summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJennifer Hodgdon <yahgrp@poplarware.com>2012-11-27 07:45:14 -0800
committerJennifer Hodgdon <yahgrp@poplarware.com>2012-11-27 07:45:14 -0800
commit137bbb88df148e12ec450a2dd40109e3c7f9deef (patch)
treee6b9bb291c22db44156534aab83dd838c956d07d
parent71173d457c63fc86cd27e0312cb2064f264a6665 (diff)
downloadbrdo-137bbb88df148e12ec450a2dd40109e3c7f9deef.tar.gz
brdo-137bbb88df148e12ec450a2dd40109e3c7f9deef.tar.bz2
Issue #1313980 by Albert Volkman, Lars Toomre, jn2, xjm, jhodgdon: Clean up API docs for Node module
-rw-r--r--modules/node/content_types.inc9
-rw-r--r--modules/node/node.admin.inc135
-rw-r--r--modules/node/node.api.php200
-rw-r--r--modules/node/node.module236
-rw-r--r--modules/node/node.pages.inc105
-rw-r--r--modules/node/node.test141
-rw-r--r--modules/node/tests/node_access_test.module6
-rw-r--r--modules/node/tests/node_test.module6
-rw-r--r--modules/node/tests/node_test_exception.module3
9 files changed, 611 insertions, 230 deletions
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc
index 72adc3491..4b722ee02 100644
--- a/modules/node/content_types.inc
+++ b/modules/node/content_types.inc
@@ -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']);
diff --git a/modules/node/node.admin.inc b/modules/node/node.admin.inc
index 1508bc054..be09b37cc 100644
--- a/modules/node/node.admin.inc
+++ b/modules/node/node.admin.inc
@@ -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']));
diff --git a/modules/node/node.api.php b/modules/node/node.api.php
index 052effc9b..f8dcfdeff 100644
--- a/modules/node/node.api.php
+++ b/modules/node/node.api.php
@@ -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
*/
diff --git a/modules/node/node.module b/modules/node/node.module
index d86c74d2d..519a0cba5 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -244,6 +244,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(
@@ -315,8 +321,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;
@@ -461,6 +473,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);
@@ -761,8 +775,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.
@@ -851,6 +866,7 @@ function node_rdf_mapping() {
* 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.
*/
@@ -868,6 +884,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.
*/
@@ -883,8 +900,8 @@ function node_invoke($node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
* Load 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
@@ -934,6 +951,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.
@@ -1159,6 +1179,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;
@@ -1406,6 +1433,7 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) {
* 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 +1456,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();
@@ -1893,6 +1924,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) {
@@ -2111,6 +2150,14 @@ function node_menu_local_tasks_alter(&$data, $router_item, $root_path) {
/**
* Title callback for a node type.
+ *
+ * @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;
@@ -2118,6 +2165,14 @@ function node_type_page_title($type) {
/**
* Title callback.
+ *
+ * @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;
@@ -2138,6 +2193,12 @@ function node_last_changed($nid) {
/**
* Return 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,8 +2284,8 @@ 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');
@@ -2568,8 +2629,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().
@@ -2589,6 +2650,11 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcod
/**
* Menu callback; Generate 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')
@@ -2639,6 +2705,14 @@ function node_page_default() {
/**
* Menu callback; view 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
@@ -2819,8 +2893,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
@@ -3005,6 +3079,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 +3113,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.
@@ -3064,18 +3139,19 @@ function node_permissions_get_configured_types() {
* Fetch 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 +3239,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');
@@ -3394,15 +3469,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 +3484,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) {
@@ -3450,13 +3528,16 @@ function node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE)
* 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
+ * 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)) {
@@ -3543,11 +3624,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 +3662,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) {
@@ -3631,6 +3722,7 @@ function node_content_form($node, $form_state) {
/**
* Implements hook_forms().
+ *
* All node forms share the same form handler.
*/
function node_forms() {
@@ -3715,6 +3807,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 +3823,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 +3839,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 +3855,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 +3871,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 +3887,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 +3903,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 +3922,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 +3935,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 +3985,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 +3997,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 +4008,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(
diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc
index c6cb1bcc2..dee92e16c 100644
--- a/modules/node/node.pages.inc
+++ b/modules/node/node.pages.inc
@@ -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);
@@ -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);
diff --git a/modules/node/node.test b/modules/node/node.test
index d789d3c0e..2180f5838 100644
--- a/modules/node/node.test
+++ b/modules/node/node.test
@@ -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.
@@ -563,6 +575,9 @@ class NodeCreationTestCase extends DrupalWebTestCase {
}
}
+/**
+ * Tests the functionality of node entity edit permissions.
+ */
class PageViewTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -573,7 +588,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 +617,9 @@ class PageViewTestCase extends DrupalWebTestCase {
}
}
+/**
+ * Tests the summary length functionality.
+ */
class SummaryLengthTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -612,7 +630,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 +662,9 @@ class SummaryLengthTestCase extends DrupalWebTestCase {
}
}
+/**
+ * Tests XSS functionality with a node entity.
+ */
class NodeTitleXSSTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -653,6 +674,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 +702,9 @@ class NodeTitleXSSTestCase extends DrupalWebTestCase {
}
}
+/**
+ * Tests the availability of the syndicate block.
+ */
class NodeBlockTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
@@ -709,7 +736,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 +755,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 +778,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 +801,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 +828,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 +867,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 +883,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 +938,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 +957,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 +1033,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 +1040,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 +1177,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 +1198,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 +1233,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 +1332,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 +1351,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 +1381,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 +1434,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 +1495,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 +1559,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 +1578,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 +1590,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 +1658,7 @@ class NodeAdminTestCase extends DrupalWebTestCase {
* Tests content overview with different user permissions.
*
* Taxonomy filters are tested separately.
+ *
* @see TaxonomyNodeFilterTestCase
*/
function testContentAdminPages() {
@@ -1727,7 +1756,7 @@ class NodeAdminTestCase extends DrupalWebTestCase {
}
/**
- * Test node title.
+ * Tests node title functionality.
*/
class NodeTitleTestCase extends DrupalWebTestCase {
protected $admin_user;
@@ -1747,7 +1776,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 +1819,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 +1851,7 @@ class NodeBlockFunctionalTest extends DrupalWebTestCase {
}
/**
- * Test the recent comments block.
+ * Tests the recent comments block.
*/
function testRecentNodeBlock() {
$this->drupalLogin($this->admin_user);
@@ -1935,7 +1964,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 +1982,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 +2014,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 +2094,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 +2117,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 +2140,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 +2165,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(
diff --git a/modules/node/tests/node_access_test.module b/modules/node/tests/node_access_test.module
index 813bf929b..ec35c41f1 100644
--- a/modules/node/tests/node_access_test.module
+++ b/modules/node/tests/node_access_test.module
@@ -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 = '';
diff --git a/modules/node/tests/node_test.module b/modules/node/tests/node_test.module
index a52c1fad0..fb6678521 100644
--- a/modules/node/tests/node_test.module
+++ b/modules/node/tests/node_test.module
@@ -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.
*/
/**
diff --git a/modules/node/tests/node_test_exception.module b/modules/node/tests/node_test_exception.module
index 0fe9f35ea..66bc71747 100644
--- a/modules/node/tests/node_test_exception.module
+++ b/modules/node/tests/node_test_exception.module
@@ -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.
*/
/**