security update core+modules
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Content type editing UI.
|
||||
* Content type editing user interface.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -255,11 +255,11 @@ function _node_characters($length) {
|
||||
*/
|
||||
function node_type_form_validate($form, &$form_state) {
|
||||
$type = new stdClass();
|
||||
$type->type = trim($form_state['values']['type']);
|
||||
$type->type = $form_state['values']['type'];
|
||||
$type->name = trim($form_state['values']['name']);
|
||||
|
||||
// Work out what the type was before the user submitted this form
|
||||
$old_type = trim($form_state['values']['old_type']);
|
||||
$old_type = $form_state['values']['old_type'];
|
||||
|
||||
$types = node_type_get_names();
|
||||
|
||||
@@ -288,7 +288,7 @@ function node_type_form_submit($form, &$form_state) {
|
||||
|
||||
$type = node_type_set_defaults();
|
||||
|
||||
$type->type = trim($form_state['values']['type']);
|
||||
$type->type = $form_state['values']['type'];
|
||||
$type->name = trim($form_state['values']['name']);
|
||||
$type->orig_type = trim($form_state['values']['orig_type']);
|
||||
$type->old_type = isset($form_state['values']['old_type']) ? $form_state['values']['old_type'] : $type->type;
|
||||
@@ -388,8 +388,7 @@ function node_node_type_update($info) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all of the relevant fields of a module-defined node type to their
|
||||
* default values.
|
||||
* Resets relevant fields of a module-defined node type to their default values.
|
||||
*
|
||||
* @param $type
|
||||
* The node type to reset. The node type is passed back by reference with its
|
||||
@@ -410,6 +409,8 @@ function node_type_reset($type) {
|
||||
|
||||
/**
|
||||
* Menu callback; delete a single content type.
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function node_type_delete_confirm($form, &$form_state, $type) {
|
||||
$form['type'] = array('#type' => 'value', '#value' => $type->type);
|
||||
@@ -430,6 +431,8 @@ function node_type_delete_confirm($form, &$form_state, $type) {
|
||||
|
||||
/**
|
||||
* Process content type delete confirm submissions.
|
||||
*
|
||||
* @see node_type_delete_confirm()
|
||||
*/
|
||||
function node_type_delete_confirm_submit($form, &$form_state) {
|
||||
node_type_delete($form_state['values']['type']);
|
||||
|
@@ -7,6 +7,10 @@
|
||||
|
||||
/**
|
||||
* Menu callback: confirm rebuilding of permissions.
|
||||
*
|
||||
* @see node_configure_rebuild_confirm_submit()
|
||||
* @see node_menu()
|
||||
* @ingroup forms
|
||||
*/
|
||||
function node_configure_rebuild_confirm() {
|
||||
return confirm_form(array(), t('Are you sure you want to rebuild the permissions on site content?'),
|
||||
@@ -15,6 +19,8 @@ function node_configure_rebuild_confirm() {
|
||||
|
||||
/**
|
||||
* Handler for wipe confirmation
|
||||
*
|
||||
* @see node_configure_rebuild_confirm()
|
||||
*/
|
||||
function node_configure_rebuild_confirm_submit($form, &$form_state) {
|
||||
node_access_rebuild(TRUE);
|
||||
@@ -66,6 +72,9 @@ function node_node_operations() {
|
||||
|
||||
/**
|
||||
* List node administration filters that can be applied.
|
||||
*
|
||||
* @return
|
||||
* An associative array of filters.
|
||||
*/
|
||||
function node_filters() {
|
||||
// Regular filters
|
||||
@@ -110,7 +119,7 @@ function node_filters() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply filters for node administration filters based on session.
|
||||
* Applies filters for node administration filters based on session.
|
||||
*
|
||||
* @param $query
|
||||
* A SelectQuery to which the filters should be applied.
|
||||
@@ -133,7 +142,16 @@ function node_build_filter_query(SelectQueryInterface $query) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return form for node administration filters.
|
||||
* Returns the node administration filters form array to node_admin_content().
|
||||
*
|
||||
* @see node_admin_nodes()
|
||||
* @see node_admin_nodes_submit()
|
||||
* @see node_admin_nodes_validate()
|
||||
* @see node_filter_form_submit()
|
||||
* @see node_multiple_delete_confirm()
|
||||
* @see node_multiple_delete_confirm_submit()
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function node_filter_form() {
|
||||
$session = isset($_SESSION['node_overview_filter']) ? $_SESSION['node_overview_filter'] : array();
|
||||
@@ -208,7 +226,15 @@ function node_filter_form() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process result from node administration filter form.
|
||||
* Form submission handler for node_filter_form().
|
||||
*
|
||||
* @see node_admin_content()
|
||||
* @see node_admin_nodes()
|
||||
* @see node_admin_nodes_submit()
|
||||
* @see node_admin_nodes_validate()
|
||||
* @see node_filter_form()
|
||||
* @see node_multiple_delete_confirm()
|
||||
* @see node_multiple_delete_confirm_submit()
|
||||
*/
|
||||
function node_filter_form_submit($form, &$form_state) {
|
||||
$filters = node_filters();
|
||||
@@ -240,15 +266,15 @@ function node_filter_form_submit($form, &$form_state) {
|
||||
* Make mass update of nodes, changing all nodes in the $nodes array
|
||||
* to update them with the field values in $updates.
|
||||
*
|
||||
* IMPORTANT NOTE: This function is intended to work when called
|
||||
* from a form submit handler. Calling it outside of the form submission
|
||||
* process may not work correctly.
|
||||
* IMPORTANT NOTE: This function is intended to work when called from a form
|
||||
* submission handler. Calling it outside of the form submission process may not
|
||||
* work correctly.
|
||||
*
|
||||
* @param array $nodes
|
||||
* Array of node nids to update.
|
||||
* @param array $updates
|
||||
* Array of key/value pairs with node field names and the
|
||||
* value to update that field to.
|
||||
* Array of key/value pairs with node field names and the value to update that
|
||||
* field to.
|
||||
*/
|
||||
function node_mass_update($nodes, $updates) {
|
||||
// We use batch processing to prevent timeout when updating a large number
|
||||
@@ -279,7 +305,17 @@ function node_mass_update($nodes, $updates) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Node Mass Update - helper function.
|
||||
* Updates individual nodes when fewer than 10 are queued.
|
||||
*
|
||||
* @param $nid
|
||||
* ID of node to update.
|
||||
* @param $updates
|
||||
* Associative array of updates.
|
||||
*
|
||||
* @return object
|
||||
* An updated node object.
|
||||
*
|
||||
* @see node_mass_update()
|
||||
*/
|
||||
function _node_mass_update_helper($nid, $updates) {
|
||||
$node = node_load($nid, NULL, TRUE);
|
||||
@@ -293,7 +329,14 @@ function _node_mass_update_helper($nid, $updates) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Node Mass Update Batch operation
|
||||
* Executes a batch operation for node_mass_update().
|
||||
*
|
||||
* @param array $nodes
|
||||
* An array of node IDs.
|
||||
* @param array $updates
|
||||
* Associative array of updates.
|
||||
* @param array $context
|
||||
* An array of contextual key/values.
|
||||
*/
|
||||
function _node_mass_update_batch_process($nodes, $updates, &$context) {
|
||||
if (!isset($context['sandbox']['progress'])) {
|
||||
@@ -324,7 +367,15 @@ function _node_mass_update_batch_process($nodes, $updates, &$context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Node Mass Update Batch 'finished' callback.
|
||||
* Menu callback: Reports the status of batch operation for node_mass_update().
|
||||
*
|
||||
* @param bool $success
|
||||
* A boolean indicating whether the batch mass update operation successfully
|
||||
* concluded.
|
||||
* @param int $results
|
||||
* The number of nodes updated via the batch mode process.
|
||||
* @param array $operations
|
||||
* An array of function calls (not used in this function).
|
||||
*/
|
||||
function _node_mass_update_batch_finished($success, $results, $operations) {
|
||||
if ($success) {
|
||||
@@ -339,7 +390,17 @@ function _node_mass_update_batch_finished($success, $results, $operations) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback: content administration.
|
||||
* Page callback: Form constructor for the content administration form.
|
||||
*
|
||||
* @see node_admin_nodes()
|
||||
* @see node_admin_nodes_submit()
|
||||
* @see node_admin_nodes_validate()
|
||||
* @see node_filter_form()
|
||||
* @see node_filter_form_submit()
|
||||
* @see node_menu()
|
||||
* @see node_multiple_delete_confirm()
|
||||
* @see node_multiple_delete_confirm_submit()
|
||||
* @ingroup forms
|
||||
*/
|
||||
function node_admin_content($form, $form_state) {
|
||||
if (isset($form_state['values']['operation']) && $form_state['values']['operation'] == 'delete') {
|
||||
@@ -354,6 +415,15 @@ function node_admin_content($form, $form_state) {
|
||||
|
||||
/**
|
||||
* Form builder: Builds the node administration overview.
|
||||
*
|
||||
* @see node_admin_nodes_submit()
|
||||
* @see node_admin_nodes_validate()
|
||||
* @see node_filter_form()
|
||||
* @see node_filter_form_submit()
|
||||
* @see node_multiple_delete_confirm()
|
||||
* @see node_multiple_delete_confirm_submit()
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function node_admin_nodes() {
|
||||
$admin_access = user_access('administer nodes');
|
||||
@@ -401,6 +471,7 @@ function node_admin_nodes() {
|
||||
$header['operations'] = array('data' => t('Operations'));
|
||||
|
||||
$query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort');
|
||||
$query->addTag('node_admin_filter');
|
||||
node_build_filter_query($query);
|
||||
|
||||
if (!user_access('bypass node access')) {
|
||||
@@ -525,8 +596,15 @@ function node_admin_nodes() {
|
||||
/**
|
||||
* Validate node_admin_nodes form submissions.
|
||||
*
|
||||
* Check if any nodes have been selected to perform the chosen
|
||||
* 'Update option' on.
|
||||
* Checks whether any nodes have been selected to perform the chosen 'Update
|
||||
* option' on.
|
||||
*
|
||||
* @see node_admin_nodes()
|
||||
* @see node_admin_nodes_submit()
|
||||
* @see node_filter_form()
|
||||
* @see node_filter_form_submit()
|
||||
* @see node_multiple_delete_confirm()
|
||||
* @see node_multiple_delete_confirm_submit()
|
||||
*/
|
||||
function node_admin_nodes_validate($form, &$form_state) {
|
||||
// Error if there are no items to select.
|
||||
@@ -538,7 +616,14 @@ function node_admin_nodes_validate($form, &$form_state) {
|
||||
/**
|
||||
* Process node_admin_nodes form submissions.
|
||||
*
|
||||
* Execute the chosen 'Update option' on the selected nodes.
|
||||
* Executes the chosen 'Update option' on the selected nodes.
|
||||
*
|
||||
* @see node_admin_nodes()
|
||||
* @see node_admin_nodes_validate()
|
||||
* @see node_filter_form()
|
||||
* @see node_filter_form_submit()
|
||||
* @see node_multiple_delete_confirm()
|
||||
* @see node_multiple_delete_confirm_submit()
|
||||
*/
|
||||
function node_admin_nodes_submit($form, &$form_state) {
|
||||
$operations = module_invoke_all('node_operations');
|
||||
@@ -564,6 +649,17 @@ function node_admin_nodes_submit($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple node deletion confirmation form for node_admin_content().
|
||||
*
|
||||
* @see node_admin_nodes()
|
||||
* @see node_admin_nodes_submit()
|
||||
* @see node_admin_nodes_validate()
|
||||
* @see node_filter_form()
|
||||
* @see node_filter_form_submit()
|
||||
* @see node_multiple_delete_confirm_submit()
|
||||
* @ingroup forms
|
||||
*/
|
||||
function node_multiple_delete_confirm($form, &$form_state, $nodes) {
|
||||
$form['nodes'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
|
||||
// array_filter returns only elements with TRUE values
|
||||
@@ -587,9 +683,20 @@ function node_multiple_delete_confirm($form, &$form_state, $nodes) {
|
||||
t('Delete'), t('Cancel'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission handler for node_multiple_delete_confirm().
|
||||
*
|
||||
* @see node_admin_nodes()
|
||||
* @see node_admin_nodes_submit()
|
||||
* @see node_admin_nodes_validate()
|
||||
* @see node_filter_form()
|
||||
* @see node_filter_form_submit()
|
||||
* @see node_multiple_delete_confirm()
|
||||
*/
|
||||
function node_multiple_delete_confirm_submit($form, &$form_state) {
|
||||
if ($form_state['values']['confirm']) {
|
||||
node_delete_multiple(array_keys($form_state['values']['nodes']));
|
||||
cache_clear_all();
|
||||
$count = count($form_state['values']['nodes']);
|
||||
watchdog('content', 'Deleted @count posts.', array('@count' => $count));
|
||||
drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.'));
|
||||
|
@@ -11,21 +11,24 @@
|
||||
* Functions to define and modify content types.
|
||||
*
|
||||
* Each content type is maintained by a primary module, which is either
|
||||
* node.module (for content types created in the user interface) or the
|
||||
* module that implements hook_node_info() to define the content type.
|
||||
* node.module (for content types created in the user interface) or the module
|
||||
* that implements hook_node_info() to define the content type.
|
||||
*
|
||||
* During node operations (create, update, view, delete, etc.), there are
|
||||
* several sets of hooks that get invoked to allow modules to modify the base
|
||||
* node operation:
|
||||
* - Node-type-specific hooks: These hooks are only invoked on the primary
|
||||
* module, using the "base" return component of hook_node_info() as the
|
||||
* function prefix. For example, poll.module defines the base for the Poll
|
||||
* content type as "poll", so during creation of a poll node, hook_insert() is
|
||||
* only invoked by calling poll_insert().
|
||||
* - All-module hooks: This set of hooks is invoked on all implementing
|
||||
* modules, to allow other modules to modify what the primary node module is
|
||||
* doing. For example, hook_node_insert() is invoked on all modules when
|
||||
* creating a poll node.
|
||||
* - Node-type-specific hooks: When defining a node type, hook_node_info()
|
||||
* returns a 'base' component. Node-type-specific hooks are named
|
||||
* base_hookname() instead of mymodule_hookname() (in a module called
|
||||
* 'mymodule' for example). Only the node type's corresponding implementation
|
||||
* is invoked. For example, poll_node_info() in poll.module defines the base
|
||||
* for the 'poll' node type as 'poll'. So when a poll node is created,
|
||||
* hook_insert() is invoked on poll_insert() only.
|
||||
* Hooks that are node-type-specific are noted below.
|
||||
* - All-module hooks: This set of hooks is invoked on all implementing modules,
|
||||
* to allow other modules to modify what the primary node module is doing. For
|
||||
* example, hook_node_insert() is invoked on all modules when creating a poll
|
||||
* node.
|
||||
* - Field hooks: Hooks related to the fields attached to the node. These are
|
||||
* invoked from the field operations functions described below, and can be
|
||||
* either field-type-specific or all-module hooks.
|
||||
@@ -56,16 +59,15 @@
|
||||
* - hook_entity_update() (all)
|
||||
* - hook_node_access_records() (all)
|
||||
* - hook_node_access_records_alter() (all)
|
||||
* - Loading a node (calling node_load(), node_load_multiple(), or
|
||||
* entity_load() with $entity_type of 'node'):
|
||||
* - Loading a node (calling node_load(), node_load_multiple() or entity_load()
|
||||
* with $entity_type of 'node'):
|
||||
* - Node and revision information is read from database.
|
||||
* - hook_load() (node-type-specific)
|
||||
* - field_attach_load_revision() and field_attach_load()
|
||||
* - hook_entity_load() (all)
|
||||
* - hook_node_load() (all)
|
||||
* - Viewing a single node (calling node_view() - note that the input to
|
||||
* node_view() is a loaded node, so the Loading steps above are already
|
||||
* done):
|
||||
* node_view() is a loaded node, so the Loading steps above are already done):
|
||||
* - hook_view() (node-type-specific)
|
||||
* - field_attach_prepare_view()
|
||||
* - hook_entity_prepare_view() (all)
|
||||
@@ -97,9 +99,8 @@
|
||||
* - Revision information is deleted from database
|
||||
* - hook_node_revision_delete() (all)
|
||||
* - field_attach_delete_revision()
|
||||
* - Preparing a node for editing (calling node_form() - note that if it's
|
||||
* an existing node, it will already be loaded; see the Loading section
|
||||
* above):
|
||||
* - Preparing a node for editing (calling node_form() - note that if it is an
|
||||
* existing node, it will already be loaded; see the Loading section above):
|
||||
* - hook_prepare() (node-type-specific)
|
||||
* - hook_node_prepare() (all)
|
||||
* - hook_form() (node-type-specific)
|
||||
@@ -137,16 +138,16 @@
|
||||
* associated with permission to view, edit, and delete individual nodes.
|
||||
*
|
||||
* The realms and grant IDs can be arbitrarily defined by your node access
|
||||
* module; it is common to use role IDs as grant IDs, but that is not
|
||||
* required. Your module could instead maintain its own list of users, where
|
||||
* each list has an ID. In that case, the return value of this hook would be
|
||||
* an array of the list IDs that this user is a member of.
|
||||
* module; it is common to use role IDs as grant IDs, but that is not required.
|
||||
* Your module could instead maintain its own list of users, where each list has
|
||||
* an ID. In that case, the return value of this hook would be an array of the
|
||||
* list IDs that this user is a member of.
|
||||
*
|
||||
* A node access module may implement as many realms as necessary to
|
||||
* properly define the access privileges for the nodes. Note that the system
|
||||
* makes no distinction between published and unpublished nodes. It is the
|
||||
* module's responsibility to provide appropriate realms to limit access to
|
||||
* unpublished content.
|
||||
* A node access module may implement as many realms as necessary to properly
|
||||
* define the access privileges for the nodes. Note that the system makes no
|
||||
* distinction between published and unpublished nodes. It is the module's
|
||||
* responsibility to provide appropriate realms to limit access to unpublished
|
||||
* content.
|
||||
*
|
||||
* Node access records are stored in the {node_access} table and define which
|
||||
* grants are required to access a node. There is a special case for the view
|
||||
@@ -183,7 +184,7 @@
|
||||
* @param $account
|
||||
* The user object whose grants are requested.
|
||||
* @param $op
|
||||
* The node operation to be performed, such as "view", "update", or "delete".
|
||||
* The node operation to be performed, such as 'view', 'update', or 'delete'.
|
||||
*
|
||||
* @return
|
||||
* An array whose keys are "realms" of grants, and whose values are arrays of
|
||||
@@ -197,7 +198,7 @@ function hook_node_grants($account, $op) {
|
||||
if (user_access('access private content', $account)) {
|
||||
$grants['example'] = array(1);
|
||||
}
|
||||
$grants['example_owner'] = array($account->uid);
|
||||
$grants['example_author'] = array($account->uid);
|
||||
return $grants;
|
||||
}
|
||||
|
||||
@@ -264,6 +265,7 @@ function hook_node_grants($account, $op) {
|
||||
* @return
|
||||
* An array of grants as defined above.
|
||||
*
|
||||
* @see hook_node_access_records_alter()
|
||||
* @ingroup node_access
|
||||
*/
|
||||
function hook_node_access_records($node) {
|
||||
@@ -350,12 +352,11 @@ function hook_node_access_records_alter(&$grants, $node) {
|
||||
* Alter user access rules when trying to view, edit or delete a node.
|
||||
*
|
||||
* Node access modules establish rules for user access to content.
|
||||
* hook_node_grants() defines permissions for a user to view, edit or
|
||||
* delete nodes by building a $grants array that indicates the permissions
|
||||
* assigned to the user by each node access module. This hook is called to allow
|
||||
* modules to modify the $grants array by reference, so the interaction of
|
||||
* multiple node access modules can be altered or advanced business logic can be
|
||||
* applied.
|
||||
* hook_node_grants() defines permissions for a user to view, edit or delete
|
||||
* nodes by building a $grants array that indicates the permissions assigned to
|
||||
* the user by each node access module. This hook is called to allow modules to
|
||||
* modify the $grants array by reference, so the interaction of multiple node
|
||||
* access modules can be altered or advanced business logic can be applied.
|
||||
*
|
||||
* @see hook_node_grants()
|
||||
*
|
||||
@@ -374,8 +375,8 @@ function hook_node_access_records_alter(&$grants, $node) {
|
||||
* @param $op
|
||||
* The operation being performed, 'view', 'update' or 'delete'.
|
||||
*
|
||||
* Developers may use this hook to either add additional grants to a user
|
||||
* or to remove existing grants. These rules are typically based on either the
|
||||
* Developers may use this hook to either add additional grants to a user or to
|
||||
* remove existing grants. These rules are typically based on either the
|
||||
* permissions assigned to a user role, or specific attributes of a user
|
||||
* account.
|
||||
*
|
||||
@@ -412,10 +413,10 @@ function hook_node_grants_alter(&$grants, $account, $op) {
|
||||
* @return
|
||||
* An array of operations. Each operation is an associative array that may
|
||||
* contain the following key-value pairs:
|
||||
* - 'label': Required. The label for the operation, displayed in the dropdown
|
||||
* - label: (required) The label for the operation, displayed in the dropdown
|
||||
* menu.
|
||||
* - 'callback': Required. The function to call for the operation.
|
||||
* - 'callback arguments': Optional. An array of additional arguments to pass
|
||||
* - callback: (required) The function to call for the operation.
|
||||
* - callback arguments: (optional) An array of additional arguments to pass
|
||||
* to the callback function.
|
||||
*/
|
||||
function hook_node_operations() {
|
||||
@@ -528,11 +529,10 @@ function hook_node_insert($node) {
|
||||
/**
|
||||
* Act on arbitrary nodes being loaded from the database.
|
||||
*
|
||||
* This hook should be used to add information that is not in the node or
|
||||
* node revisions table, not to replace information that is in these tables
|
||||
* (which could interfere with the entity cache). For performance reasons,
|
||||
* information for all available nodes should be loaded in a single query where
|
||||
* possible.
|
||||
* This hook should be used to add information that is not in the node or node
|
||||
* revisions table, not to replace information that is in these tables (which
|
||||
* could interfere with the entity cache). For performance reasons, information
|
||||
* for all available nodes should be loaded in a single query where possible.
|
||||
*
|
||||
* This hook is invoked during node loading, which is handled by entity_load(),
|
||||
* via classes NodeController and DrupalDefaultEntityController. After the node
|
||||
@@ -572,15 +572,15 @@ function hook_node_load($nodes, $types) {
|
||||
* Modules may implement this hook if they want to have a say in whether or not
|
||||
* a given user has access to perform a given operation on a node.
|
||||
*
|
||||
* The administrative account (user ID #1) always passes any access check,
|
||||
* so this hook is not called in that case. Users with the "bypass node access"
|
||||
* The administrative account (user ID #1) always passes any access check, so
|
||||
* this hook is not called in that case. Users with the "bypass node access"
|
||||
* permission may always view and edit content through the administrative
|
||||
* interface.
|
||||
*
|
||||
* Note that not all modules will want to influence access on all
|
||||
* node types. If your module does not want to actively grant or
|
||||
* block access, return NODE_ACCESS_IGNORE or simply return nothing.
|
||||
* Blindly returning FALSE will break other node access modules.
|
||||
* Note that not all modules will want to influence access on all node types. If
|
||||
* your module does not want to actively grant or block access, return
|
||||
* NODE_ACCESS_IGNORE or simply return nothing. Blindly returning FALSE will
|
||||
* break other node access modules.
|
||||
*
|
||||
* Also note that this function isn't called for node listings (e.g., RSS feeds,
|
||||
* the default home page at path 'node', a recent content block, etc.) See
|
||||
@@ -651,17 +651,17 @@ function hook_node_prepare($node) {
|
||||
/**
|
||||
* Act on a node being displayed as a search result.
|
||||
*
|
||||
* This hook is invoked from node_search_execute(), after node_load()
|
||||
* and node_view() have been called.
|
||||
* This hook is invoked from node_search_execute(), after node_load() and
|
||||
* node_view() have been called.
|
||||
*
|
||||
* @param $node
|
||||
* The node being displayed in a search result.
|
||||
*
|
||||
* @return array
|
||||
* Extra information to be displayed with search result. This information
|
||||
* should be presented as an associative array. It will be concatenated
|
||||
* with the post information (last updated, author) in the default search
|
||||
* result theming.
|
||||
* should be presented as an associative array. It will be concatenated with
|
||||
* the post information (last updated, author) in the default search result
|
||||
* theming.
|
||||
*
|
||||
* @see template_preprocess_search_result()
|
||||
* @see search-result.tpl.php
|
||||
@@ -724,8 +724,8 @@ function hook_node_update($node) {
|
||||
/**
|
||||
* Act on a node being indexed for searching.
|
||||
*
|
||||
* This hook is invoked during search indexing, after node_load(), and after
|
||||
* the result of node_view() is added as $node->rendered to the node object.
|
||||
* This hook is invoked during search indexing, after node_load(), and after the
|
||||
* result of node_view() is added as $node->rendered to the node object.
|
||||
*
|
||||
* @param $node
|
||||
* The node being indexed.
|
||||
@@ -756,8 +756,8 @@ function hook_node_update_index($node) {
|
||||
*
|
||||
* Note: Changes made to the $node object within your hook implementation will
|
||||
* have no effect. The preferred method to change a node's content is to use
|
||||
* hook_node_presave() instead. If it is really necessary to change
|
||||
* the node at the validate stage, you can use form_set_value().
|
||||
* hook_node_presave() instead. If it is really necessary to change the node at
|
||||
* the validate stage, you can use form_set_value().
|
||||
*
|
||||
* @param $node
|
||||
* The node being validated.
|
||||
@@ -874,8 +874,8 @@ function hook_node_view_alter(&$build) {
|
||||
*
|
||||
* This hook allows a module to define one or more of its own node types. For
|
||||
* example, the blog module uses it to define a blog node-type named "Blog
|
||||
* entry." The name and attributes of each desired node type are specified in
|
||||
* an array returned by the hook.
|
||||
* entry." The name and attributes of each desired node type are specified in an
|
||||
* array returned by the hook.
|
||||
*
|
||||
* Only module-provided node types should be defined through this hook. User-
|
||||
* provided (or 'custom') node types should be defined only in the 'node_type'
|
||||
@@ -887,22 +887,21 @@ function hook_node_view_alter(&$build) {
|
||||
* contains a sub-array for each node type, with the machine-readable type
|
||||
* name as the key. Each sub-array has up to 10 attributes. Possible
|
||||
* attributes:
|
||||
* - "name": the human-readable name of the node type. Required.
|
||||
* - "base": the base string used to construct callbacks corresponding to
|
||||
* this node type.
|
||||
* (i.e. if base is defined as example_foo, then example_foo_insert will
|
||||
* be called when inserting a node of that type). This string is usually
|
||||
* the name of the module, but not always. Required.
|
||||
* - "description": a brief description of the node type. Required.
|
||||
* - "help": help information shown to the user when creating a node of
|
||||
* this type.. Optional (defaults to '').
|
||||
* - "has_title": boolean indicating whether or not this node type has a title
|
||||
* field. Optional (defaults to TRUE).
|
||||
* - "title_label": the label for the title field of this content type.
|
||||
* Optional (defaults to 'Title').
|
||||
* - "locked": boolean indicating whether the administrator can change the
|
||||
* machine name of this type. FALSE = changeable (not locked),
|
||||
* TRUE = unchangeable (locked). Optional (defaults to TRUE).
|
||||
* - name: (required) The human-readable name of the node type.
|
||||
* - base: (required) The base name for implementations of node-type-specific
|
||||
* hooks that respond to this node type. Base is usually the name of the
|
||||
* module or 'node_content', but not always. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
* - description: (required) A brief description of the node type.
|
||||
* - help: (optional) Help information shown to the user when creating a node
|
||||
* of this type.
|
||||
* - has_title: (optional) A Boolean indicating whether or not this node type
|
||||
* has a title field.
|
||||
* - title_label: (optional) The label for the title field of this content
|
||||
* type.
|
||||
* - locked: (optional) A Boolean indicating whether the administrator can
|
||||
* change the machine name of this type. FALSE = changeable (not locked),
|
||||
* TRUE = unchangeable (locked).
|
||||
*
|
||||
* The machine name of a node type should contain only letters, numbers, and
|
||||
* underscores. Underscores will be converted into hyphens for the purpose of
|
||||
@@ -950,20 +949,20 @@ function hook_node_info() {
|
||||
* corresponding to the internal name of the ranking mechanism, such as
|
||||
* 'recent', or 'comments'. The values should be arrays themselves, with the
|
||||
* following keys available:
|
||||
* - "title": the human readable name of the ranking mechanism. Required.
|
||||
* - "join": part of a query string to join to any additional necessary
|
||||
* table. This is not necessary if the table required is already joined to
|
||||
* by the base query, such as for the {node} table. Other tables should use
|
||||
* the full table name as an alias to avoid naming collisions. Optional.
|
||||
* - "score": part of a query string to calculate the score for the ranking
|
||||
* mechanism based on values in the database. This does not need to be
|
||||
* wrapped in parentheses, as it will be done automatically; it also does
|
||||
* not need to take the weighted system into account, as it will be done
|
||||
* automatically. It does, however, need to calculate a decimal between
|
||||
* - title: (required) The human readable name of the ranking mechanism.
|
||||
* - join: (optional) The part of a query string to join to any additional
|
||||
* necessary table. This is not necessary if the table required is already
|
||||
* joined to by the base query, such as for the {node} table. Other tables
|
||||
* should use the full table name as an alias to avoid naming collisions.
|
||||
* - score: (required) The part of a query string to calculate the score for
|
||||
* the ranking mechanism based on values in the database. This does not need
|
||||
* to be wrapped in parentheses, as it will be done automatically; it also
|
||||
* does not need to take the weighted system into account, as it will be
|
||||
* done automatically. It does, however, need to calculate a decimal between
|
||||
* 0 and 1; be careful not to cast the entire score to an integer by
|
||||
* inadvertently introducing a variable argument. Required.
|
||||
* - "arguments": if any arguments are required for the score, they can be
|
||||
* specified in an array here.
|
||||
* inadvertently introducing a variable argument.
|
||||
* - arguments: (optional) If any arguments are required for the score, they
|
||||
* can be specified in an array here.
|
||||
*
|
||||
* @ingroup node_api_hooks
|
||||
*/
|
||||
@@ -990,8 +989,8 @@ function hook_ranking() {
|
||||
/**
|
||||
* Respond to node type creation.
|
||||
*
|
||||
* This hook is invoked from node_type_save() after the node type is added
|
||||
* to the database.
|
||||
* This hook is invoked from node_type_save() after the node type is added to
|
||||
* the database.
|
||||
*
|
||||
* @param $info
|
||||
* The node type object that is being created.
|
||||
@@ -1003,8 +1002,8 @@ function hook_node_type_insert($info) {
|
||||
/**
|
||||
* Respond to node type updates.
|
||||
*
|
||||
* This hook is invoked from node_type_save() after the node type is updated
|
||||
* in the database.
|
||||
* This hook is invoked from node_type_save() after the node type is updated in
|
||||
* the database.
|
||||
*
|
||||
* @param $info
|
||||
* The node type object that is being updated.
|
||||
@@ -1033,12 +1032,23 @@ function hook_node_type_delete($info) {
|
||||
/**
|
||||
* Respond to node deletion.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_delete() to respond to all node deletions).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* This hook is invoked from node_delete_multiple() after the node has been
|
||||
* removed from the node table in the database, before hook_node_delete() is
|
||||
* invoked, and before field_attach_delete() is called.
|
||||
* Use hook_node_delete() to respond to node deletion of all node types.
|
||||
*
|
||||
* This hook is invoked from node_delete_multiple() before hook_node_delete()
|
||||
* is invoked and before field_attach_delete() is called.
|
||||
*
|
||||
* Note that when this hook is invoked, the changes have not yet been written
|
||||
* to the database, because a database transaction is still in progress. The
|
||||
* transaction is not finalized until the delete operation is entirely
|
||||
* completed and node_delete_multiple() goes out of scope. You should not rely
|
||||
* on data in the database at this time as it is not updated yet. You should
|
||||
* also note that any write/update database queries executed from this hook are
|
||||
* also not committed immediately. Check node_delete_multiple() and
|
||||
* db_transaction() for more info.
|
||||
*
|
||||
* @param $node
|
||||
* The node that is being deleted.
|
||||
@@ -1054,8 +1064,11 @@ function hook_delete($node) {
|
||||
/**
|
||||
* Act on a node object about to be shown on the add/edit form.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_prepare() to act on all node preparations).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_prepare() to respond to node preparation of all node types.
|
||||
*
|
||||
* This hook is invoked from node_object_prepare() before the general
|
||||
* hook_node_prepare() is invoked.
|
||||
@@ -1066,26 +1079,31 @@ function hook_delete($node) {
|
||||
* @ingroup node_api_hooks
|
||||
*/
|
||||
function hook_prepare($node) {
|
||||
if ($file = file_check_upload($field_name)) {
|
||||
$file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
|
||||
if ($file) {
|
||||
if (!image_get_info($file->uri)) {
|
||||
form_set_error($field_name, t('Uploaded file is not a valid image'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
|
||||
if ($file) {
|
||||
if (!image_get_info($file->uri)) {
|
||||
form_set_error($field_name, t('Uploaded file is not a valid image'));
|
||||
return;
|
||||
}
|
||||
$node->images['_original'] = $file->uri;
|
||||
_image_build_derivatives($node, TRUE);
|
||||
$node->new_file = TRUE;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
$node->images['_original'] = $file->uri;
|
||||
_image_build_derivatives($node, TRUE);
|
||||
$node->new_file = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a node editing form.
|
||||
*
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_form_BASE_FORM_ID_alter(), with base form ID 'node_form', to alter
|
||||
* node forms for all node types.
|
||||
*
|
||||
* This hook, implemented by node modules, is called to retrieve the form
|
||||
* that is displayed to create or edit a node. This form is displayed at path
|
||||
* node/add/[node type] or node/[node ID]/edit.
|
||||
@@ -1141,8 +1159,11 @@ function hook_form($node, &$form_state) {
|
||||
/**
|
||||
* Respond to creation of a new node.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_insert() to act on all node insertions).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_insert() to respond to node insertion of all node types.
|
||||
*
|
||||
* This hook is invoked from node_save() after the node is inserted into the
|
||||
* node table in the database, before field_attach_insert() is called, and
|
||||
@@ -1165,8 +1186,11 @@ function hook_insert($node) {
|
||||
/**
|
||||
* Act on nodes being loaded from the database.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_load() to respond to all node loads).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_load() to respond to node load of all node types.
|
||||
*
|
||||
* This hook is invoked during node loading, which is handled by entity_load(),
|
||||
* via classes NodeController and DrupalDefaultEntityController. After the node
|
||||
@@ -1199,8 +1223,11 @@ function hook_load($nodes) {
|
||||
/**
|
||||
* Respond to updates to a node.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_update() to act on all node updates).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_update() to respond to node update of all node types.
|
||||
*
|
||||
* This hook is invoked from node_save() after the node is updated in the
|
||||
* node table in the database, before field_attach_update() is called, and
|
||||
@@ -1221,8 +1248,11 @@ function hook_update($node) {
|
||||
/**
|
||||
* Perform node validation before a node is created or updated.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_validate() to act on all node validations).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_validate() to respond to node validation of all node types.
|
||||
*
|
||||
* This hook is invoked from node_validate(), after a user has finished
|
||||
* editing the node and is previewing or submitting it. It is invoked at the end
|
||||
@@ -1255,32 +1285,38 @@ function hook_validate($node, $form, &$form_state) {
|
||||
/**
|
||||
* Display a node.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_view() to act on all node views).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* This hook is invoked during node viewing after the node is fully loaded,
|
||||
* so that the node type module can define a custom method for display, or
|
||||
* add to the default display.
|
||||
* Use hook_node_view() to respond to node view of all node types.
|
||||
*
|
||||
* This hook is invoked during node viewing after the node is fully loaded, so
|
||||
* that the node type module can define a custom method for display, or add to
|
||||
* the default display.
|
||||
*
|
||||
* @param $node
|
||||
* The node to be displayed, as returned by node_load().
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full', 'teaser', ...
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*
|
||||
* @return
|
||||
* $node. The passed $node parameter should be modified as necessary and
|
||||
* returned so it can be properly presented. Nodes are prepared for display
|
||||
* by assembling a structured array, formatted as in the Form API, in
|
||||
* $node->content. As with Form API arrays, the #weight property can be
|
||||
* used to control the relative positions of added elements. After this
|
||||
* hook is invoked, node_view() calls field_attach_view() to add field
|
||||
* views to $node->content, and then invokes hook_node_view() and
|
||||
* hook_node_view_alter(), so if you want to affect the final
|
||||
* view of the node, you might consider implementing one of these hooks
|
||||
* instead.
|
||||
* The passed $node parameter should be modified as necessary and returned so
|
||||
* it can be properly presented. Nodes are prepared for display by assembling
|
||||
* a structured array, formatted as in the Form API, in $node->content. As
|
||||
* with Form API arrays, the #weight property can be used to control the
|
||||
* relative positions of added elements. After this hook is invoked,
|
||||
* node_view() calls field_attach_view() to add field views to $node->content,
|
||||
* and then invokes hook_node_view() and hook_node_view_alter(), so if you
|
||||
* want to affect the final view of the node, you might consider implementing
|
||||
* one of these hooks instead.
|
||||
*
|
||||
* @ingroup node_api_hooks
|
||||
*/
|
||||
function hook_view($node, $view_mode) {
|
||||
function hook_view($node, $view_mode, $langcode = NULL) {
|
||||
if ($view_mode == 'full' && node_is_page($node)) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('Home'), NULL);
|
||||
|
@@ -8,3 +8,9 @@ files[] = node.test
|
||||
required = TRUE
|
||||
configure = admin/structure/types
|
||||
stylesheets[all][] = node.css
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -114,6 +114,7 @@ function node_schema() {
|
||||
'uid' => array('uid'),
|
||||
'tnid' => array('tnid'),
|
||||
'translate' => array('translate'),
|
||||
'language' => array('language'),
|
||||
),
|
||||
'unique keys' => array(
|
||||
'vid' => array('vid'),
|
||||
@@ -914,6 +915,7 @@ function node_update_7012() {
|
||||
* Change {node}.vid default value from 0 to NULL to avoid deadlock issues on MySQL.
|
||||
*/
|
||||
function node_update_7013() {
|
||||
db_drop_unique_key('node', 'vid');
|
||||
db_change_field('node', 'vid', 'vid', array(
|
||||
'description' => 'The current {node_revision}.vid version identifier.',
|
||||
'type' => 'int',
|
||||
@@ -921,6 +923,14 @@ function node_update_7013() {
|
||||
'not null' => FALSE,
|
||||
'default' => NULL,
|
||||
));
|
||||
db_add_unique_key('node', 'vid', array('vid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an index on {node}.language.
|
||||
*/
|
||||
function node_update_7014() {
|
||||
db_add_index('node', 'language', array('language'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,6 @@
|
||||
* Page callbacks for adding, editing, deleting, and revisions management for content.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Menu callback; presents the node editing form.
|
||||
*/
|
||||
@@ -63,6 +62,12 @@ function theme_node_add_list($variables) {
|
||||
|
||||
/**
|
||||
* Returns a node submission form.
|
||||
*
|
||||
* @param $type
|
||||
* The node type for the submitted node.
|
||||
*
|
||||
* @return
|
||||
* The themed form.
|
||||
*/
|
||||
function node_add($type) {
|
||||
global $user;
|
||||
@@ -75,6 +80,12 @@ function node_add($type) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form validation handler for node_form().
|
||||
*
|
||||
* @see node_form()
|
||||
* @see node_form_submit()
|
||||
*/
|
||||
function node_form_validate($form, &$form_state) {
|
||||
// $form_state['node'] contains the actual entity being edited, but we must
|
||||
// not update it with form values that have not yet been validated, so we
|
||||
@@ -85,7 +96,13 @@ function node_form_validate($form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the node add/edit form array.
|
||||
* Form constructor for the node add/edit form.
|
||||
*
|
||||
* @see node_form_validate()
|
||||
* @see node_form_submit()
|
||||
* @see node_form_build_preview()
|
||||
* @see node_form_delete_submit()
|
||||
* @ingroup forms
|
||||
*/
|
||||
function node_form($form, &$form_state, $node) {
|
||||
global $user;
|
||||
@@ -311,7 +328,12 @@ function node_form($form, &$form_state, $node) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Button submit function: handle the 'Delete' button on the node form.
|
||||
* Form submission handler for node_form().
|
||||
*
|
||||
* Handles the 'Delete' button on the node form.
|
||||
*
|
||||
* @see node_form()
|
||||
* @see node_form_validate()
|
||||
*/
|
||||
function node_form_delete_submit($form, &$form_state) {
|
||||
$destination = array();
|
||||
@@ -323,7 +345,14 @@ function node_form_delete_submit($form, &$form_state) {
|
||||
$form_state['redirect'] = array('node/' . $node->nid . '/delete', array('query' => $destination));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Form submission handler for node_form().
|
||||
*
|
||||
* Handles the 'Preview' button on the node form.
|
||||
*
|
||||
* @see node_form()
|
||||
* @see node_form_validate()
|
||||
*/
|
||||
function node_form_build_preview($form, &$form_state) {
|
||||
$node = node_form_submit_build_node($form, $form_state);
|
||||
$form_state['node_preview'] = node_preview($node);
|
||||
@@ -331,38 +360,49 @@ function node_form_build_preview($form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a node preview.
|
||||
* Generates a node preview.
|
||||
*
|
||||
* @param $node
|
||||
* The node to preview.
|
||||
*
|
||||
* @return
|
||||
* An HTML-formatted string of a node preview.
|
||||
*
|
||||
* @see node_form_build_preview()
|
||||
*/
|
||||
function node_preview($node) {
|
||||
if (node_access('create', $node) || node_access('update', $node)) {
|
||||
_field_invoke_multiple('load', 'node', array($node->nid => $node));
|
||||
// Clone the node before previewing it to prevent the node itself from being
|
||||
// modified.
|
||||
$cloned_node = clone $node;
|
||||
if (node_access('create', $cloned_node) || node_access('update', $cloned_node)) {
|
||||
_field_invoke_multiple('load', 'node', array($cloned_node->nid => $cloned_node));
|
||||
// Load the user's name when needed.
|
||||
if (isset($node->name)) {
|
||||
if (isset($cloned_node->name)) {
|
||||
// The use of isset() is mandatory in the context of user IDs, because
|
||||
// user ID 0 denotes the anonymous user.
|
||||
if ($user = user_load_by_name($node->name)) {
|
||||
$node->uid = $user->uid;
|
||||
$node->picture = $user->picture;
|
||||
if ($user = user_load_by_name($cloned_node->name)) {
|
||||
$cloned_node->uid = $user->uid;
|
||||
$cloned_node->picture = $user->picture;
|
||||
}
|
||||
else {
|
||||
$node->uid = 0; // anonymous user
|
||||
$cloned_node->uid = 0; // anonymous user
|
||||
}
|
||||
}
|
||||
elseif ($node->uid) {
|
||||
$user = user_load($node->uid);
|
||||
$node->name = $user->name;
|
||||
$node->picture = $user->picture;
|
||||
elseif ($cloned_node->uid) {
|
||||
$user = user_load($cloned_node->uid);
|
||||
$cloned_node->name = $user->name;
|
||||
$cloned_node->picture = $user->picture;
|
||||
}
|
||||
|
||||
$node->changed = REQUEST_TIME;
|
||||
$nodes = array($node->nid => $node);
|
||||
$cloned_node->changed = REQUEST_TIME;
|
||||
$nodes = array($cloned_node->nid => $cloned_node);
|
||||
field_attach_prepare_view('node', $nodes, 'full');
|
||||
|
||||
// Display a preview of the node.
|
||||
if (!form_get_errors()) {
|
||||
$node->in_preview = TRUE;
|
||||
$output = theme('node_preview', array('node' => $node));
|
||||
unset($node->in_preview);
|
||||
$cloned_node->in_preview = TRUE;
|
||||
$output = theme('node_preview', array('node' => $cloned_node));
|
||||
unset($cloned_node->in_preview);
|
||||
}
|
||||
drupal_set_title(t('Preview'), PASS_THROUGH);
|
||||
|
||||
@@ -377,6 +417,7 @@ function node_preview($node) {
|
||||
* An associative array containing:
|
||||
* - node: The node object which is being previewed.
|
||||
*
|
||||
* @see node_preview()
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_node_preview($variables) {
|
||||
@@ -407,6 +448,12 @@ function theme_node_preview($variables) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission handler for node_form().
|
||||
*
|
||||
* @see node_form()
|
||||
* @see node_form_validate()
|
||||
*/
|
||||
function node_form_submit($form, &$form_state) {
|
||||
$node = node_form_submit_build_node($form, $form_state);
|
||||
$insert = empty($node->nid);
|
||||
@@ -426,7 +473,7 @@ function node_form_submit($form, &$form_state) {
|
||||
if ($node->nid) {
|
||||
$form_state['values']['nid'] = $node->nid;
|
||||
$form_state['nid'] = $node->nid;
|
||||
$form_state['redirect'] = 'node/' . $node->nid;
|
||||
$form_state['redirect'] = node_access('view', $node) ? 'node/' . $node->nid : '<front>';
|
||||
}
|
||||
else {
|
||||
// In the unlikely case something went wrong on save, the node will be
|
||||
@@ -472,7 +519,9 @@ function node_form_submit_build_node($form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback -- ask for confirmation of node deletion
|
||||
* Form constructor for the node deletion confirmation form.
|
||||
*
|
||||
* @see node_delete_confirm_submit()
|
||||
*/
|
||||
function node_delete_confirm($form, &$form_state, $node) {
|
||||
$form['#node'] = $node;
|
||||
@@ -488,12 +537,15 @@ function node_delete_confirm($form, &$form_state, $node) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute node deletion
|
||||
* Executes node deletion.
|
||||
*
|
||||
* @see node_delete_confirm()
|
||||
*/
|
||||
function node_delete_confirm_submit($form, &$form_state) {
|
||||
if ($form_state['values']['confirm']) {
|
||||
$node = node_load($form_state['values']['nid']);
|
||||
node_delete($form_state['values']['nid']);
|
||||
cache_clear_all();
|
||||
watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
|
||||
drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));
|
||||
}
|
||||
@@ -502,7 +554,15 @@ function node_delete_confirm_submit($form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an overview table of older revisions of a node.
|
||||
* Generates an overview table of older revisions of a node.
|
||||
*
|
||||
* @param $node
|
||||
* A node object.
|
||||
*
|
||||
* @return array
|
||||
* An array as expected by drupal_render().
|
||||
*
|
||||
* @see node_menu()
|
||||
*/
|
||||
function node_revision_overview($node) {
|
||||
drupal_set_title(t('Revisions for %title', array('%title' => $node->title)), PASS_THROUGH);
|
||||
@@ -553,13 +613,26 @@ function node_revision_overview($node) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask for confirmation of the reversion to prevent against CSRF attacks.
|
||||
* Asks for confirmation of the reversion to prevent against CSRF attacks.
|
||||
*
|
||||
* @param int $node_revision
|
||||
* The node revision ID.
|
||||
*
|
||||
* @return array
|
||||
* An array as expected by drupal_render().
|
||||
*
|
||||
* @see node_menu()
|
||||
* @see node_revision_revert_confirm_submit()
|
||||
* @ingroup forms
|
||||
*/
|
||||
function node_revision_revert_confirm($form, $form_state, $node_revision) {
|
||||
$form['#node_revision'] = $node_revision;
|
||||
return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', '', t('Revert'), t('Cancel'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission handler for node_revision_revert_confirm().
|
||||
*/
|
||||
function node_revision_revert_confirm_submit($form, &$form_state) {
|
||||
$node_revision = $form['#node_revision'];
|
||||
$node_revision->revision = 1;
|
||||
@@ -572,11 +645,29 @@ function node_revision_revert_confirm_submit($form, &$form_state) {
|
||||
$form_state['redirect'] = 'node/' . $node_revision->nid . '/revisions';
|
||||
}
|
||||
|
||||
/**
|
||||
* Form constructor for the revision deletion confirmation form.
|
||||
*
|
||||
* This form prevents against CSRF attacks.
|
||||
*
|
||||
* @param $node_revision
|
||||
* The node revision ID.
|
||||
*
|
||||
* @return
|
||||
* An array as expected by drupal_render().
|
||||
*
|
||||
* @see node_menu()
|
||||
* @see node_revision_delete_confirm_submit()
|
||||
* @ingroup forms
|
||||
*/
|
||||
function node_revision_delete_confirm($form, $form_state, $node_revision) {
|
||||
$form['#node_revision'] = $node_revision;
|
||||
return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission handler for node_revision_delete_confirm().
|
||||
*/
|
||||
function node_revision_delete_confirm_submit($form, &$form_state) {
|
||||
$node_revision = $form['#node_revision'];
|
||||
node_revision_delete($node_revision->vid);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -136,10 +136,29 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
|
||||
case 'body':
|
||||
case 'summary':
|
||||
if ($items = field_get_items('node', $node, 'body', $language_code)) {
|
||||
$column = ($name == 'body') ? 'value' : 'summary';
|
||||
$instance = field_info_instance('node', 'body', $node->type);
|
||||
$field_langcode = field_language('node', $node, 'body', $language_code);
|
||||
$replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], $column) : $items[0][$column];
|
||||
// If the summary was requested and is not empty, use it.
|
||||
if ($name == 'summary' && !empty($items[0]['summary'])) {
|
||||
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'summary') : $items[0]['summary'];
|
||||
}
|
||||
// Attempt to provide a suitable version of the 'body' field.
|
||||
else {
|
||||
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'value') : $items[0]['value'];
|
||||
// A summary was requested.
|
||||
if ($name == 'summary') {
|
||||
if (isset($instance['display']['teaser']['settings']['trim_length'])) {
|
||||
$trim_length = $instance['display']['teaser']['settings']['trim_length'];
|
||||
}
|
||||
else {
|
||||
// Use default value.
|
||||
$trim_length = NULL;
|
||||
}
|
||||
// Generate an optionally trimmed summary of the body field.
|
||||
$output = text_summary($output, $instance['settings']['text_processing'] ? $items[0]['format'] : NULL, $trim_length);
|
||||
}
|
||||
}
|
||||
$replacements[$original] = $output;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@@ -4,3 +4,9 @@ package = Testing
|
||||
version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Dummy module implementing node access related hooks to test API interaction
|
||||
* A dummy module implementing node access related hooks for testing purposes.
|
||||
*
|
||||
* A dummy module implementing node access related hooks to test API interaction
|
||||
* with the Node module. This module restricts view permission to those with
|
||||
* a special 'node test view' permission.
|
||||
*/
|
||||
@@ -140,6 +142,8 @@ function node_access_test_page() {
|
||||
* database query is shown, and a list of the node IDs, for debugging purposes.
|
||||
* And if there is a query exception, the page says "Exception" and gives the
|
||||
* error.
|
||||
*
|
||||
* @see node_access_test_menu()
|
||||
*/
|
||||
function node_access_entity_test_page() {
|
||||
$output = '';
|
||||
@@ -207,7 +211,7 @@ function node_access_test_node_insert($node) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_nodeapi_update().
|
||||
* Implements hook_node_update().
|
||||
*/
|
||||
function node_access_test_node_update($node) {
|
||||
_node_access_test_node_write($node);
|
||||
|
@@ -4,3 +4,9 @@ package = Testing
|
||||
version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -2,8 +2,10 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Dummy module implementing node related hooks to test API interaction with
|
||||
* the Node module.
|
||||
* A dummy module for testing node related hooks.
|
||||
*
|
||||
* This is a dummy module that implements node related hooks to test API
|
||||
* interaction with the Node module.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -159,3 +161,21 @@ function node_test_entity_view_mode_alter(&$view_mode, $context) {
|
||||
$view_mode = $change_view_mode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_insert().
|
||||
*
|
||||
* This tests saving a node on node insert.
|
||||
*
|
||||
* @see NodeSaveTest::testNodeSaveOnInsert()
|
||||
*/
|
||||
function node_test_node_insert($node) {
|
||||
// Set the node title to the node ID and save.
|
||||
if ($node->title == 'new') {
|
||||
$node->title = 'Node '. $node->nid;
|
||||
// Remove the is_new flag, so that the node is updated and not inserted
|
||||
// again.
|
||||
unset($node->is_new);
|
||||
node_save($node);
|
||||
}
|
||||
}
|
||||
|
@@ -4,3 +4,9 @@ package = Testing
|
||||
version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.36"
|
||||
project = "drupal"
|
||||
datestamp = "1427943826"
|
||||
|
||||
|
@@ -2,8 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Dummy module implementing node related hooks to test API interaction with
|
||||
* the Node module.
|
||||
* A module implementing node related hooks to test API interaction.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user