Commit ddc2604d authored by webchick's avatar webchick

#383066 by David Strauss: Rename hook_nodeapi_X to hook_node_X.

parent ad84a926
......@@ -119,7 +119,7 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a
* 'description' => t('Save node'),
* 'configurable' => FALSE,
* 'hooks' => array(
* 'nodeapi' => array('delete', 'insert', 'update', 'view'),
* 'node' => array('delete', 'insert', 'update', 'view'),
* 'comment' => array('delete', 'insert', 'update', 'view'),
* )
* )
......@@ -147,7 +147,7 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a
* 'description' => t('Publish post'),
* 'configurable' => FALSE,
* 'hooks' => array(
* 'nodeapi' => array('presave', 'insert', 'update', 'view'),
* 'node' => array('presave', 'insert', 'update', 'view'),
* 'comment' => array('delete', 'insert', 'update', 'view'),
* ),
* );
......
......@@ -94,9 +94,9 @@ function blog_view($node, $teaser) {
}
/**
* Implementation of hook_nodeapi_view.
* Implementation of hook_node_view.
*/
function blog_nodeapi_view($node, $teaser = FALSE) {
function blog_node_view($node, $teaser = FALSE) {
if ($node->type == 'blog') {
if (arg(0) != 'blog' || arg(1) != $node->uid) {
$links['blog_usernames_blog'] = array(
......
......@@ -224,7 +224,7 @@ function blogapi_blogger_new_post($appkey, $blogid, $username, $password, $conte
$edit['date'] = format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O');
}
node_invoke_nodeapi($edit, 'blogapi_new');
node_invoke_node($edit, 'blogapi_new');
$valid = blogapi_status_error_check($edit, $publish);
if ($valid !== TRUE) {
......@@ -282,7 +282,7 @@ function blogapi_blogger_edit_post($appkey, $postid, $username, $password, $cont
$node->body = $content;
}
node_invoke_nodeapi($node, 'blogapi_edit');
node_invoke_node($node, 'blogapi_edit');
$valid = blogapi_status_error_check($node, $original_status);
if ($valid !== TRUE) {
......
......@@ -63,7 +63,7 @@ function book_perm() {
/**
* Inject links into $node as needed.
*/
function book_nodeapi_view_link($node, $teaser, $page) {
function book_node_view_link($node, $teaser, $page) {
$links = array();
if (isset($node->book['depth'])) {
......@@ -720,9 +720,9 @@ function book_build_active_trail($book_link) {
}
/**
* Implementation of hook_nodeapi_load().
* Implementation of hook_node_load().
*/
function book_nodeapi_load($nodes, $types) {
function book_node_load($nodes, $types) {
$result = db_query("SELECT * FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid IN (:nids)", array(':nids' => array_keys($nodes)), array('fetch' => PDO::FETCH_ASSOC));
foreach ($result as $record) {
$nodes[$record['nid']]->book = $record;
......@@ -733,9 +733,9 @@ function book_nodeapi_load($nodes, $types) {
}
/**
* Implementation of hook_nodeapi_view().
* Implementation of hook_node_view().
*/
function book_nodeapi_view($node, $teaser, $page) {
function book_node_view($node, $teaser, $page) {
if (!$teaser) {
if (!empty($node->book['bid']) && $node->build_mode == NODE_BUILD_NORMAL) {
$node->content['book_navigation'] = array(
......@@ -750,13 +750,13 @@ function book_nodeapi_view($node, $teaser, $page) {
}
}
book_nodeapi_view_link($node, $teaser, $page);
book_node_view_link($node, $teaser, $page);
}
/**
* Implementation of hook_nodeapi_presave().
* Implementation of hook_node_presave().
*/
function book_nodeapi_presave($node) {
function book_node_presave($node) {
// Always save a revision for non-administrators.
if (!empty($node->book['bid']) && !user_access('administer nodes')) {
$node->revision = 1;
......@@ -772,9 +772,9 @@ function book_nodeapi_presave($node) {
}
/**
* Implementation of hook_nodeapi_insert().
* Implementation of hook_node_insert().
*/
function book_nodeapi_insert($node) {
function book_node_insert($node) {
if (!empty($node->book['bid'])) {
if ($node->book['bid'] == 'new') {
// New nodes that are their own book.
......@@ -787,9 +787,9 @@ function book_nodeapi_insert($node) {
}
/**
* Implementation of hook_nodeapi_update().
* Implementation of hook_node_update().
*/
function book_nodeapi_update($node) {
function book_node_update($node) {
if (!empty($node->book['bid'])) {
if ($node->book['bid'] == 'new') {
// New nodes that are their own book.
......@@ -802,9 +802,9 @@ function book_nodeapi_update($node) {
}
/**
* Implementation of hook_nodeapi_delete().
* Implementation of hook_node_delete().
*/
function book_nodeapi_delete($node) {
function book_node_delete($node) {
if (!empty($node->book['bid'])) {
if ($node->nid == $node->book['bid']) {
// Handle deletion of a top-level post.
......@@ -825,9 +825,9 @@ function book_nodeapi_delete($node) {
}
/**
* Implementation of hook_nodeapi_prepare().
* Implementation of hook_node_prepare().
*/
function book_nodeapi_prepare($node) {
function book_node_prepare($node) {
// Prepare defaults for the add/edit form.
if (empty($node->book) && (user_access('add content to books') || user_access('administer book outlines'))) {
$node->book = array();
......
......@@ -414,9 +414,9 @@ function theme_comment_block() {
}
/**
* An implementation of hook_nodeapi_view().
* An implementation of hook_node_view().
*/
function comment_nodeapi_view($node, $teaser) {
function comment_node_view($node, $teaser) {
$links = array();
if ($node->comment) {
......@@ -592,9 +592,9 @@ function comment_form_alter(&$form, $form_state, $form_id) {
}
/**
* Implementation of hook_nodeapi_load().
* Implementation of hook_node_load().
*/
function comment_nodeapi_load($nodes, $types) {
function comment_node_load($nodes, $types) {
$comments_enabled = array();
// Check if comments are enabled for each node. If comments are disabled,
......@@ -623,18 +623,18 @@ function comment_nodeapi_load($nodes, $types) {
}
/**
* Implementation of hook_nodeapi_prepare().
* Implementation of hook_node_prepare().
*/
function comment_nodeapi_prepare($node) {
function comment_node_prepare($node) {
if (!isset($node->comment)) {
$node->comment = variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
}
}
/**
* Implementation of hook_nodeapi_insert().
* Implementation of hook_node_insert().
*/
function comment_nodeapi_insert($node) {
function comment_node_insert($node) {
db_insert('node_comment_statistics')
->fields(array(
'nid' => $node->nid,
......@@ -646,9 +646,9 @@ function comment_nodeapi_insert($node) {
}
/**
* Implementation of hook_nodeapi_delete().
* Implementation of hook_node_delete().
*/
function comment_nodeapi_delete($node) {
function comment_node_delete($node) {
db_delete('comment')
->condition('nid', $node->nid)
->execute();
......@@ -658,9 +658,9 @@ function comment_nodeapi_delete($node) {
}
/**
* Implementation of hook_nodeapi_update_index().
* Implementation of hook_node_update_index().
*/
function comment_nodeapi_update_index($node) {
function comment_node_update_index($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) {
......@@ -678,17 +678,17 @@ function comment_update_index() {
}
/**
* Implementation of hook_nodeapi_search_result().
* Implementation of hook_node_search_result().
*/
function comment_nodeapi_search_result($node) {
function comment_node_search_result($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');
}
/**
* Implementation of hook_nodeapi_rss_item().
* Implementation of hook_node_rss_item().
*/
function comment_nodeapi_rss_item($node) {
function comment_node_rss_item($node) {
if ($node->comment != COMMENT_NODE_DISABLED) {
return array(array('key' => 'comments', 'value' => url('node/' . $node->nid, array('fragment' => 'comments', 'absolute' => TRUE))));
}
......
......@@ -512,7 +512,7 @@ function _field_attach_preprocess($obj_type, &$object) {
}
/**
* Implementation of hook_nodeapi_prepare_translation.
* Implementation of hook_node_prepare_translation.
*
* TODO D7: We do not yet know if this really belongs in Field API.
*/
......
......@@ -251,7 +251,7 @@ function field_attach_preprocess($obj_type, &$object) {
}
/**
* Implementation of hook_nodeapi_prepare_translation.
* Implementation of hook_node_prepare_translation.
*
* TODO D7: We do not yet know if this really belongs in Field API.
*
......
......@@ -69,7 +69,7 @@ function field_default_submit($obj_type, &$object, $field, $instance, &$items, $
* '#field_name' => 'field_name',
* '#object' => $object,
* '#object_type' => $obj_type,
* // Value of the $teaser param of hook_nodeapi('view').
* // Value of the $teaser param of hook_node('view').
* '#teaser' => $teaser,
* 'items' =>
* 0 => array(
......
......@@ -461,7 +461,7 @@ function field_format($obj_type, $object, $field, $item, $formatter_name = NULL,
* The object containing the field to display. Must at least contain the id key,
* revision key (if applicable), bundle key, and the field data.
* @param $teaser
* Similar to hook_nodeapi('view')
* Similar to hook_node('view')
* @return
* The themed output for the field.
*/
......
......@@ -156,14 +156,14 @@ function forum_init() {
}
/**
* _forum_nodeapi_check_node_type
* _forum_node_check_node_type
*
* @param mixed $node
* @param mixed $vocabulary
* @access protected
* @return bool
*/
function _forum_nodeapi_check_node_type($node, $vocabulary) {
function _forum_node_check_node_type($node, $vocabulary) {
// We are going to return if $node->type is not one of the node
// types assigned to the forum vocabulary. If forum_nav_vocabulary
// is undefined or the vocabulary does not exist, it clearly cannot
......@@ -181,12 +181,12 @@ function _forum_nodeapi_check_node_type($node, $vocabulary) {
}
/**
* Implementation of hook_nodeapi_view().
* Implementation of hook_node_view().
*/
function forum_nodeapi_view($node, $teaser) {
function forum_node_view($node, $teaser) {
$vid = variable_get('forum_nav_vocabulary', '');
$vocabulary = taxonomy_vocabulary_load($vid);
if (_forum_nodeapi_check_node_type($node, $vocabulary)) {
if (_forum_node_check_node_type($node, $vocabulary)) {
if ((bool)menu_get_object() && taxonomy_node_get_terms_by_vocabulary($node, $vid) && $tree = taxonomy_get_tree($vid)) {
// Get the forum terms from the (cached) tree
foreach ($tree as $term) {
......@@ -219,12 +219,12 @@ function forum_nodeapi_view($node, $teaser) {
}
/**
* Implementation of hook_nodeapi_prepare().
* Implementation of hook_node_prepare().
*/
function forum_nodeapi_prepare($node) {
function forum_node_prepare($node) {
$vid = variable_get('forum_nav_vocabulary', '');
$vocabulary = taxonomy_vocabulary_load($vid);
if (_forum_nodeapi_check_node_type($node, $vocabulary)) {
if (_forum_node_check_node_type($node, $vocabulary)) {
if (empty($node->nid)) {
// New topic
$node->taxonomy[arg(3)] = (object) array(
......@@ -236,14 +236,14 @@ function forum_nodeapi_prepare($node) {
}
/**
* Implementation of hook_nodeapi_validate().
* Implementation of hook_node_validate().
*
* Check in particular that only a "leaf" term in the associated taxonomy.
*/
function forum_nodeapi_validate($node, $form) {
function forum_node_validate($node, $form) {
$vid = variable_get('forum_nav_vocabulary', '');
$vocabulary = taxonomy_vocabulary_load($vid);
if (_forum_nodeapi_check_node_type($node, $vocabulary)) {
if (_forum_node_check_node_type($node, $vocabulary)) {
// vocabulary is selected, not a "container" term.
if ($node->taxonomy) {
// Extract the node's proper topic ID.
......@@ -262,14 +262,14 @@ function forum_nodeapi_validate($node, $form) {
}
/**
* Implementation of hook_nodeapi_presave().
* Implementation of hook_node_presave().
*
* Assign forum taxonomy when adding a topic from within a forum.
*/
function forum_nodeapi_presave($node) {
function forum_node_presave($node) {
$vid = variable_get('forum_nav_vocabulary', '');
$vocabulary = taxonomy_vocabulary_load($vid);
if (_forum_nodeapi_check_node_type($node, $vocabulary)) {
if (_forum_node_check_node_type($node, $vocabulary)) {
// Make sure all fields are set properly:
$node->icon = !empty($node->icon) ? $node->icon : '';
......@@ -293,12 +293,12 @@ function forum_nodeapi_presave($node) {
}
/**
* Implementation of hook_nodeapi_update().
* Implementation of hook_node_update().
*/
function forum_nodeapi_update($node) {
function forum_node_update($node) {
$vid = variable_get('forum_nav_vocabulary', '');
$vocabulary = taxonomy_vocabulary_load($vid);
if (_forum_nodeapi_check_node_type($node, $vocabulary)) {
if (_forum_node_check_node_type($node, $vocabulary)) {
if (empty($node->revision) && db_result(db_query('SELECT tid FROM {forum} WHERE nid=%d', $node->nid))) {
if (!empty($node->tid)) {
db_query('UPDATE {forum} SET tid = %d WHERE vid = %d', $node->tid, $node->vid);
......@@ -317,12 +317,12 @@ function forum_nodeapi_update($node) {
}
/**
* Implementation of hook_nodeapi_insert().
* Implementation of hook_node_insert().
*/
function forum_nodeapi_insert($node) {
function forum_node_insert($node) {
$vid = variable_get('forum_nav_vocabulary', '');
$vocabulary = taxonomy_vocabulary_load($vid);
if (_forum_nodeapi_check_node_type($node, $vocabulary)) {
if (_forum_node_check_node_type($node, $vocabulary)) {
if (!empty($node->tid)) {
db_query('INSERT INTO {forum} (tid, vid, nid) VALUES (%d, %d, %d)', $node->tid, $node->vid, $node->nid);
}
......@@ -330,20 +330,20 @@ function forum_nodeapi_insert($node) {
}
/**
* Implementation of hook_nodeapi_delete().
* Implementation of hook_node_delete().
*/
function forum_nodeapi_delete($node) {
function forum_node_delete($node) {
$vid = variable_get('forum_nav_vocabulary', '');
$vocabulary = taxonomy_vocabulary_load($vid);
if (_forum_nodeapi_check_node_type($node, $vocabulary)) {
if (_forum_node_check_node_type($node, $vocabulary)) {
db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid);
}
}
/**
* Implementation of hook_nodeapi_load().
* Implementation of hook_node_load().
*/
function forum_nodeapi_load($nodes, $types) {
function forum_node_load($nodes, $types) {
$vid = variable_get('forum_nav_vocabulary', '');
// If no forum vocabulary is set up, return.
if ($vid == '') {
......
......@@ -289,9 +289,9 @@ function menu_block_view($delta = '') {
}
/**
* Implementation of hook_nodeapi_insert().
* Implementation of hook_node_insert().
*/
function menu_nodeapi_insert(&$node) {
function menu_node_insert(&$node) {
if (isset($node->menu)) {
$item = &$node->menu;
if (!empty($item['delete'])) {
......@@ -311,9 +311,9 @@ function menu_nodeapi_insert(&$node) {
}
/**
* Implementation of hook_nodeapi_update().
* Implementation of hook_node_update().
*/
function menu_nodeapi_update(&$node) {
function menu_node_update(&$node) {
if (isset($node->menu)) {
$item = &$node->menu;
if (!empty($item['delete'])) {
......@@ -333,9 +333,9 @@ function menu_nodeapi_update(&$node) {
}
/**
* Implementation of hook_nodeapi_delete().
* Implementation of hook_node_delete().
*/
function menu_nodeapi_delete(&$node) {
function menu_node_delete(&$node) {
// Delete all menu module links that point to this node.
$result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu'", array(':path' => 'node/'. $node->nid));
while ($m = db_fetch_array($result)) {
......@@ -344,9 +344,9 @@ function menu_nodeapi_delete(&$node) {
}
/**
* Implementation of hook_nodeapi_prepare().
* Implementation of hook_node_prepare().
*/
function menu_nodeapi_prepare(&$node) {
function menu_node_prepare(&$node) {
if (empty($node->menu)) {
// Prepare the node for the edit form so that $node->menu always exists.
$menu_name = variable_get('menu_default_node_menu', 'main-menu');
......
......@@ -169,7 +169,7 @@ function hook_node_operations() {
* @return
* None.
*/
function hook_nodeapi_alter($node, $teaser) {
function hook_node_alter($node, $teaser) {
}
/**
......@@ -180,7 +180,7 @@ function hook_nodeapi_alter($node, $teaser) {
* @return
* None.
*/
function hook_nodeapi_delete($node) {
function hook_node_delete($node) {
db_query('DELETE FROM {mytable} WHERE nid = %d', $node->nid);
}
......@@ -194,7 +194,7 @@ function hook_nodeapi_delete($node) {
* @return
* None.
*/
function hook_nodeapi_delete_revision($node) {
function hook_node_delete_revision($node) {
db_delete('upload')->condition('vid', $node->vid)->execute();
if (!is_array($node->files)) {
return;
......@@ -212,7 +212,7 @@ function hook_nodeapi_delete_revision($node) {
* @return
* None.
*/
function hook_nodeapi_insert($node) {
function hook_node_insert($node) {
db_query("INSERT INTO {mytable} (nid, extra) VALUES (%d, '%s')", $node->nid, $node->extra);
}
......@@ -233,16 +233,16 @@ function hook_nodeapi_insert($node) {
* this may affect the way nodes are returned from the cache in subsequent
* calls to the function.
*
* @see comment_nodeapi_load()
* @see taxonomy_nodeapi_load()
* @see forum_nodeapi_load()
* @see comment_node_load()
* @see taxonomy_node_load()
* @see forum_node_load()
*
* @param $nodes
* An array of node objects indexed by nid.
* @param $types
* An array containing the types of the nodes.
*/
function hook_nodeapi_load($nodes, $types) {
function hook_node_load($nodes, $types) {
$result = db_query('SELECT nid, foo FROM {mytable} WHERE nid IN(:nids)', array(':nids' => array_keys($nodes)));
foreach ($result as $record) {
$nodes[$record->nid]->foo = $record->foo;
......@@ -257,7 +257,7 @@ function hook_nodeapi_load($nodes, $types) {
* @return
* None.
*/
function hook_nodeapi_prepare($node) {
function hook_node_prepare($node) {
if (!isset($node->comment)) {
$node->comment = variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
}
......@@ -274,7 +274,7 @@ function hook_nodeapi_prepare($node) {
* @return
* None.
*/
function hook_nodeapi_prepare_translation($node) {
function hook_node_prepare_translation($node) {
}
/**
......@@ -282,7 +282,7 @@ function hook_nodeapi_prepare_translation($node) {
*
* The module can return properties to be added to the RSS item generated for
* this node. This hook should only be used to add XML elements to the RSS
* feed item itself. See comment_nodeapi_rss_item() and upload_nodeapi_rss_item()
* feed item itself. See comment_node_rss_item() and upload_node_rss_item()
* for examples.
*
* @param $node
......@@ -290,7 +290,7 @@ function hook_nodeapi_prepare_translation($node) {
* @return
* Extra information to be added to the RSS item.
*/
function hook_nodeapi_rss_item($node) {
function hook_node_rss_item($node) {
if ($node->comment != COMMENT_NODE_DISABLED) {
return array(array('key' => 'comments', 'value' => url('node/' . $node->nid, array('fragment' => 'comments', 'absolute' => TRUE))));
}
......@@ -309,7 +309,7 @@ function hook_nodeapi_rss_item($node) {
* @return
* Extra information to be displayed with search result.
*/
function hook_nodeapi_search_result($node) {
function hook_node_search_result($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');
}
......@@ -324,7 +324,7 @@ function hook_nodeapi_search_result($node) {
* @return
* None.
*/
function hook_nodeapi_presave($node) {
function hook_node_presave($node) {
if ($node->nid && $node->moderate) {
// Reset votes when node is updated:
$node->score = 0;
......@@ -341,7 +341,7 @@ function hook_nodeapi_presave($node) {
* @return
* None.
*/
function hook_nodeapi_update($node) {
function hook_node_update($node) {
db_query("UPDATE {mytable} SET extra = '%s' WHERE nid = %d", $node->extra, $node->nid);
}
......@@ -349,14 +349,14 @@ function hook_nodeapi_update($node) {
* The node is being indexed.
*
* If you want additional information to be indexed which is not already
* visible through nodeapi "view", then you should return it here.
* visible through node "view", then you should return it here.
*
* @param $node
* The node the action is being performed on.
* @return
* Array of additional information to be indexed.
*/
function hook_nodeapi_update_index($node) {
function hook_node_update_index($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) {
......@@ -378,7 +378,7 @@ function hook_nodeapi_update_index($node) {
* @return
* None.
*/
function hook_nodeapi_validate($node, $form) {
function hook_node_validate($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.'));
......@@ -400,7 +400,7 @@ function hook_nodeapi_validate($node, $form) {
* @return
* None.
*/
function hook_nodeapi_view($node, $teaser) {
function hook_node_view($node, $teaser) {
$node->content['my_additional_field'] = array(
'#value' => $additional_field,
'#weight' => 10,
......@@ -558,7 +558,7 @@ function hook_access($op, $node, $account) {
* None.
*
* To take action when nodes of any type are deleted (not just nodes of
* the type defined by this module), use hook_nodeapi() instead.
* the type defined by this module), use hook_node() instead.
*
* For a detailed usage example, see node_example.module.
*/
......@@ -665,7 +665,7 @@ function hook_form(&$node, $form_state) {
* None.
*
* To take action when nodes of any type are inserted (not just nodes of
* the type(s) defined by this module), use hook_nodeapi() instead.
* the type(s) defined by this module), use hook_node() instead.
*
* For a detailed usage example, see node_example.module.
*/
......@@ -709,7 +709,7 @@ function hook_load($nodes) {
* None.
*
* To take action when nodes of any type are updated (not just nodes of
* the type(s) defined by this module), use hook_nodeapi() instead.
* the type(s) defined by this module), use hook_node() instead.
*
* For a detailed usage example, see node_example.module.
*/
......@@ -733,11 +733,11 @@ function hook_update($node) {
* None.
*
* To validate nodes of all types (not just nodes of the type(s) defined by
* this module), use hook_nodeapi() instead.
* this module), use hook_node() instead.
*
* Changes made to the $node object within a hook_validate() function will
* have no effect. The preferred method to change a node's content is to use
* hook_submit() or hook_nodeapi($op='submit') instead. If it is really
* hook_submit() or hook_node($op='submit') instead. If it is really
* necessary to change the node at the validate stage, you can use function
* form_set_value().
*
......@@ -773,7 +773,7 @@ function hook_validate($node, &$form) {
* If for some reason you need to change the body or teaser returned by
* node_prepare(), you can modify $node->content['body']['#value']. Note
* that this will be the un-rendered content. To modify the rendered output,
* see hook_nodeapi($op = 'alter').