update to 7.22

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy
2013-05-24 13:03:57 +02:00
parent d5097a4bc6
commit 5658794f17
265 changed files with 5551 additions and 8808 deletions

View File

@@ -2,7 +2,7 @@
/**
* @file
* Content type editing UI.
* Content type editing user interface.
*/
/**
@@ -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']);

View File

@@ -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');
@@ -525,8 +595,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 +615,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 +648,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,6 +682,16 @@ 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']));

View File

@@ -11,8 +11,8 @@
* 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
@@ -22,10 +22,10 @@
* 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.
* - 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 +56,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 +96,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 +135,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 +181,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
@@ -264,6 +262,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 +349,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 +372,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 +410,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 +526,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 +569,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 +648,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 +721,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 +753,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 +871,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 +884,22 @@ 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 string used to construct callbacks
* corresponding to this node type (for example, 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.
* - 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 +947,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 +987,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 +1000,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.
@@ -1258,25 +1255,24 @@ function hook_validate($node, $form, &$form_state) {
* 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 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.
* 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', ...
* @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
*/

View File

@@ -9,8 +9,8 @@ required = TRUE
configure = admin/structure/types
stylesheets[all][] = node.css
; Information added by drupal.org packaging script on 2013-03-07
version = "7.21"
; Information added by drupal.org packaging script on 2013-04-03
version = "7.22"
project = "drupal"
datestamp = "1362616996"
datestamp = "1365027012"

View File

@@ -914,6 +914,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 +922,7 @@ function node_update_7013() {
'not null' => FALSE,
'default' => NULL,
));
db_add_unique_key('node', 'vid', array('vid'));
}
/**

View File

@@ -141,6 +141,7 @@ function node_theme() {
),
'node_admin_overview' => array(
'variables' => array('name' => NULL, 'type' => NULL),
'file' => 'content_types.inc',
),
'node_recent_block' => array(
'variables' => array('nodes' => NULL),
@@ -200,8 +201,8 @@ function node_entity_info() {
),
);
// Search integration is provided by node.module, so search-related
// view modes for nodes are defined here and not in search.module.
// Search integration is provided by node.module, so search-related view modes
// for nodes are defined here and not in search.module.
if (module_exists('search')) {
$return['node']['view modes'] += array(
'search_index' => array(
@@ -244,6 +245,12 @@ function node_field_display_node_alter(&$display, $context) {
/**
* Entity URI callback.
*
* @param $node
* A node entity.
*
* @return array
* An array with 'path' as the key and the path to the node as its value.
*/
function node_uri($node) {
return array(
@@ -296,7 +303,7 @@ function node_title_list($result, $title = NULL) {
}
/**
* Update the 'last viewed' timestamp of the specified node for current user.
* Updates the 'last viewed' timestamp of the specified node for current user.
*
* @param $node
* A node object.
@@ -315,8 +322,14 @@ function node_tag_new($node) {
}
/**
* Retrieves the timestamp at which the current user last viewed the
* specified node.
* Retrieves the timestamp for the current user's last view of a specified node.
*
* @param $nid
* A node ID.
*
* @return
* If a node has been previously viewed by the user, the timestamp in seconds
* of when the last view occurred; otherwise, zero.
*/
function node_last_viewed($nid) {
global $user;
@@ -330,12 +343,13 @@ function node_last_viewed($nid) {
}
/**
* Decide on the type of marker to be displayed for a given node.
* Determines the type of marker to be displayed for a given node.
*
* @param $nid
* Node ID whose history supplies the "last viewed" timestamp.
* @param $timestamp
* Time which is compared against node's "last viewed" timestamp.
*
* @return
* One of the MARK constants.
*/
@@ -359,7 +373,7 @@ function node_mark($nid, $timestamp) {
}
/**
* Extract the type name.
* Extracts the type name.
*
* @param $node
* Either a string or object, containing the node type information.
@@ -461,6 +475,8 @@ function node_type_get_name($node) {
* node_type_save(), and obsolete ones are deleted via a call to
* node_type_delete(). See _node_types_build() for an explanation of the new
* and obsolete types.
*
* @see _node_types_build()
*/
function node_types_rebuild() {
_node_types_build(TRUE);
@@ -483,11 +499,34 @@ function node_type_load($name) {
/**
* Saves a node type to the database.
*
* @param $info
* The node type to save, as an object.
* @param object $info
* The node type to save; an object with the following properties:
* - type: A string giving the machine name of the node type.
* - name: A string giving the human-readable name of the node type.
* - base: A string that indicates the base string for hook functions. For
* example, 'node_content' is the value used by the UI when creating a new
* node type.
* - description: A string that describes the node type.
* - help: A string giving the help information shown to the user when
* creating a node of this type.
* - custom: TRUE or FALSE indicating whether this type is defined by a module
* (FALSE) or by a user (TRUE) via Add Content Type.
* - modified: TRUE or FALSE indicating whether this type has been modified by
* an administrator. Currently not used in any way.
* - locked: TRUE or FALSE indicating whether the administrator can change the
* machine name of this type.
* - disabled: TRUE or FALSE indicating whether this type has been disabled.
* - has_title: TRUE or FALSE indicating whether this type uses the node title
* field.
* - title_label: A string containing the label for the title.
* - module: A string giving the module defining this type of node.
* - orig_type: A string giving the original machine-readable name of this
* node type. This may be different from the current type name if the
* 'locked' key is FALSE.
*
* @return
* Status flag indicating outcome of the operation.
* @return int
* A status flag indicating the outcome of the operation, either SAVED_NEW or
* SAVED_UPDATED.
*/
function node_type_save($info) {
$existing_type = !empty($info->old_type) ? $info->old_type : $info->type;
@@ -540,7 +579,7 @@ function node_type_save($info) {
}
/**
* Add default body field to a node type.
* Adds default body field to a node type.
*
* @param $type
* A node type object.
@@ -655,6 +694,7 @@ function node_type_update_nodes($old_type, $type) {
*
* @param $rebuild
* TRUE to rebuild node types. Equivalent to calling node_types_rebuild().
*
* @return
* An object with two properties:
* - names: Associative array of the names of node types, keyed by the type.
@@ -761,8 +801,9 @@ function node_type_cache_reset() {
* which prevents users from changing the machine name of the type.
*
* @param $info
* An object or array containing values to override the defaults. See
* hook_node_info() for details on what the array elements mean.
* (optional) An object or array containing values to override the defaults.
* See hook_node_info() for details on what the array elements mean. Defaults
* to an empty array.
*
* @return
* A node type object, with missing values in $info set to their defaults.
@@ -845,12 +886,13 @@ function node_rdf_mapping() {
}
/**
* Determine whether a node hook exists.
* Determines whether a node hook exists.
*
* @param $node
* A node object or a string containing the node type.
* @param $hook
* A string containing the name of the hook.
*
* @return
* TRUE if the $hook exists in the node type of $node.
*/
@@ -860,7 +902,7 @@ function node_hook($node, $hook) {
}
/**
* Invoke a node hook.
* Invokes a node hook.
*
* @param $node
* A node object or a string containing the node type.
@@ -868,6 +910,7 @@ function node_hook($node, $hook) {
* A string containing the name of the hook.
* @param $a2, $a3, $a4
* Arguments to pass on to the hook, after the $node argument.
*
* @return
* The returned value of the invoked hook.
*/
@@ -880,11 +923,11 @@ function node_invoke($node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
}
/**
* Load node entities from the database.
* Loads node entities from the database.
*
* This function should be used whenever you need to load more than one node
* from the database. Nodes are loaded into memory and will not require
* database access if loaded again during the same page request.
* from the database. Nodes are loaded into memory and will not require database
* access if loaded again during the same page request.
*
* @see entity_load()
* @see EntityFieldQuery
@@ -910,7 +953,7 @@ function node_load_multiple($nids = array(), $conditions = array(), $reset = FAL
}
/**
* Load a node object from the database.
* Loads a node object from the database.
*
* @param $nid
* The node ID.
@@ -934,6 +977,9 @@ function node_load($nid = NULL, $vid = NULL, $reset = FALSE) {
*
* Fills in a few default values, and then invokes hook_prepare() on the node
* type module, and hook_node_prepare() on all modules.
*
* @param $node
* A node object.
*/
function node_object_prepare($node) {
// Set up default values, if required.
@@ -963,11 +1009,11 @@ function node_object_prepare($node) {
}
/**
* Perform validation checks on the given node.
* Implements hook_validate().
*
* Performs validation checks on the given node.
*/
function node_validate($node, $form, &$form_state) {
$type = node_type_get_type($node);
if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
form_set_error('changed', t('The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.'));
}
@@ -1000,7 +1046,13 @@ function node_validate($node, $form, &$form_state) {
}
/**
* Prepare node for saving by populating author and creation date.
* Prepares node for saving by populating author and creation date.
*
* @param $node
* A node object.
*
* @return
* An updated node object.
*/
function node_submit($node) {
// A user might assign the node author by entering a user name in the node
@@ -1021,7 +1073,7 @@ function node_submit($node) {
}
/**
* Save changes to a node or add a new node.
* Saves changes to a node or adds a new node.
*
* @param $node
* The $node object to be saved. If $node->nid is
@@ -1159,6 +1211,13 @@ function node_save($node) {
* Helper function to save a revision with the uid of the current user.
*
* The resulting revision ID is available afterward in $node->vid.
*
* @param $node
* A node object.
* @param $uid
* The current user's UID.
* @param $update
* (optional) An array of primary keys' field names to update.
*/
function _node_save_revision($node, $uid, $update = NULL) {
$temp_uid = $node->uid;
@@ -1174,7 +1233,7 @@ function _node_save_revision($node, $uid, $update = NULL) {
}
/**
* Delete a node.
* Deletes a node.
*
* @param $nid
* A node ID.
@@ -1184,7 +1243,7 @@ function node_delete($nid) {
}
/**
* Delete multiple nodes.
* Deletes multiple nodes.
*
* @param $nids
* An array of node IDs.
@@ -1237,7 +1296,7 @@ function node_delete_multiple($nids) {
}
/**
* Delete a node revision.
* Deletes a node revision.
*
* @param $revision_id
* The revision ID to delete.
@@ -1262,7 +1321,7 @@ function node_revision_delete($revision_id) {
}
/**
* Generate an array for rendering the given node.
* Generates an array for rendering the given node.
*
* @param $node
* A node object.
@@ -1367,8 +1426,8 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) {
entity_prepare_view('node', array($node->nid => $node), $langcode);
$node->content += field_attach_view('node', $node, $view_mode, $langcode);
// Always display a read more link on teasers because we have no way
// to know when a teaser view is different than a full view.
// Always display a read more link on teasers because we have no way to know
// when a teaser view is different than a full view.
$links = array();
$node->content['links'] = array(
'#theme' => 'links__node',
@@ -1400,12 +1459,13 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) {
}
/**
* Generate an array which displays a node detail page.
* Generates an array which displays a node detail page.
*
* @param $node
* A node object.
* @param $message
* A flag which sets a page title relevant to the revision being viewed.
*
* @return
* A $page element suitable for use by drupal_render().
*/
@@ -1428,6 +1488,9 @@ function node_show($node, $message = FALSE) {
*
* @param $node
* A node object.
*
* @return
* The ID of the node if this is a full page view, otherwise FALSE.
*/
function node_is_page($node) {
$page_node = menu_get_object();
@@ -1435,7 +1498,7 @@ function node_is_page($node) {
}
/**
* Process variables for node.tpl.php
* Processes variables for node.tpl.php
*
* Most themes utilize their own copy of node.tpl.php. The default is located
* inside "modules/node/node.tpl.php". Look in there for the full list of
@@ -1557,7 +1620,7 @@ function node_permission() {
}
/**
* Gather the rankings from the the hook_ranking implementations.
* Gathers the rankings from the the hook_ranking() implementations.
*
* @param $query
* A query object that has been extended with the Search DB Extender.
@@ -1804,6 +1867,7 @@ function node_user_delete($account) {
* An associative array containing:
* - form: A render element representing the form.
*
* @see node_search_admin()
* @ingroup themeable
*/
function theme_node_search_admin($variables) {
@@ -1872,11 +1936,11 @@ function _node_revision_access($node, $op = 'view', $account = NULL) {
$node_current_revision = node_load($node->nid);
$is_current_revision = $node_current_revision->vid == $node->vid;
// There should be at least two revisions. If the vid of the given node
// and the vid of the current revision differ, then we already have two
// There should be at least two revisions. If the vid of the given node and
// the vid of the current revision differ, then we already have two
// different revisions so there is no need for a separate database check.
// Also, if you try to revert to or delete the current revision, that's
// not good.
// Also, if you try to revert to or delete the current revision, that's not
// good.
if ($is_current_revision && (db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() == 1 || $op == 'update' || $op == 'delete')) {
$access[$cid] = FALSE;
}
@@ -1884,8 +1948,8 @@ function _node_revision_access($node, $op = 'view', $account = NULL) {
$access[$cid] = TRUE;
}
else {
// First check the access to the current revision and finally, if the
// node passed in is not the current revision then access to that, too.
// First check the access to the current revision and finally, if the node
// passed in is not the current revision then access to that, too.
$access[$cid] = node_access($op, $node_current_revision, $account) && ($is_current_revision || node_access($op, $node, $account));
}
}
@@ -1893,6 +1957,14 @@ function _node_revision_access($node, $op = 'view', $account = NULL) {
return $access[$cid];
}
/**
* Access callback: Checks whether the user has permission to add a node.
*
* @return
* TRUE if the user has add permission, otherwise FALSE.
*
* @see node_menu()
*/
function _node_add_access() {
$types = node_type_get_types();
foreach ($types as $type) {
@@ -2110,14 +2182,30 @@ function node_menu_local_tasks_alter(&$data, $router_item, $root_path) {
}
/**
* Title callback for a node type.
* Title callback: Returns the unsanitized title of the node type edit form.
*
* @param $type
* The node type object.
*
* @return string
* An unsanitized string that is the title of the node type edit form.
*
* @see node_menu()
*/
function node_type_page_title($type) {
return $type->name;
}
/**
* Title callback.
* Title callback: Returns the title of the node.
*
* @param $node
* The node object.
*
* @return
* An unsanitized string that is the title of the node.
*
* @see node_menu()
*/
function node_page_title($node) {
return $node->title;
@@ -2137,7 +2225,13 @@ function node_last_changed($nid) {
}
/**
* Return a list of all the existing revision numbers.
* Returns a list of all the existing revision numbers.
*
* @param Drupal\node\Node $node
* The node entity.
*
* @return
* An associative array keyed by node revision number.
*/
function node_revision_list($node) {
$revisions = array();
@@ -2223,16 +2317,16 @@ function node_block_save($delta = '', $edit = array()) {
* (optional) The maximum number of nodes to find. Defaults to 10.
*
* @return
* An array of partial node objects or an empty array if there are no recent
* nodes visible to the current user.
* An array of node entities or an empty array if there are no recent nodes
* visible to the current user.
*/
function node_get_recent($number = 10) {
$query = db_select('node', 'n');
if (!user_access('bypass node access')) {
// If the user is able to view their own unpublished nodes, allow them
// to see these in addition to published nodes. Check that they actually
// have some unpublished nodes to view before adding the condition.
// If the user is able to view their own unpublished nodes, allow them to
// see these in addition to published nodes. Check that they actually have
// some unpublished nodes to view before adding the condition.
if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT nid FROM {node} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => NODE_NOT_PUBLISHED))->fetchCol()) {
$query->condition(db_or()
->condition('n.status', NODE_PUBLISHED)
@@ -2362,7 +2456,7 @@ function node_form_block_admin_configure_alter(&$form, &$form_state) {
}
/**
* Form submit handler for block configuration form.
* Form submission handler for node_form_block_admin_configure_alter().
*
* @see node_form_block_admin_configure_alter()
*/
@@ -2394,7 +2488,7 @@ function node_form_block_custom_block_delete_alter(&$form, &$form_state) {
}
/**
* Form submit handler for custom block delete form.
* Form submission handler for node_form_block_custom_block_delete_alter().
*
* @see node_form_block_custom_block_delete_alter()
*/
@@ -2419,8 +2513,8 @@ function node_modules_uninstalled($modules) {
/**
* Implements hook_block_list_alter().
*
* Check the content type specific visibilty settings.
* Remove the block if the visibility conditions are not met.
* Check the content type specific visibilty settings. Remove the block if the
* visibility conditions are not met.
*/
function node_block_list_alter(&$blocks) {
global $theme_key;
@@ -2485,7 +2579,8 @@ function node_block_list_alter(&$blocks) {
* @param $channel
* An associative array containing title, link, description and other keys,
* to be parsed by format_rss_channel() and format_xml_elements().
* A list of channel elements can be found at the @link http://cyber.law.harvard.edu/rss/rss.html RSS 2.0 Specification. @endlink
* A list of channel elements can be found at the
* @link http://cyber.law.harvard.edu/rss/rss.html RSS 2.0 Specification. @endlink
* The link should be an absolute URL.
*/
function node_feed($nids = FALSE, $channel = array()) {
@@ -2505,7 +2600,6 @@ function node_feed($nids = FALSE, $channel = array()) {
$item_length = variable_get('feed_item_length', 'fulltext');
$namespaces = array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/');
$teaser = ($item_length == 'teaser');
// Load all nodes to be rendered.
$nodes = node_load_multiple($nids);
@@ -2559,7 +2653,7 @@ function node_feed($nids = FALSE, $channel = array()) {
}
/**
* Construct a drupal_render() style array from an array of loaded nodes.
* Constructs a drupal_render() style array from an array of loaded nodes.
*
* @param $nodes
* An array of nodes as returned by node_load_multiple().
@@ -2568,8 +2662,8 @@ function node_feed($nids = FALSE, $channel = array()) {
* @param $weight
* An integer representing the weight of the first node in the list.
* @param $langcode
* (optional) A language code to use for rendering. Defaults to the global
* content language of the current request.
* (optional) A language code to use for rendering. Defaults to NULL which is
* the global content language of the current request.
*
* @return
* An array in the format expected by drupal_render().
@@ -2588,7 +2682,12 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcod
}
/**
* Menu callback; Generate a listing of promoted nodes.
* Menu callback: Generates a listing of promoted nodes.
*
* @return array
* An array in the format expected by drupal_render().
*
* @see node_menu()
*/
function node_page_default() {
$select = db_select('node', 'n')
@@ -2638,7 +2737,15 @@ function node_page_default() {
}
/**
* Menu callback; view a single node.
* Menu callback: Displays a single node.
*
* @param $node
* The node object.
*
* @return
* A page array suitable for use by drupal_render().
*
* @see node_menu()
*/
function node_page_view($node) {
// If there is a menu link to this node, the link becomes the last part
@@ -2667,7 +2774,7 @@ function node_update_index() {
}
/**
* Index a single node.
* Indexes a single node.
*
* @param $node
* The node to index.
@@ -2771,7 +2878,7 @@ function node_form_search_form_alter(&$form, $form_state) {
}
/**
* Form API callback for the search form. Registered in node_form_alter().
* Form validation handler for node_form_alter().
*/
function node_search_validate($form, &$form_state) {
// Initialize using any existing basic search keywords.
@@ -2819,8 +2926,8 @@ function node_search_validate($form, &$form_state) {
* @{
* The node access system determines who can do what to which nodes.
*
* In determining access rights for a node, node_access() first checks
* whether the user has the "bypass node access" permission. Such users have
* In determining access rights for a node, node_access() first checks whether
* the user has the "bypass node access" permission. Such users have
* unrestricted access to all nodes. user 1 will always pass this check.
*
* Next, all implementations of hook_node_access() will be called. Each
@@ -2858,8 +2965,7 @@ function node_search_validate($form, &$form_state) {
*/
/**
* Determine whether the current user may perform the given operation on the
* specified node.
* Determines whether the current user may perform the operation on the node.
*
* @param $op
* The operation to be performed on the node. Possible values are:
@@ -2873,6 +2979,7 @@ function node_search_validate($form, &$form_state) {
* @param $account
* Optional, a user object representing the user for whom the operation is to
* be performed. Determines access for a user other than the current user.
*
* @return
* TRUE if the operation may be performed, FALSE otherwise.
*/
@@ -3005,6 +3112,7 @@ function node_node_access($node, $op, $account) {
*
* @param $type
* The machine-readable name of the node type.
*
* @return array
* An array of permission names and descriptions.
*/
@@ -3038,11 +3146,11 @@ function node_list_permissions($type) {
*
* By default, this will include all node types in the system. To exclude a
* specific node from getting permissions defined for it, set the
* node_permissions_$type variable to 0. Core does not provide an interface
* for doing so, however, contrib modules may exclude their own nodes in
* node_permissions_$type variable to 0. Core does not provide an interface for
* doing so. However, contrib modules may exclude their own nodes in
* hook_install(). Alternatively, contrib modules may configure all node types
* at once, or decide to apply some other hook_node_access() implementation
* to some or all node types.
* at once, or decide to apply some other hook_node_access() implementation to
* some or all node types.
*
* @return
* An array of node types managed by this module.
@@ -3061,21 +3169,22 @@ function node_permissions_get_configured_types() {
}
/**
* Fetch an array of permission IDs granted to the given user ID.
* Fetches an array of permission IDs granted to the given user ID.
*
* The implementation here provides only the universal "all" grant. A node
* access module should implement hook_node_grants() to provide a grant
* list for the user.
* access module should implement hook_node_grants() to provide a grant list for
* the user.
*
* After the default grants have been loaded, we allow modules to alter
* the grants array by reference. This hook allows for complex business
* logic to be applied when integrating multiple node access modules.
* After the default grants have been loaded, we allow modules to alter the
* grants array by reference. This hook allows for complex business logic to be
* applied when integrating multiple node access modules.
*
* @param $op
* The operation that the user is trying to perform.
* @param $account
* The user object for the user performing the operation. If omitted, the
* current user is used.
*
* @return
* An associative array in which the keys are realms, and the values are
* arrays of grants for those realms.
@@ -3163,11 +3272,10 @@ function node_access_view_all_nodes($account = NULL) {
/**
* Implements hook_query_TAG_alter().
*
* This is the hook_query_alter() for queries tagged with 'node_access'.
* It adds node access checks for the user account given by the 'account'
* meta-data (or global $user if not provided), for an operation given by
* the 'op' meta-data (or 'view' if not provided; other possible values are
* 'update' and 'delete').
* This is the hook_query_alter() for queries tagged with 'node_access'. It adds
* node access checks for the user account given by the 'account' meta-data (or
* global $user if not provided), for an operation given by the 'op' meta-data
* (or 'view' if not provided; other possible values are 'update' and 'delete').
*/
function node_query_node_access_alter(QueryAlterableInterface $query) {
_node_query_node_access_alter($query, 'node');
@@ -3206,8 +3314,8 @@ function _node_query_node_access_alter($query, $type) {
}
// If $account can bypass node access, or there are no node access modules,
// or the operation is 'view' and the $acount has a global view grant (i.e.,
// a view grant for node ID 0), we don't need to alter the query.
// or the operation is 'view' and the $account has a global view grant
// (such as a view grant for node ID 0), we don't need to alter the query.
if (user_access('bypass node access', $account)) {
return;
}
@@ -3394,15 +3502,14 @@ function node_access_acquire_grants($node, $delete = TRUE) {
*
* If a realm is provided, it will only delete grants from that realm, but it
* will always delete a grant from the 'all' realm. Modules that utilize
* node_access can use this function when doing mass updates due to widespread
* node_access() can use this function when doing mass updates due to widespread
* permission changes.
*
* Note: Don't call this function directly from a contributed module. Call
* node_access_acquire_grants() instead.
*
* @param $node
* The $node being written to. All that is necessary is that it contains a
* nid.
* The node whose grants are being written.
* @param $grants
* A list of grants to write. Each grant is an array that must contain the
* following keys: realm, gid, grant_view, grant_update, grant_delete.
@@ -3410,10 +3517,14 @@ function node_access_acquire_grants($node, $delete = TRUE) {
* is a module-defined id to define grant privileges. each grant_* field
* is a boolean value.
* @param $realm
* If provided, only read/write grants for that realm.
* (optional) If provided, read/write grants for that realm only. Defaults to
* NULL.
* @param $delete
* If false, do not delete records. This is only for optimization purposes,
* and assumes the caller has already performed a mass delete of some form.
* (optional) If false, does not delete records. This is only for optimization
* purposes, and assumes the caller has already performed a mass delete of
* some form. Defaults to TRUE.
*
* @see node_access_acquire_grants()
*/
function node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE) {
if ($delete) {
@@ -3442,21 +3553,23 @@ function node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE)
}
/**
* Flag / unflag the node access grants for rebuilding, or read the current
* value of the flag.
* Flags or unflags the node access grants for rebuilding.
*
* If the argument isn't specified, the current value of the flag is returned.
* When the flag is set, a message is displayed to users with 'access
* administration pages' permission, pointing to the 'rebuild' confirm form.
* This can be used as an alternative to direct node_access_rebuild calls,
* allowing administrators to decide when they want to perform the actual
* (possibly time consuming) rebuild.
* When unsure the current user is an administrator, node_access_rebuild
* should be used instead.
* (possibly time consuming) rebuild. When unsure if the current user is an
* administrator, node_access_rebuild() should be used instead.
*
* @param $rebuild
* (Optional) The boolean value to be written.
* @return
* (If no value was provided for $rebuild) The current value of the flag.
*
* @return
* The current value of the flag if no value was provided for $rebuild.
*
* @see node_access_rebuild()
*/
function node_access_needs_rebuild($rebuild = NULL) {
if (!isset($rebuild)) {
@@ -3471,15 +3584,15 @@ function node_access_needs_rebuild($rebuild = NULL) {
}
/**
* Rebuild the node access database. This is occasionally needed by modules
* that make system-wide changes to access levels.
* Rebuilds the node access database.
*
* When the rebuild is required by an admin-triggered action (e.g module
* settings form), calling node_access_needs_rebuild(TRUE) instead of
* This is occasionally needed by modules that make system-wide changes to
* access levels. When the rebuild is required by an admin-triggered action (e.g
* module settings form), calling node_access_needs_rebuild(TRUE) instead of
* node_access_rebuild() lets the user perform his changes and actually
* rebuild only once he is done.
*
* Note : As of Drupal 6, node access modules are not required to (and actually
* Note: As of Drupal 6, node access modules are not required to (and actually
* should not) call node_access_rebuild() in hook_enable/disable anymore.
*
* @see node_access_needs_rebuild()
@@ -3543,11 +3656,14 @@ function node_access_rebuild($batch_mode = FALSE) {
}
/**
* Batch operation for node_access_rebuild_batch.
* Performs batch operation for node_access_rebuild().
*
* This is a multistep operation : we go through all nodes by packs of 20.
* The batch processing engine interrupts processing and sends progress
* feedback after 1 second execution time.
* This is a multistep operation: we go through all nodes by packs of 20. The
* batch processing engine interrupts processing and sends progress feedback
* after 1 second execution time.
*
* @param array $context
* An array of contextual key/value information for rebuild batch process.
*/
function _node_access_rebuild_batch_operation(&$context) {
if (empty($context['sandbox'])) {
@@ -3578,7 +3694,14 @@ function _node_access_rebuild_batch_operation(&$context) {
}
/**
* Post-processing for node_access_rebuild_batch.
* Performs post-processing for node_access_rebuild().
*
* @param bool $success
* A boolean indicating whether the re-build process has completed.
* @param array $results
* An array of results information.
* @param array $operations
* An array of function calls (not used in this function).
*/
function _node_access_rebuild_batch_finished($success, $results, $operations) {
if ($success) {
@@ -3595,7 +3718,6 @@ function _node_access_rebuild_batch_finished($success, $results, $operations) {
* @} End of "defgroup node_access".
*/
/**
* @defgroup node_content Hook implementations for user-created content types
* @{
@@ -3631,6 +3753,7 @@ function node_content_form($node, $form_state) {
/**
* Implements hook_forms().
*
* All node forms share the same form handler.
*/
function node_forms() {
@@ -3715,6 +3838,12 @@ function node_action_info() {
/**
* Sets the status of a node to 1 (published).
*
* @param $node
* A node object.
* @param $context
* (optional) Array of additional information about what triggered the action.
* Not used for this action.
*
* @ingroup actions
*/
function node_publish_action($node, $context = array()) {
@@ -3725,6 +3854,12 @@ function node_publish_action($node, $context = array()) {
/**
* Sets the status of a node to 0 (unpublished).
*
* @param $node
* A node object.
* @param $context
* (optional) Array of additional information about what triggered the action.
* Not used for this action.
*
* @ingroup actions
*/
function node_unpublish_action($node, $context = array()) {
@@ -3735,6 +3870,12 @@ function node_unpublish_action($node, $context = array()) {
/**
* Sets the sticky-at-top-of-list property of a node to 1.
*
* @param $node
* A node object.
* @param $context
* (optional) Array of additional information about what triggered the action.
* Not used for this action.
*
* @ingroup actions
*/
function node_make_sticky_action($node, $context = array()) {
@@ -3745,6 +3886,12 @@ function node_make_sticky_action($node, $context = array()) {
/**
* Sets the sticky-at-top-of-list property of a node to 0.
*
* @param $node
* A node object.
* @param $context
* (optional) Array of additional information about what triggered the action.
* Not used for this action.
*
* @ingroup actions
*/
function node_make_unsticky_action($node, $context = array()) {
@@ -3755,6 +3902,12 @@ function node_make_unsticky_action($node, $context = array()) {
/**
* Sets the promote property of a node to 1.
*
* @param $node
* A node object.
* @param $context
* (optional) Array of additional information about what triggered the action.
* Not used for this action.
*
* @ingroup actions
*/
function node_promote_action($node, $context = array()) {
@@ -3765,6 +3918,12 @@ function node_promote_action($node, $context = array()) {
/**
* Sets the promote property of a node to 0.
*
* @param $node
* A node object.
* @param $context
* (optional) Array of additional information about what triggered the action.
* Not used for this action.
*
* @ingroup actions
*/
function node_unpromote_action($node, $context = array()) {
@@ -3775,6 +3934,9 @@ function node_unpromote_action($node, $context = array()) {
/**
* Saves a node.
*
* @param $node
* The node to be saved.
*
* @ingroup actions
*/
function node_save_action($node) {
@@ -3791,6 +3953,9 @@ function node_save_action($node) {
* Array with the following elements:
* - 'owner_uid': User ID to assign to the node.
*
* @see node_assign_owner_action_form()
* @see node_assign_owner_action_validate()
* @see node_assign_owner_action_submit()
* @ingroup actions
*/
function node_assign_owner_action($node, $context) {
@@ -3801,6 +3966,16 @@ function node_assign_owner_action($node, $context) {
/**
* Generates the settings form for node_assign_owner_action().
*
* @param $context
* Array of additional information about what triggered the action. Includes
* the following elements:
* - 'owner_uid': User ID to assign to the node.
*
* @see node_assign_owner_action_submit()
* @see node_assign_owner_action_validate()
*
* @ingroup forms
*/
function node_assign_owner_action_form($context) {
$description = t('The username of the user to which you would like to assign ownership.');
@@ -3841,6 +4016,8 @@ function node_assign_owner_action_form($context) {
/**
* Validates settings form for node_assign_owner_action().
*
* @see node_assign_owner_action_submit()
*/
function node_assign_owner_action_validate($form, $form_state) {
$exists = (bool) db_query_range('SELECT 1 FROM {users} WHERE name = :name', 0, 1, array(':name' => $form_state['values']['owner_name']))->fetchField();
@@ -3851,6 +4028,8 @@ function node_assign_owner_action_validate($form, $form_state) {
/**
* Saves settings form for node_assign_owner_action().
*
* @see node_assign_owner_action_validate()
*/
function node_assign_owner_action_submit($form, $form_state) {
// Username can change, so we need to store the ID, not the username.
@@ -3860,6 +4039,14 @@ function node_assign_owner_action_submit($form, $form_state) {
/**
* Generates settings form for node_unpublish_by_keyword_action().
*
* @param array $context
* Array of additional information about what triggered this action.
*
* @return array
* A form array.
*
* @see node_unpublish_by_keyword_action_submit()
*/
function node_unpublish_by_keyword_action_form($context) {
$form['keywords'] = array(

View File

@@ -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,7 +360,15 @@ 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)) {
@@ -377,6 +414,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 +445,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 +470,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 +516,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,7 +534,9 @@ 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']) {
@@ -502,7 +550,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 +609,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 +641,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);

View File

@@ -149,6 +149,9 @@ class NodeLoadHooksTestCase extends DrupalWebTestCase {
}
}
/**
* Tests the node revision functionality.
*/
class NodeRevisionsTestCase extends DrupalWebTestCase {
protected $nodes;
protected $logs;
@@ -198,7 +201,7 @@ class NodeRevisionsTestCase extends DrupalWebTestCase {
}
/**
* Check node revision related operations.
* Checks node revision related operations.
*/
function testRevisions() {
$nodes = $this->nodes;
@@ -282,6 +285,9 @@ class NodeRevisionsTestCase extends DrupalWebTestCase {
}
}
/**
* Tests the node edit functionality.
*/
class PageEditTestCase extends DrupalWebTestCase {
protected $web_user;
protected $admin_user;
@@ -302,7 +308,7 @@ class PageEditTestCase extends DrupalWebTestCase {
}
/**
* Check node edit functionality.
* Checks node edit functionality.
*/
function testPageEdit() {
$this->drupalLogin($this->web_user);
@@ -369,7 +375,7 @@ class PageEditTestCase extends DrupalWebTestCase {
}
/**
* Check changing node authored by fields.
* Tests changing a node's "authored by" field.
*/
function testPageAuthoredBy() {
$this->drupalLogin($this->admin_user);
@@ -414,6 +420,9 @@ class PageEditTestCase extends DrupalWebTestCase {
}
}
/**
* Tests the node entity preview functionality.
*/
class PagePreviewTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -431,7 +440,7 @@ class PagePreviewTestCase extends DrupalWebTestCase {
}
/**
* Check the node preview functionality.
* Checks the node preview functionality.
*/
function testPagePreview() {
$langcode = LANGUAGE_NONE;
@@ -455,7 +464,7 @@ class PagePreviewTestCase extends DrupalWebTestCase {
}
/**
* Check the node preview functionality, when using revisions.
* Checks the node preview functionality, when using revisions.
*/
function testPagePreviewWithRevisions() {
$langcode = LANGUAGE_NONE;
@@ -485,6 +494,9 @@ class PagePreviewTestCase extends DrupalWebTestCase {
}
}
/**
* Tests creating and saving a node.
*/
class NodeCreationTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -503,7 +515,7 @@ class NodeCreationTestCase extends DrupalWebTestCase {
}
/**
* Create a "Basic page" node and verify its consistency in the database.
* Creates a "Basic page" node and verifies its consistency in the database.
*/
function testNodeCreation() {
// Create a node.
@@ -522,7 +534,7 @@ class NodeCreationTestCase extends DrupalWebTestCase {
}
/**
* Create a page node and verify that a transaction rolls back the failed creation
* Verifies that a transaction rolls back the failed creation.
*/
function testFailedPageCreation() {
// Create a node.
@@ -561,8 +573,30 @@ class NodeCreationTestCase extends DrupalWebTestCase {
$records = db_query("SELECT wid FROM {watchdog} WHERE variables LIKE '%Test exception for rollback.%'")->fetchAll();
$this->assertTrue(count($records) > 0, t('Rollback explanatory error logged to watchdog.'));
}
/**
* Create an unpublished node and confirm correct redirect behavior.
*/
function testUnpublishedNodeCreation() {
// Set "Basic page" content type to be unpublished by default.
variable_set('node_options_page', array());
// Set the front page to the default "node" page.
variable_set('site_frontpage', 'node');
// Create a node.
$edit = array();
$edit["title"] = $this->randomName(8);
$edit["body[" . LANGUAGE_NONE . "][0][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the user was redirected to the home page.
$this->assertText(t('Welcome to Drupal'), t('The user is redirected to the home page.'));
}
}
/**
* Tests the functionality of node entity edit permissions.
*/
class PageViewTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -573,7 +607,7 @@ class PageViewTestCase extends DrupalWebTestCase {
}
/**
* Creates a node and then an anonymous and unpermissioned user attempt to edit the node.
* Tests an anonymous and unpermissioned user attempting to edit the node.
*/
function testPageView() {
// Create a node to view.
@@ -602,6 +636,9 @@ class PageViewTestCase extends DrupalWebTestCase {
}
}
/**
* Tests the summary length functionality.
*/
class SummaryLengthTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -612,7 +649,7 @@ class SummaryLengthTestCase extends DrupalWebTestCase {
}
/**
* Creates a node and then an anonymous and unpermissioned user attempt to edit the node.
* Tests the node summary length functionality.
*/
function testSummaryLength() {
// Create a node to view.
@@ -644,6 +681,9 @@ class SummaryLengthTestCase extends DrupalWebTestCase {
}
}
/**
* Tests XSS functionality with a node entity.
*/
class NodeTitleXSSTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -653,6 +693,9 @@ class NodeTitleXSSTestCase extends DrupalWebTestCase {
);
}
/**
* Tests XSS functionality with a node entity.
*/
function testNodeTitleXSS() {
// Prepare a user to do the stuff.
$web_user = $this->drupalCreateUser(array('create page content', 'edit any page content'));
@@ -678,6 +721,9 @@ class NodeTitleXSSTestCase extends DrupalWebTestCase {
}
}
/**
* Tests the availability of the syndicate block.
*/
class NodeBlockTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -709,7 +755,7 @@ class NodeBlockTestCase extends DrupalWebTestCase {
}
/**
* Check that the post information displays when enabled for a content type.
* Checks that the post information displays when enabled for a content type.
*/
class NodePostSettingsTestCase extends DrupalWebTestCase {
public static function getInfo() {
@@ -728,7 +774,7 @@ class NodePostSettingsTestCase extends DrupalWebTestCase {
}
/**
* Set "Basic page" content type to display post information and confirm its presence on a new node.
* Confirms "Basic page" content type and post information is on a new node.
*/
function testPagePostInfo() {
@@ -751,7 +797,7 @@ class NodePostSettingsTestCase extends DrupalWebTestCase {
}
/**
* Set "Basic page" content type to not display post information and confirm its absence on a new node.
* Confirms absence of post information on a new node.
*/
function testPageNotPostInfo() {
@@ -774,7 +820,7 @@ class NodePostSettingsTestCase extends DrupalWebTestCase {
}
/**
* Ensure that data added to nodes by other modules appears in RSS feeds.
* Ensures that data added to nodes by other modules appears in RSS feeds.
*
* Create a node, enable the node_test module to ensure that extra data is
* added to the node->content array, then verify that the data appears on the
@@ -801,8 +847,7 @@ class NodeRSSContentTestCase extends DrupalWebTestCase {
}
/**
* Create a new node and ensure that it includes the custom data when added
* to an RSS feed.
* Ensures that a new node includes the custom data when added to an RSS feed.
*/
function testNodeRSSContent() {
// Create a node.
@@ -841,9 +886,11 @@ class NodeRSSContentTestCase extends DrupalWebTestCase {
}
/**
* Test case to verify basic node_access functionality.
* Tests basic node_access functionality.
*
* Note that hook_node_access_records() is covered in another test class.
*
* @todo Cover hook_node_access in a separate test class.
* hook_node_access_records is covered in another test class.
*/
class NodeAccessTestCase extends DrupalWebTestCase {
public static function getInfo() {
@@ -855,7 +902,7 @@ class NodeAccessTestCase extends DrupalWebTestCase {
}
/**
* Asserts node_access correctly grants or denies access.
* Asserts node_access() correctly grants or denies access.
*/
function assertNodeAccess($ops, $node, $account) {
foreach ($ops as $op => $result) {
@@ -910,7 +957,7 @@ class NodeAccessTestCase extends DrupalWebTestCase {
}
/**
* Test case to verify hook_node_access_records functionality.
* Tests hook_node_access_records() functionality.
*/
class NodeAccessRecordsTestCase extends DrupalWebTestCase {
public static function getInfo() {
@@ -929,7 +976,7 @@ class NodeAccessRecordsTestCase extends DrupalWebTestCase {
}
/**
* Create a node and test the creation of node access rules.
* Creates a node and tests the creation of node access rules.
*/
function testNodeAccessRecords() {
// Create an article node.
@@ -1005,9 +1052,6 @@ class NodeAccessBaseTableTestCase extends DrupalWebTestCase {
);
}
/**
* Enable modules and create user with specific permissions.
*/
public function setUp() {
parent::setUp('node_access_test');
node_access_rebuild();
@@ -1015,7 +1059,7 @@ class NodeAccessBaseTableTestCase extends DrupalWebTestCase {
}
/**
* Test the "private" node access.
* Tests the "private" node access functionality.
*
* - Create 2 users with "access content" and "create article" permissions.
* - Each user creates one private and one not private article.
@@ -1152,7 +1196,7 @@ class NodeAccessBaseTableTestCase extends DrupalWebTestCase {
}
/**
* Test case to check node save related functionality, including import-save
* Tests node save related functionality, including import-save.
*/
class NodeSaveTestCase extends DrupalWebTestCase {
@@ -1173,7 +1217,8 @@ class NodeSaveTestCase extends DrupalWebTestCase {
}
/**
* Import test, to check if custom node ids are saved properly.
* Checks whether custom node IDs are saved properly during an import operation.
*
* Workflow:
* - first create a piece of content
* - save the content
@@ -1207,8 +1252,7 @@ class NodeSaveTestCase extends DrupalWebTestCase {
}
/**
* Check that the "created" and "changed" timestamps are set correctly when
* saving a new node or updating an existing node.
* Verifies accuracy of the "created" and "changed" timestamp functionality.
*/
function testTimestamps() {
// Use the default timestamps.
@@ -1307,7 +1351,7 @@ class NodeTypeTestCase extends DrupalWebTestCase {
}
/**
* Ensure that node type functions (node_type_get_*) work correctly.
* Ensures that node type functions (node_type_get_*) work correctly.
*
* Load available node types and validate the returned data.
*/
@@ -1326,7 +1370,7 @@ class NodeTypeTestCase extends DrupalWebTestCase {
}
/**
* Test creating a content type programmatically and via a form.
* Tests creating a content type programmatically and via a form.
*/
function testNodeTypeCreation() {
// Create a content type programmaticaly.
@@ -1356,7 +1400,7 @@ class NodeTypeTestCase extends DrupalWebTestCase {
}
/**
* Test editing a node type using the UI.
* Tests editing a node type using the UI.
*/
function testNodeTypeEditing() {
$web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types'));
@@ -1409,7 +1453,7 @@ class NodeTypeTestCase extends DrupalWebTestCase {
}
/**
* Test that node_types_rebuild() correctly handles the 'disabled' flag.
* Tests that node_types_rebuild() correctly handles the 'disabled' flag.
*/
function testNodeTypeStatus() {
// Enable all core node modules, and all types should be active.
@@ -1470,7 +1514,7 @@ class NodeTypePersistenceTestCase extends DrupalWebTestCase {
}
/**
* Test node type customizations persist through disable and uninstall.
* Tests that node type customizations persist through disable and uninstall.
*/
function testNodeTypeCustomizationPersistence() {
$web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types', 'administer modules'));
@@ -1534,7 +1578,7 @@ class NodeTypePersistenceTestCase extends DrupalWebTestCase {
}
/**
* Rebuild the node_access table.
* Verifies the rebuild functionality for the node_access table.
*/
class NodeAccessRebuildTestCase extends DrupalWebTestCase {
public static function getInfo() {
@@ -1553,6 +1597,9 @@ class NodeAccessRebuildTestCase extends DrupalWebTestCase {
$this->web_user = $web_user;
}
/**
* Tests rebuilding the node access permissions table.
*/
function testNodeAccessRebuild() {
$this->drupalGet('admin/reports/status');
$this->clickLink(t('Rebuild permissions'));
@@ -1562,7 +1609,7 @@ class NodeAccessRebuildTestCase extends DrupalWebTestCase {
}
/**
* Test node administration page functionality.
* Tests node administration page functionality.
*/
class NodeAdminTestCase extends DrupalWebTestCase {
public static function getInfo() {
@@ -1630,6 +1677,7 @@ class NodeAdminTestCase extends DrupalWebTestCase {
* Tests content overview with different user permissions.
*
* Taxonomy filters are tested separately.
*
* @see TaxonomyNodeFilterTestCase
*/
function testContentAdminPages() {
@@ -1727,7 +1775,7 @@ class NodeAdminTestCase extends DrupalWebTestCase {
}
/**
* Test node title.
* Tests node title functionality.
*/
class NodeTitleTestCase extends DrupalWebTestCase {
protected $admin_user;
@@ -1747,7 +1795,7 @@ class NodeTitleTestCase extends DrupalWebTestCase {
}
/**
* Create one node and test if the node title has the correct value.
* Creates one node and tests if the node title has the correct value.
*/
function testNodeTitle() {
// Create "Basic page" content with title.
@@ -1790,7 +1838,7 @@ class NodeFeedTestCase extends DrupalWebTestCase {
}
/**
* Ensure that node_feed accepts and prints extra channel elements.
* Ensures that node_feed() accepts and prints extra channel elements.
*/
function testNodeFeedExtraChannelElements() {
ob_start();
@@ -1822,7 +1870,7 @@ class NodeBlockFunctionalTest extends DrupalWebTestCase {
}
/**
* Test the recent comments block.
* Tests the recent comments block.
*/
function testRecentNodeBlock() {
$this->drupalLogin($this->admin_user);
@@ -1935,7 +1983,7 @@ class NodeBlockFunctionalTest extends DrupalWebTestCase {
}
}
/**
* Test multistep node forms basic options.
* Tests basic options of multi-step node forms.
*/
class MultiStepNodeFormBasicOptionsTest extends DrupalWebTestCase {
public static function getInfo() {
@@ -1953,7 +2001,7 @@ class MultiStepNodeFormBasicOptionsTest extends DrupalWebTestCase {
}
/**
* Change the default values of basic options to ensure they persist.
* Tests changing the default values of basic options to ensure they persist.
*/
function testMultiStepNodeFormBasicOptions() {
$edit = array(
@@ -1985,7 +2033,7 @@ class NodeBuildContent extends DrupalWebTestCase {
}
/**
* Test to ensure that a node's content array is rebuilt on every call to node_build_content().
* Ensures that content array is rebuilt on every call to node_build_content().
*/
function testNodeRebuildContent() {
$node = $this->drupalCreateNode();
@@ -2065,10 +2113,10 @@ class NodeQueryAlter extends DrupalWebTestCase {
}
/**
* Lower-level test of 'node_access' query alter, for user with access.
* Tests 'node_access' query alter, for user with access.
*
* Verifies that a non-standard table alias can be used, and that a
* user with node access can view the nodes.
* Verifies that a non-standard table alias can be used, and that a user with
* node access can view the nodes.
*/
function testNodeQueryAlterLowLevelWithAccess() {
// User with access should be able to view 4 nodes.
@@ -2088,10 +2136,10 @@ class NodeQueryAlter extends DrupalWebTestCase {
}
/**
* Lower-level test of 'node_access' query alter, for user without access.
* Tests 'node_access' query alter, for user without access.
*
* Verifies that a non-standard table alias can be used, and that a
* user without node access cannot view the nodes.
* Verifies that a non-standard table alias can be used, and that a user
* without node access cannot view the nodes.
*/
function testNodeQueryAlterLowLevelNoAccess() {
// User without access should be able to view 0 nodes.
@@ -2111,10 +2159,10 @@ class NodeQueryAlter extends DrupalWebTestCase {
}
/**
* Lower-level test of 'node_access' query alter, for edit access.
* Tests 'node_access' query alter, for edit access.
*
* Verifies that a non-standard table alias can be used, and that a
* user with view-only node access cannot edit the nodes.
* Verifies that a non-standard table alias can be used, and that a user with
* view-only node access cannot edit the nodes.
*/
function testNodeQueryAlterLowLevelEditAccess() {
// User with view-only access should not be able to edit nodes.
@@ -2136,13 +2184,13 @@ class NodeQueryAlter extends DrupalWebTestCase {
}
/**
* Lower-level test of 'node_access' query alter override.
* Tests 'node_access' query alter override.
*
* Verifies that node_access_view_all_nodes() is called from
* node_query_node_access_alter(). We do this by checking that
* a user which normally would not have view privileges is able
* to view the nodes when we add a record to {node_access} paired
* with a corresponding privilege in hook_node_grants().
* node_query_node_access_alter(). We do this by checking that a user who
* normally would not have view privileges is able to view the nodes when we
* add a record to {node_access} paired with a corresponding privilege in
* hook_node_grants().
*/
function testNodeQueryAlterOverride() {
$record = array(

View File

@@ -5,8 +5,8 @@ version = VERSION
core = 7.x
hidden = TRUE
; Information added by drupal.org packaging script on 2013-03-07
version = "7.21"
; Information added by drupal.org packaging script on 2013-04-03
version = "7.22"
project = "drupal"
datestamp = "1362616996"
datestamp = "1365027012"

View File

@@ -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 = '';

View File

@@ -5,8 +5,8 @@ version = VERSION
core = 7.x
hidden = TRUE
; Information added by drupal.org packaging script on 2013-03-07
version = "7.21"
; Information added by drupal.org packaging script on 2013-04-03
version = "7.22"
project = "drupal"
datestamp = "1362616996"
datestamp = "1365027012"

View File

@@ -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.
*/
/**

View File

@@ -5,8 +5,8 @@ version = VERSION
core = 7.x
hidden = TRUE
; Information added by drupal.org packaging script on 2013-03-07
version = "7.21"
; Information added by drupal.org packaging script on 2013-04-03
version = "7.22"
project = "drupal"
datestamp = "1362616996"
datestamp = "1365027012"

View File

@@ -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.
*/
/**