summaryrefslogtreecommitdiff
path: root/modules/node
diff options
context:
space:
mode:
Diffstat (limited to 'modules/node')
-rw-r--r--modules/node/node.api.php44
-rw-r--r--modules/node/node.module53
-rw-r--r--modules/node/node.pages.inc12
-rw-r--r--modules/node/tests/node_test.module6
4 files changed, 58 insertions, 57 deletions
diff --git a/modules/node/node.api.php b/modules/node/node.api.php
index a8e5d1e4c..fc967e3ef 100644
--- a/modules/node/node.api.php
+++ b/modules/node/node.api.php
@@ -74,7 +74,7 @@ function hook_node_grants($account, $op) {
*
* @ingroup node_access
*/
-function hook_node_access_records($node) {
+function hook_node_access_records(stdClass $node) {
if (node_access_example_disabling()) {
return;
}
@@ -138,7 +138,7 @@ function hook_node_access_records($node) {
*
* @ingroup node_access
*/
-function hook_node_access_records_alter(&$grants, $node) {
+function hook_node_access_records_alter(&$grants, stdClass $node) {
// Our module allows editors to tag specific articles as 'preview'
// content using the taxonomy system. If the node being saved
// contains one of the preview terms defined in our variable
@@ -265,7 +265,7 @@ function hook_node_operations() {
* @param $node
* The node that is being deleted.
*/
-function hook_node_delete($node) {
+function hook_node_delete(stdClass $node) {
db_delete('mytable')
->condition('nid', $node->nid)
->execute();
@@ -279,7 +279,7 @@ function hook_node_delete($node) {
* @param $node
* The node the action is being performed on.
*/
-function hook_node_revision_delete($node) {
+function hook_node_revision_delete(stdClass $node) {
db_delete('upload')->condition('vid', $node->vid)->execute();
if (!is_array($node->files)) {
return;
@@ -297,7 +297,7 @@ function hook_node_revision_delete($node) {
* @param $node
* The node the action is being performed on.
*/
-function hook_node_insert($node) {
+function hook_node_insert(stdClass $node) {
db_insert('mytable')
->fields(array(
'nid' => $node->nid,
@@ -375,7 +375,7 @@ function hook_node_load($nodes, $types) {
* NODE_ACCESSS_IGNORE to not affect this operation at all.
*/
function hook_node_access($node, $op, $account) {
- $type = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
+ $type = is_string($node) ? $node : $node->type;
if (in_array($type, node_permissions_get_configured_types())) {
if ($op == 'create' && user_access('create ' . $type . ' content', $account)) {
@@ -406,7 +406,7 @@ function hook_node_access($node, $op, $account) {
* @param $node
* The node the action is being performed on.
*/
-function hook_node_prepare($node) {
+function hook_node_prepare(stdClass $node) {
if (!isset($node->comment)) {
$node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN);
}
@@ -421,7 +421,7 @@ function hook_node_prepare($node) {
* @param $node
* The node the action is being performed on.
*/
-function hook_node_prepare_translation($node) {
+function hook_node_prepare_translation(stdClass $node) {
}
/**
@@ -434,7 +434,7 @@ function hook_node_prepare_translation($node) {
* @return
* Extra information to be displayed with search result.
*/
-function hook_node_search_result($node) {
+function hook_node_search_result(stdClass $node) {
$comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField();
return format_plural($comments, '1 comment', '@count comments');
}
@@ -447,7 +447,7 @@ function hook_node_search_result($node) {
* @param $node
* The node the action is being performed on.
*/
-function hook_node_presave($node) {
+function hook_node_presave(stdClass $node) {
if ($node->nid && $node->moderate) {
// Reset votes when node is updated:
$node->score = 0;
@@ -462,7 +462,7 @@ function hook_node_presave($node) {
* @param $node
* The node the action is being performed on.
*/
-function hook_node_update($node) {
+function hook_node_update(stdClass $node) {
db_update('mytable')
->fields(array('extra' => $node->extra))
->condition('nid', $node->nid)
@@ -480,7 +480,7 @@ function hook_node_update($node) {
* @return
* Array of additional information to be indexed.
*/
-function hook_node_update_index($node) {
+function hook_node_update_index(stdClass $node) {
$text = '';
$comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(':nid' => $node->nid, ':status' => COMMENT_PUBLISHED));
foreach ($comments as $comment) {
@@ -500,7 +500,7 @@ function hook_node_update_index($node) {
* @param $form
* The $form parameter from node_validate().
*/
-function hook_node_validate($node, $form) {
+function hook_node_validate(stdClass $node, $form) {
if (isset($node->end) && isset($node->start)) {
if ($node->start > $node->end) {
form_set_error('time', t('An event may not end before it starts.'));
@@ -531,7 +531,7 @@ function hook_node_validate($node, $form) {
* @param $build_mode
* The $build_mode parameter from node_build().
*/
-function hook_node_view($node, $build_mode) {
+function hook_node_view(stdClass $node, $build_mode) {
$node->content['my_additional_field'] = array(
'#value' => $additional_field,
'#weight' => 10,
@@ -556,7 +556,7 @@ function hook_node_view($node, $build_mode) {
* @param $build_mode
* The $build_mode parameter from node_build().
*/
-function hook_node_build_alter($node, $build_mode) {
+function hook_node_build_alter(stdClass $node, $build_mode) {
// Check for the existence of a field added by another module.
if (isset($node->content['an_additional_field'])) {
// Change its weight.
@@ -741,7 +741,7 @@ function hook_node_type_delete($info) {
*
* For a detailed usage example, see node_example.module.
*/
-function hook_delete($node) {
+function hook_delete(stdClass $node) {
db_delete('mytable')
->condition('nid', $nid->nid)
->execute();
@@ -756,7 +756,7 @@ function hook_delete($node) {
*
* For a usage example, see image.module.
*/
-function hook_prepare($node) {
+function hook_prepare(stdClass $node) {
if ($file = file_check_upload($field_name)) {
$file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
if ($file) {
@@ -796,7 +796,7 @@ function hook_prepare($node) {
*
* For a detailed usage example, see node_example.module.
*/
-function hook_form($node, $form_state) {
+function hook_form(stdClass $node, $form_state) {
$type = node_type_get_type($node);
$form['title'] = array(
@@ -846,7 +846,7 @@ function hook_form($node, $form_state) {
*
* For a detailed usage example, see node_example.module.
*/
-function hook_insert($node) {
+function hook_insert(stdClass $node) {
db_insert('mytable')
->fields(array(
'nid' => $node->nid,
@@ -892,7 +892,7 @@ function hook_load($nodes) {
*
* For a detailed usage example, see node_example.module.
*/
-function hook_update($node) {
+function hook_update(stdClass $node) {
db_update('mytable')
->fields(array('extra' => $node->extra))
->condition('nid', $node->nid)
@@ -921,7 +921,7 @@ function hook_update($node) {
*
* For a detailed usage example, see node_example.module.
*/
-function hook_validate($node, &$form) {
+function hook_validate(stdClass $node, &$form) {
if (isset($node->end) && isset($node->start)) {
if ($node->start > $node->end) {
form_set_error('time', t('An event may not end before it starts.'));
@@ -954,7 +954,7 @@ function hook_validate($node, &$form) {
*
* For a detailed usage example, see node_example.module.
*/
-function hook_view($node, $build_mode = 'full') {
+function hook_view(stdClass $node, $build_mode = 'full') {
if ((bool)menu_get_object()) {
$breadcrumb = array();
$breadcrumb[] = array('path' => 'example', 'title' => t('example'));
diff --git a/modules/node/node.module b/modules/node/node.module
index 1b3f500e8..71338eba7 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -869,7 +869,7 @@ function node_load($nid = NULL, $vid = NULL, $reset = FALSE) {
/**
* Perform validation checks on the given node.
*/
-function node_validate($node, $form = array()) {
+function node_validate(stdClass $node, $form = array()) {
$type = node_type_get_type($node);
if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
@@ -924,7 +924,7 @@ function node_submit($node) {
* The $node object to be saved. If $node->nid is
* omitted (or $node->is_new is TRUE), a new node will be added.
*/
-function node_save($node) {
+function node_save(stdClass $node) {
field_attach_presave('node', $node);
// Let modules modify the node before it is saved to the database.
module_invoke_all('node_presave', $node);
@@ -1035,7 +1035,7 @@ function node_save($node) {
* Node is taken by reference, because drupal_write_record() updates the
* $node with the revision id, and we need to pass that back to the caller.
*/
-function _node_save_revision($node, $uid, $update = NULL) {
+function _node_save_revision(stdClass $node, $uid, $update = NULL) {
$temp_uid = $node->uid;
$node->uid = $uid;
if (isset($update)) {
@@ -1179,7 +1179,7 @@ function node_build($node, $build_mode = 'full') {
* Build mode, e.g. 'full', 'teaser'...
*
*/
-function node_build_content($node, $build_mode = 'full') {
+function node_build_content(stdClass $node, $build_mode = 'full') {
// The 'view' hook can be implemented to overwrite the default function
// to display nodes.
if (node_hook($node, 'view')) {
@@ -1271,7 +1271,7 @@ function node_language_provider($languages) {
* @return
* A $page element suitable for use by drupal_page_render().
*/
-function node_show($node, $message = FALSE) {
+function node_show(stdClass $node, $message = FALSE) {
if ($message) {
drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'], '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
}
@@ -1686,7 +1686,7 @@ function theme_node_search_admin($variables) {
return $output;
}
-function _node_revision_access($node, $op = 'view') {
+function _node_revision_access(stdClass $node, $op = 'view') {
$access = &drupal_static(__FUNCTION__, array());
if (!isset($access[$node->vid])) {
$node_current_revision = node_load($node->nid);
@@ -1926,7 +1926,7 @@ function node_type_page_title($type) {
/**
* Title callback.
*/
-function node_page_title($node) {
+function node_page_title(stdClass $node) {
return $node->title;
}
@@ -1955,7 +1955,7 @@ function node_last_changed($nid) {
/**
* Return a list of all the existing revision numbers.
*/
-function node_revision_list($node) {
+function node_revision_list(stdClass $node) {
$revisions = array();
$result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.timestamp, u.name FROM {node_revision} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE r.nid = :nid ORDER BY r.timestamp DESC', array(':nid' => $node->nid));
foreach ($result as $revision) {
@@ -2147,7 +2147,7 @@ function node_page_default() {
/**
* Menu callback; view a single node.
*/
-function node_page_view($node) {
+function node_page_view(stdClass $node) {
$return = node_show($node);
if (isset($return['nodes'][$node->nid]['title'])) {
drupal_set_title($return['nodes'][$node->nid]['title']['items'][0]['#item']['value']);
@@ -2174,7 +2174,7 @@ function node_update_index() {
* @param $node
* The node to index.
*/
-function _node_index_node($node) {
+function _node_index_node(stdClass $node) {
$node = node_load($node->nid);
// Save the changed time of the most recent indexed node, for the search
@@ -2458,7 +2458,7 @@ function node_access($op, $node, $account = NULL) {
* Implement hook_node_access().
*/
function node_node_access($node, $op, $account) {
- $type = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
+ $type = is_string($node) ? $node : $node->type;
if (in_array($type, node_permissions_get_configured_types())) {
if ($op == 'create' && user_access('create ' . $type . ' content', $account)) {
@@ -2677,7 +2677,7 @@ function node_query_node_access_alter(QueryAlterableInterface $query) {
* @param $node
* The $node to acquire grants for.
*/
-function node_access_acquire_grants($node) {
+function node_access_acquire_grants(stdClass $node) {
$grants = module_invoke_all('node_access_records', $node);
// Let modules alter the grants.
drupal_alter('node_access_records', $grants, $node);
@@ -2707,7 +2707,8 @@ function node_access_acquire_grants($node) {
* changes.
*
* @param $node
- * The $node being written to. All that is necessary is that it contain a nid.
+ * The $node being written to. All that is necessary is that it contains a
+ * nid.
* @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.
@@ -2720,7 +2721,7 @@ function node_access_acquire_grants($node) {
* 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.
*/
-function node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE) {
+function node_access_write_grants(stdClass $node, $grants, $realm = NULL, $delete = TRUE) {
if ($delete) {
$query = db_delete('node_access')->condition('nid', $node->nid);
if ($realm) {
@@ -2909,7 +2910,7 @@ function _node_access_rebuild_batch_finished($success, $results, $operations) {
/**
* Implement hook_form().
*/
-function node_content_form($node, $form_state) {
+function node_content_form(stdClass $node, $form_state) {
// It is impossible to define a content type without implementing hook_form()
// so simply return an empty array().
// @todo: remove this requirement.
@@ -3027,7 +3028,7 @@ function node_action_info() {
* Implement a Drupal action.
* Sets the status of a node to 1, meaning published.
*/
-function node_publish_action($node, $context = array()) {
+function node_publish_action(stdClass $node, $context = array()) {
$node->status = NODE_PUBLISHED;
watchdog('action', 'Set @type %title to published.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
}
@@ -3036,7 +3037,7 @@ function node_publish_action($node, $context = array()) {
* Implement a Drupal action.
* Sets the status of a node to 0, meaning unpublished.
*/
-function node_unpublish_action($node, $context = array()) {
+function node_unpublish_action(stdClass $node, $context = array()) {
$node->status = NODE_NOT_PUBLISHED;
watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
}
@@ -3045,7 +3046,7 @@ function node_unpublish_action($node, $context = array()) {
* Implement a Drupal action.
* Sets the sticky-at-top-of-list property of a node to 1.
*/
-function node_make_sticky_action($node, $context = array()) {
+function node_make_sticky_action(stdClass $node, $context = array()) {
$node->sticky = NODE_STICKY;
watchdog('action', 'Set @type %title to sticky.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
}
@@ -3054,7 +3055,7 @@ function node_make_sticky_action($node, $context = array()) {
* Implement a Drupal action.
* Sets the sticky-at-top-of-list property of a node to 0.
*/
-function node_make_unsticky_action($node, $context = array()) {
+function node_make_unsticky_action(stdClass $node, $context = array()) {
$node->sticky = NODE_NOT_STICKY;
watchdog('action', 'Set @type %title to unsticky.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
}
@@ -3063,7 +3064,7 @@ function node_make_unsticky_action($node, $context = array()) {
* Implement a Drupal action.
* Sets the promote property of a node to 1.
*/
-function node_promote_action($node, $context = array()) {
+function node_promote_action(stdClass $node, $context = array()) {
$node->promote = NODE_PROMOTED;
watchdog('action', 'Promoted @type %title to front page.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
}
@@ -3072,7 +3073,7 @@ function node_promote_action($node, $context = array()) {
* Implement a Drupal action.
* Sets the promote property of a node to 0.
*/
-function node_unpromote_action($node, $context = array()) {
+function node_unpromote_action(stdClass $node, $context = array()) {
$node->promote = NODE_NOT_PROMOTED;
watchdog('action', 'Removed @type %title from front page.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
}
@@ -3081,7 +3082,7 @@ function node_unpromote_action($node, $context = array()) {
* Implement a Drupal action.
* Saves a node.
*/
-function node_save_action($node) {
+function node_save_action(stdClass $node) {
node_save($node);
watchdog('action', 'Saved @type %title', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
}
@@ -3090,7 +3091,7 @@ function node_save_action($node) {
* Implement a configurable Drupal action.
* Assigns ownership of a node to a user.
*/
-function node_assign_owner_action($node, $context) {
+function node_assign_owner_action(stdClass $node, $context) {
$node->uid = $context['owner_uid'];
$owner_name = db_query("SELECT name FROM {users} WHERE uid = :uid", array(':uid' => $context['owner_uid']))->fetchField();
watchdog('action', 'Changed owner of @type %title to uid %name.', array('@type' => node_type_get_type($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'], '%name' => $owner_name));
@@ -3164,13 +3165,13 @@ function node_unpublish_by_keyword_action_submit($form, $form_state) {
* Implement a configurable Drupal action.
* Unpublish a node if it contains a certain string.
*
+ * @param $node
+ * A node object.
* @param $context
* An array providing more information about the context of the call to this
* action.
- * @param $comment
- * A node object.
*/
-function node_unpublish_by_keyword_action($node, $context) {
+function node_unpublish_by_keyword_action(stdClass $node, $context) {
foreach ($context['keywords'] as $keyword) {
if (strpos(drupal_render(node_build(clone $node)), $keyword) !== FALSE || strpos($node->title, $keyword) !== FALSE) {
$node->status = NODE_NOT_PUBLISHED;
diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc
index ae0209ee4..748df2c2c 100644
--- a/modules/node/node.pages.inc
+++ b/modules/node/node.pages.inc
@@ -10,7 +10,7 @@
/**
* Menu callback; presents the node editing form, or redirects to delete confirmation.
*/
-function node_page_edit($node) {
+function node_page_edit(stdClass $node) {
$type_name = node_type_get_name($node);
drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => $type_name, '@title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'])), PASS_THROUGH);
return drupal_get_form($node->type . '_node_form', $node);
@@ -80,7 +80,7 @@ function node_form_validate($form, &$form_state) {
field_attach_form_validate('node', $node, $form, $form_state);
}
-function node_object_prepare($node) {
+function node_object_prepare(stdClass $node) {
// Set up default values, if required.
$node_options = variable_get('node_options_' . $node->type, array('status', 'promote'));
// If this is a new node, fill in the default values.
@@ -107,7 +107,7 @@ function node_object_prepare($node) {
/**
* Generate the node add/edit form array.
*/
-function node_form($form, &$form_state, $node) {
+function node_form($form, &$form_state, stdClass $node) {
global $user;
if (isset($form_state['node'])) {
@@ -339,7 +339,7 @@ function theme_node_form($variables) {
/**
* Generate a node preview.
*/
-function node_preview($node) {
+function node_preview(stdClass $node) {
if (node_access('create', $node) || node_access('update', $node)) {
_field_invoke_multiple('load', 'node', array($node->nid => $node));
// Load the user's name when needed.
@@ -460,7 +460,7 @@ function node_form_submit_build_node($form, &$form_state) {
/**
* Menu callback -- ask for confirmation of node deletion
*/
-function node_delete_confirm($form, &$form_state, $node) {
+function node_delete_confirm($form, &$form_state, stdClass $node) {
$form['nid'] = array(
'#type' => 'value',
'#value' => $node->nid,
@@ -492,7 +492,7 @@ function node_delete_confirm_submit($form, &$form_state) {
/**
* Generate an overview table of older revisions of a node.
*/
-function node_revision_overview($node) {
+function node_revision_overview(stdClass $node) {
drupal_set_title(t('Revisions for %title', array('%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'])), PASS_THROUGH);
$header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 2));
diff --git a/modules/node/tests/node_test.module b/modules/node/tests/node_test.module
index dc354ff80..2af1c202d 100644
--- a/modules/node/tests/node_test.module
+++ b/modules/node/tests/node_test.module
@@ -10,7 +10,7 @@
/**
* Implement hook_node_view().
*/
-function node_test_node_view($node, $build_mode) {
+function node_test_node_view(stdClass $node, $build_mode) {
if ($build_mode == 'rss') {
// Add RSS elements and namespaces when building the RSS feed.
$node->rss_elements[] = array(
@@ -51,7 +51,7 @@ function node_test_node_grants($account, $op) {
/**
* Implement hook_node_access_records().
*/
-function node_test_node_access_records($node) {
+function node_test_node_access_records(stdClass $node) {
$grants = array();
if ($node->type == 'article') {
// Create grant in arbitrary article_realm for article nodes.
@@ -81,7 +81,7 @@ function node_test_node_access_records($node) {
/**
* Implement hook_node_access_records_alter().
*/
-function node_test_node_access_records_alter(&$grants, $node) {
+function node_test_node_access_records_alter(&$grants, stdClass $node) {
if (!empty($grants)) {
foreach ($grants as $key => $grant) {
// Alter grant from test_page_realm to test_alter_realm and modify the gid.