Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.977 diff -u -r1.977 node.module --- modules/node/node.module 17 Sep 2008 20:37:32 -0000 1.977 +++ modules/node/node.module 20 Sep 2008 09:13:23 -0000 @@ -79,7 +79,7 @@ case 'node/%/revisions': return '

' . t('The revisions let you track differences between multiple versions of a post.') . '

'; case 'node/%/edit': - $node = node_load($arg[1]); + $node = drupal_load('node', $arg[1]); $type = node_get_types('type', $node->type); return (!empty($type->help) ? '

' . filter_xss_admin($type->help) . '

' : ''); } @@ -691,33 +691,6 @@ } /** - * Invoke a hook_nodeapi() operation in all modules. - * - * @param &$node - * A node object. - * @param $op - * A string containing the name of the nodeapi operation. - * @param $a3, $a4 - * Arguments to pass on to the hook, after the $node and $op arguments. - * @return - * The returned value of the invoked hooks. - */ -function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { - $return = array(); - foreach (module_implements('nodeapi') as $name) { - $function = $name . '_nodeapi'; - $result = $function($node, $op, $a3, $a4); - if (isset($result) && is_array($result)) { - $return = array_merge($return, $result); - } - else if (isset($result)) { - $return[] = $result; - } - } - return $return; -} - -/** * Load a node object from the database. * * @param $param @@ -794,7 +767,7 @@ } } - if ($extra = node_invoke_nodeapi($node, 'load')) { + if ($extra = drupal_invoke_dataapi('node', 'load', $node)) { foreach ($extra as $key => $value) { $node->$key = $value; } @@ -842,7 +815,7 @@ // Do node-type-specific validation checks. node_invoke($node, 'validate', $form); - node_invoke_nodeapi($node, 'validate', $form); + drupal_invoke_dataapi('node', 'validate', $node, $form); } /** @@ -891,7 +864,7 @@ */ function node_save(&$node) { // Let modules modify the node before it is saved to the database. - node_invoke_nodeapi($node, 'presave'); + drupal_invoke_dataapi('node', 'presave', $node); global $user; $node->is_new = FALSE; @@ -966,7 +939,7 @@ // node_invoke($node, 'insert') or // node_invoke($node, 'update'). node_invoke($node, $op); - node_invoke_nodeapi($node, $op); + drupal_invoke_dataapi('node', $op, $node); // Update the node access table for this node. node_access_acquire_grants($node); @@ -998,7 +971,7 @@ */ function node_delete($nid) { - $node = node_load($nid); + $node = drupal_load('node', $nid); if (node_access('delete', $node)) { db_query('DELETE FROM {node} WHERE nid = %d', $node->nid); @@ -1006,7 +979,7 @@ // Call the node-specific callback (if any): node_invoke($node, 'delete'); - node_invoke_nodeapi($node, 'delete'); + drupal_invoke_dataapi('node', 'delete', $node); // Clear the page and block caches. cache_clear_all(); @@ -1061,7 +1034,7 @@ } // Allow modules to modify the fully-built node. - node_invoke_nodeapi($node, 'alter', $teaser, $page); + drupal_invoke_dataapi('node', 'alter', $node, $teaser, $page); return theme('node', $node, $teaser, $page); } @@ -1124,7 +1097,7 @@ } // Allow modules to make their own additions to the node. - node_invoke_nodeapi($node, 'view', $teaser, $page); + drupal_invoke_dataapi('node', 'view', $node, $teaser, $page); return $node; } @@ -1315,17 +1288,17 @@ $results = array(); foreach ($find as $item) { // Build the node body. - $node = node_load($item->sid); + $node = drupal_load('node', $item->sid); $node->build_mode = NODE_BUILD_SEARCH_RESULT; $node = node_build_content($node, FALSE, FALSE); $node->body = drupal_render($node->content); // Fetch comments for snippet. - $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index'); + $node->body .= module_invoke('comment', 'node', $node, 'update index'); // Fetch terms for snippet. - $node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index'); + $node->body .= module_invoke('taxonomy', 'node', $node, 'update index'); - $extra = node_invoke_nodeapi($node, 'search result'); + $extra = drupal_invoke_dataapi('node', 'search result', $node); $results[] = array( 'link' => url('node/' . $item->sid, array('absolute' => TRUE)), @@ -1445,7 +1418,7 @@ function _node_revision_access($node, $op = 'view') { static $access = array(); if (!isset($access[$node->vid])) { - $node_current_revision = node_load($node->nid); + $node_current_revision = drupal_load('node', $node->nid); $is_current_revision = $node_current_revision->vid == $node->vid; // There should be at least two revisions. If the vid of the given node // and the vid of the current revision differs, then we already have two @@ -1724,7 +1697,7 @@ $items = ''; foreach ($nids as $nid) { // Load the specified node: - $item = node_load($nid); + $item = drupal_load('node', $nid); $item->build_mode = NODE_BUILD_RSS; $item->link = url("node/$nid", array('absolute' => TRUE)); @@ -1740,11 +1713,11 @@ } // Allow modules to change $node->teaser before viewing. - node_invoke_nodeapi($item, 'view', $teaser, FALSE); + drupal_invoke_dataapi('node', 'view', $item, $teaser, FALSE); } // Allow modules to add additional item fields and/or modify $item - $extra = node_invoke_nodeapi($item, 'rss item'); + $extra = drupal_invoke_dataapi('node', 'rss item', $item); $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => gmdate('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false')))); foreach ($extra as $element) { if (isset($element['namespace'])) { @@ -1798,7 +1771,7 @@ $output = ''; $num_rows = FALSE; while ($node = db_fetch_object($result)) { - $output .= node_view(node_load($node->nid), 1); + $output .= node_view(drupal_load('node', $node->nid), 1); $num_rows = TRUE; } @@ -1857,7 +1830,7 @@ * The node to index. */ function _node_index_node($node) { - $node = node_load($node->nid); + $node = drupal_load('node', $node->nid); // save the changed time of the most recent indexed node, for the search results half-life calculation variable_set('node_cron_last', $node->changed); @@ -1870,7 +1843,7 @@ $text = '

' . check_plain($node->title) . '

' . $node->body; // Fetch extra data normally not visible - $extra = node_invoke_nodeapi($node, 'update index'); + $extra = drupal_invoke_dataapi('node', 'update index', $node); foreach ($extra as $t) { $text .= $t; } @@ -2420,7 +2393,7 @@ } $result = db_query("SELECT nid FROM {node}"); while ($node = db_fetch_object($result)) { - $loaded_node = node_load($node->nid, NULL, TRUE); + $loaded_node = drupal_load('node', $node->nid, NULL, TRUE); // To preserve database integrity, only aquire grants if the node // loads successfully. if (!empty($loaded_node)) { @@ -2460,7 +2433,7 @@ $limit = 20; $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit); while ($row = db_fetch_array($result)) { - $loaded_node = node_load($row['nid'], NULL, TRUE); + $loaded_node = drupal_load('node', $row['nid'], NULL, TRUE); // To preserve database integrity, only aquire grants if the node // loads successfully. if (!empty($loaded_node)) { @@ -2586,7 +2559,7 @@ function node_hook_info() { return array( 'node' => array( - 'nodeapi' => array( + 'node' => array( 'presave' => array( 'runs when' => t('When either saving a new post or updating an existing post'), ), @@ -2618,7 +2591,7 @@ 'configurable' => FALSE, 'behavior' => array('changes_node_property'), 'hooks' => array( - 'nodeapi' => array('presave'), + 'node' => array('presave'), 'comment' => array('insert', 'update'), ), ), @@ -2648,7 +2621,7 @@ 'configurable' => FALSE, 'behavior' => array('changes_node_property'), 'hooks' => array( - 'nodeapi' => array('presave'), + 'node' => array('presave'), 'comment' => array('delete', 'insert', 'update'), ), ), @@ -2658,7 +2631,7 @@ 'configurable' => FALSE, 'behavior' => array('changes_node_property'), 'hooks' => array( - 'nodeapi' => array('presave'), + 'node' => array('presave'), 'comment' => array('insert', 'update'), ), ), @@ -2668,7 +2641,7 @@ 'configurable' => FALSE, 'behavior' => array('changes_node_property'), 'hooks' => array( - 'nodeapi' => array('presave'), + 'node' => array('presave'), 'comment' => array('delete', 'insert', 'update'), ), ), @@ -2679,7 +2652,7 @@ 'behavior' => array('changes_node_property'), 'hooks' => array( 'any' => TRUE, - 'nodeapi' => array('presave'), + 'node' => array('presave'), 'comment' => array('delete', 'insert', 'update'), ), ), @@ -2696,7 +2669,7 @@ 'description' => t('Unpublish post containing keyword(s)'), 'configurable' => TRUE, 'hooks' => array( - 'nodeapi' => array('presave', 'insert', 'update'), + 'node' => array('presave', 'insert', 'update'), ), ), ); Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.37 diff -u -r1.37 node.pages.inc --- modules/node/node.pages.inc 19 Sep 2008 07:39:00 -0000 1.37 +++ modules/node/node.pages.inc 20 Sep 2008 09:13:23 -0000 @@ -89,7 +89,7 @@ $node->revision = in_array('revision', $node_options); node_invoke($node, 'prepare'); - node_invoke_nodeapi($node, 'prepare'); + drupal_invoke_dataapi('node', 'prepare', $node); } /** @@ -576,7 +576,7 @@ function node_revision_delete_confirm_submit($form, &$form_state) { $node_revision = $form['#node_revision']; db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $node_revision->nid, $node_revision->vid); - node_invoke_nodeapi($node_revision, 'delete revision'); + drupal_invoke_dataapi('node', 'delete revision', $node_revision); watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid)); drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_get_types('name', $node_revision), '%title' => $node_revision->title))); $form_state['redirect'] = 'node/' . $node_revision->nid; Index: modules/node/node.test =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.test,v retrieving revision 1.6 diff -u -r1.6 node.test --- modules/node/node.test 17 Sep 2008 05:26:51 -0000 1.6 +++ modules/node/node.test 20 Sep 2008 09:13:24 -0000 @@ -45,7 +45,7 @@ // Create revision with random title and body and update variables. $this->drupalCreateNode($settings); - $node = node_load($node->nid); // Make sure we get revision information. + $node = drupal_load('node', $node->nid); // Make sure we get revision information. $settings = get_object_vars($node); $nodes[] = $node; @@ -273,7 +273,7 @@ $this->drupalPost('node/add/page', $edit, t('Save')); // Check that the node exists in the database. - $node = node_load(array('title' => $edit['title'])); + $node = drupal_load('node', array('title' => $edit['title'])); $this->assertTrue($node, t('Node found in database.')); // Check that "edit" link points to correct page. @@ -379,7 +379,7 @@ $this->assertRaw(t('!post %title has been created.', array('!post' => 'Page', '%title' => $edit['title'])), t('Page created.')); // Check that the node exists in the database. - $node = node_load(array('title' => $edit['title'])); + $node = drupal_load('node', array('title' => $edit['title'])); $this->assertTrue($node, t('Node found in database.')); } } @@ -402,7 +402,7 @@ function testPageView() { // Create a node to view. $node = $this->drupalCreateNode(); - $this->assertTrue(node_load($node->nid), t('Node created.')); + $this->assertTrue(drupal_load('node', $node->nid), t('Node created.')); // Try to edit with anonymous user. $html = $this->drupalGet("node/$node->nid/edit"); Index: modules/statistics/statistics.module =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v retrieving revision 1.283 diff -u -r1.283 statistics.module --- modules/statistics/statistics.module 17 Sep 2008 07:11:58 -0000 1.283 +++ modules/statistics/statistics.module 20 Sep 2008 09:13:24 -0000 @@ -319,9 +319,9 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). */ -function statistics_nodeapi(&$node, $op, $arg = 0) { +function statistics_node($op, &$node, $arg = 0) { switch ($op) { case 'delete': // clean up statistics table when node is deleted Index: modules/statistics/statistics.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.pages.inc,v retrieving revision 1.3 diff -u -r1.3 statistics.pages.inc --- modules/statistics/statistics.pages.inc 14 Apr 2008 17:48:41 -0000 1.3 +++ modules/statistics/statistics.pages.inc 20 Sep 2008 09:13:24 -0000 @@ -7,7 +7,7 @@ */ function statistics_node_tracker() { - if ($node = node_load(arg(1))) { + if ($node = drupal_load('node', arg(1))) { $header = array( array('data' => t('Time'), 'field' => 'a.timestamp', 'sort' => 'desc'), Index: modules/forum/forum.module =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v retrieving revision 1.464 diff -u -r1.464 forum.module --- modules/forum/forum.module 19 Sep 2008 20:25:02 -0000 1.464 +++ modules/forum/forum.module 20 Sep 2008 09:13:23 -0000 @@ -156,15 +156,15 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). */ -function forum_nodeapi(&$node, $op, $teaser, $page) { +function forum_node($op, &$node, $teaser, $page) { // 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 // be assigned to $node->type, so return to avoid E_ALL warnings. $vid = variable_get('forum_nav_vocabulary', ''); - $vocabulary = taxonomy_vocabulary_load($vid); + $vocabulary = drupal_load('vocabulary', $vid); if (empty($vocabulary)) { return; } @@ -636,7 +636,7 @@ global $user; $vid = variable_get('forum_nav_vocabulary', ''); - $vocabulary = taxonomy_vocabulary_load($vid); + $vocabulary = drupal_load('vocabulary', $vid); $title = !empty($vocabulary->name) ? $vocabulary->name : ''; // Breadcrumb navigation: Index: modules/forum/forum.install =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v retrieving revision 1.19 diff -u -r1.19 forum.install --- modules/forum/forum.install 25 Jun 2008 07:47:20 -0000 1.19 +++ modules/forum/forum.install 20 Sep 2008 09:13:23 -0000 @@ -12,7 +12,7 @@ } function forum_enable() { - if ($vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0))) { + if ($vocabulary = drupal_load('vocabulary', variable_get('forum_nav_vocabulary', 0))) { // Existing install. Add back forum node type, if the forums // vocabulary still exists. Keep all other node types intact there. $vocabulary = (array) $vocabulary; @@ -44,7 +44,7 @@ */ function forum_uninstall() { // Load the dependent Taxonomy module, in case it has been disabled. - drupal_load('module', 'taxonomy'); + drupal_load_file('module', 'taxonomy'); // Delete the vocabulary. $vid = variable_get('forum_nav_vocabulary', ''); Index: modules/forum/forum.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.admin.inc,v retrieving revision 1.13 diff -u -r1.13 forum.admin.inc --- modules/forum/forum.admin.inc 19 Sep 2008 20:25:02 -0000 1.13 +++ modules/forum/forum.admin.inc 20 Sep 2008 09:13:23 -0000 @@ -79,7 +79,7 @@ $type = t('forum'); } - $status = taxonomy_save_term($form_state['values']); + $status = drupal_save('term', $form_state['values']); switch ($status) { case SAVED_NEW: if ($container) { @@ -172,7 +172,7 @@ * Implementation of forms api _submit call. Deletes a forum after confirmation. */ function forum_confirm_delete_submit($form, &$form_state) { - taxonomy_del_term($form_state['values']['tid']); + drupal_delete('term', $form_state['values']['tid']); drupal_set_message(t('The forum %term and all sub-forums have been deleted.', array('%term' => $form_state['values']['name']))); watchdog('content', 'forum: deleted %term and all its sub-forums.', array('%term' => $form_state['values']['name'])); @@ -218,7 +218,7 @@ module_load_include('inc', 'taxonomy', 'taxonomy.admin'); $vid = variable_get('forum_nav_vocabulary', ''); - $vocabulary = taxonomy_vocabulary_load($vid); + $vocabulary = drupal_load('vocabulary', $vid); $form = taxonomy_overview_terms($form_state, $vocabulary); drupal_set_title('Forums'); Index: modules/poll/poll.test =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.test,v retrieving revision 1.5 diff -u -r1.5 poll.test --- modules/poll/poll.test 5 Aug 2008 18:07:14 -0000 1.5 +++ modules/poll/poll.test 20 Sep 2008 09:13:24 -0000 @@ -40,7 +40,7 @@ } $this->drupalPost(NULL, $edit, t('Save')); - $node = node_load(array('title' => $title)); + $node = drupal_load('node', array('title' => $title)); $this->assertRaw(t('@type %title has been created.', array('@type' => node_get_types('name', 'poll'), '%title' => $title)), 'Poll has been created.'); $this->assertTrue($node->nid, t('Poll has been found in the database')); Index: modules/poll/poll.module =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v retrieving revision 1.272 diff -u -r1.272 poll.module --- modules/poll/poll.module 17 Sep 2008 07:11:57 -0000 1.272 +++ modules/poll/poll.module 20 Sep 2008 09:13:24 -0000 @@ -142,7 +142,7 @@ $sql = db_rewrite_sql("SELECT MAX(n.created) FROM {node} n INNER JOIN {poll} p ON p.nid = n.nid WHERE n.status = 1 AND p.active = 1"); $timestamp = db_result(db_query($sql)); if ($timestamp) { - $poll = node_load(array('type' => 'poll', 'created' => $timestamp, 'status' => 1)); + $poll = drupal_load('node', array('type' => 'poll', 'created' => $timestamp, 'status' => 1)); if ($poll->nid) { $poll = poll_view($poll, TRUE, FALSE, TRUE); @@ -808,7 +808,7 @@ * Submit callback for poll_cancel_form */ function poll_cancel($form, &$form_state) { - $node = node_load($form['#nid']); + $node = drupal_load('node', $form['#nid']); global $user; if ($user->uid) { Index: modules/search/search.module =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.module,v retrieving revision 1.266 diff -u -r1.266 search.module --- modules/search/search.module 17 Sep 2008 20:37:32 -0000 1.266 +++ modules/search/search.module 20 Sep 2008 09:13:24 -0000 @@ -626,9 +626,9 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). */ -function search_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { +function search_node($op, &$node, $teaser = NULL, $page = NULL) { switch ($op) { // Transplant links to a node into the target node. case 'update index': @@ -985,10 +985,10 @@ * for all of the search features to work. * * There are three ways to interact with the search system: - * - Specifically for searching nodes, you can implement nodeapi('update index') - * and nodeapi('search result'). However, note that the search system already + * - Specifically for searching nodes, you can implement node('update index') + * and node('search result'). However, note that the search system already * indexes all visible output of a node, i.e. everything displayed normally - * by hook_view() and hook_nodeapi('view'). This is usually sufficient. + * by hook_view() and hook_node('view'). This is usually sufficient. * You should only use this mechanism if you want additional, non-visible data * to be indexed. * - Implement hook_search(). This will create a search tab for your module on Index: modules/menu/menu.test =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.test,v retrieving revision 1.2 diff -u -r1.2 menu.test --- modules/menu/menu.test 30 May 2008 07:30:51 -0000 1.2 +++ modules/menu/menu.test 20 Sep 2008 09:13:23 -0000 @@ -47,7 +47,7 @@ $this->drupalLogin($this->std_user); $this->verifyAccess(403); foreach ($this->items as $item) { - $node = node_load(substr($item['link_path'], 5)); // Paths were set as 'node/$nid'. + $node = drupal_load('node', substr($item['link_path'], 5)); // Paths were set as 'node/$nid'. $this->verifyMenuItem($item, $node); } Index: modules/menu/menu.module =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v retrieving revision 1.168 diff -u -r1.168 menu.module --- modules/menu/menu.module 15 Sep 2008 20:48:08 -0000 1.168 +++ modules/menu/menu.module 20 Sep 2008 09:13:23 -0000 @@ -277,9 +277,9 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). */ -function menu_nodeapi(&$node, $op) { +function menu_node($op, &$node) { switch ($op) { case 'insert': case 'update': Index: modules/comment/comment.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.admin.inc,v retrieving revision 1.10 diff -u -r1.10 comment.admin.inc --- modules/comment/comment.admin.inc 16 Jul 2008 21:59:26 -0000 1.10 +++ modules/comment/comment.admin.inc 20 Sep 2008 09:13:23 -0000 @@ -129,10 +129,10 @@ if ($value) { // Perform the update action, then refresh node statistics. db_query($query, $cid); - $comment = comment_load($cid); + $comment = drupal_load('comment', $cid); _comment_update_node_statistics($comment->nid); // Allow modules to respond to the updating of a comment. - comment_invoke_comment($comment, $form_state['values']['operation']); + drupal_invoke_dataapi('comment', $form_state['values']['operation'], $comment); // Add an entry to the watchdog log. watchdog('content', 'Comment: updated %subject.', array('%subject' => $comment->subject), WATCHDOG_NOTICE, l(t('view'), 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid))); } @@ -199,7 +199,7 @@ // array_filter() returns only elements with actual values. $comment_counter = 0; foreach (array_filter($edit['comments']) as $cid => $value) { - $comment = comment_load($cid); + $comment = drupal_load('comment', $cid); if (is_object($comment) && is_numeric($comment->cid)) { $subject = db_result(db_query('SELECT subject FROM {comments} WHERE cid = %d', $cid)); $form['comments'][$cid] = array('#type' => 'hidden', '#value' => $cid, '#prefix' => '
  • ', '#suffix' => check_plain($subject) . '
  • '); @@ -226,9 +226,9 @@ function comment_multiple_delete_confirm_submit($form, &$form_state) { if ($form_state['values']['confirm']) { foreach ($form_state['values']['comments'] as $cid => $value) { - $comment = comment_load($cid); + $comment = drupal_load('comment', $cid); // Perform the actual comment deletion. - _comment_delete_thread($comment); + drupal_load('comment', $comment); _comment_update_node_statistics($comment->nid); } cache_clear_all(); @@ -243,7 +243,7 @@ * @param $cid * The comment to be deleted. */ -function comment_delete($cid = NULL) { +function comment_process_delete($cid = NULL) { $comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = %d', $cid)); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; $output = ''; @@ -284,36 +284,10 @@ drupal_set_message(t('The comment and all its replies have been deleted.')); $comment = $form['#comment']; // Delete the comment and its replies. - _comment_delete_thread($comment); + drupal_load('comment', $comment); _comment_update_node_statistics($comment->nid); // Clear the cache so an anonymous user sees that his comment was deleted. cache_clear_all(); $form_state['redirect'] = "node/$comment->nid"; } - -/** - * Perform the actual deletion of a comment and all its replies. - * - * @param $comment - * An associative array describing the comment to be deleted. - */ -function _comment_delete_thread($comment) { - if (!is_object($comment) || !is_numeric($comment->cid)) { - watchdog('content', 'Cannot delete non-existent comment.', array(), WATCHDOG_WARNING); - - return; - } - - // Delete the comment. - db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid); - watchdog('content', 'Comment: deleted %subject.', array('%subject' => $comment->subject)); - comment_invoke_comment($comment, 'delete'); - - // Delete the comment's replies. - $result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE pid = %d', $comment->cid); - while ($comment = db_fetch_object($result)) { - $comment->name = $comment->uid ? $comment->registered_name : $comment->name; - _comment_delete_thread($comment); - } -} Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.650 diff -u -r1.650 comment.module --- modules/comment/comment.module 17 Sep 2008 20:37:31 -0000 1.650 +++ modules/comment/comment.module 20 Sep 2008 09:13:23 -0000 @@ -184,7 +184,7 @@ ); $items['comment/delete'] = array( 'title' => 'Delete comment', - 'page callback' => 'comment_delete', + 'page callback' => 'comment_process_delete', 'access arguments' => array('administer comments'), 'type' => MENU_CALLBACK, ); @@ -554,9 +554,9 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). */ -function comment_nodeapi(&$node, $op, $arg = 0) { +function comment_node($op, &$node, $arg = 0) { switch ($op) { case 'load': if ($node->comment != COMMENT_NODE_DISABLED) { @@ -648,13 +648,9 @@ * Accepts a submission of new or changed comment content. * * @param $edit - * A comment array. - * - * @return - * If the comment is successfully saved the comment ID is returned. If the comment - * is not saved, FALSE is returned. + * A comment object. */ -function comment_save($edit) { +function comment_save(&$edit) { global $user; if (user_access('post comments') && (user_access('administer comments') || node_comment_mode($edit['nid']) == COMMENT_NODE_READ_WRITE)) { if (!form_get_errors()) { @@ -665,14 +661,17 @@ 'status' => user_access('post comments without approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED, ); if ($edit['cid']) { + $status = SAVED_UPDATED; + // Update the comment in the database. db_query("UPDATE {comments} SET status = %d, timestamp = %d, subject = '%s', comment = '%s', format = %d, uid = %d, name = '%s', mail = '%s', homepage = '%s' WHERE cid = %d", $edit['status'], $edit['timestamp'], $edit['subject'], $edit['comment'], $edit['format'], $edit['uid'], $edit['name'], $edit['mail'], $edit['homepage'], $edit['cid']); // Allow modules to respond to the updating of a comment. - comment_invoke_comment($edit, 'update'); + drupal_invoke_dataapi('comment', 'update', $edit); // Add an entry to the watchdog log. watchdog('content', 'Comment: updated %subject.', array('%subject' => $edit['subject']), WATCHDOG_NOTICE, l(t('view'), 'node/' . $edit['nid'], array('fragment' => 'comment-' . $edit['cid']))); } else { + $status = SAVED_NEW; // Add the comment to database. This next section builds the thread field. // Also see the documentation for comment_render(). if ($edit['pid'] == 0) { @@ -689,7 +688,7 @@ // the part of the thread value at the proper depth. // Get the parent comment: - $parent = comment_load($edit['pid']); + $parent = drupal_load('comment', $edit['pid']); // Strip the "/" from the end of the parent thread. $parent->thread = (string) rtrim((string) $parent->thread, '/'); // Get the max value in *this* thread. @@ -722,7 +721,7 @@ db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], ip_address(), $edit['timestamp'], $edit['status'], $thread, $edit['name'], $edit['mail'], $edit['homepage']); $edit['cid'] = db_last_insert_id('comments', 'cid'); // Tell the other modules a new comment has been submitted. - comment_invoke_comment($edit, 'insert'); + drupal_invoke_dataapi('comment', 'insert', $edit); // Add an entry to the watchdog log. watchdog('content', 'Comment: added %subject.', array('%subject' => $edit['subject']), WATCHDOG_NOTICE, l(t('view'), 'node/' . $edit['nid'], array('fragment' => 'comment-' . $edit['cid']))); } @@ -737,10 +736,10 @@ } else { drupal_set_message(t('Your comment has been posted.')); - comment_invoke_comment($edit, 'publish'); + drupal_invoke_dataapi('comment', 'publish', $edit); } - return $edit['cid']; + return $status; } else { return FALSE; @@ -811,7 +810,7 @@ ); } else { - $node = node_load($comment->nid); + $node = drupal_load('node', $comment->nid); $links['comment_forbidden']['title'] = theme('comment_post_forbidden', $node); } } @@ -1045,6 +1044,33 @@ } /** + * Perform the actual deletion of a comment and all its replies. + * + * @param $comment + * An associative array describing the comment to be deleted. + */ +function comment_delete($comment) { + if (!is_object($comment) || !is_numeric($comment->cid)) { + watchdog('content', 'Cannot delete non-existent comment.', array(), WATCHDOG_WARNING); + + return; + } + + // Delete the comment. + db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid); + watchdog('content', 'Comment: deleted %subject.', array('%subject' => $comment->subject)); + drupal_invoke_dataapi('comment', 'delete', $comment); + + // Delete the comment's replies. + $result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE pid = %d', $comment->cid); + while ($comment = db_fetch_object($result)) { + $comment->name = $comment->uid ? $comment->registered_name : $comment->name; + drupal_delete('comment', $comment); + } + return SAVED_DELETED; +} + +/** * Get replies count for a comment. * * @param $pid @@ -1105,7 +1131,7 @@ global $user; // Invoke other validation handlers. - comment_invoke_comment($edit, 'validate'); + drupal_invoke_dataapi('comment', 'validate', $edit); if (isset($edit['date'])) { // As of PHP 5.1.0, strtotime returns FALSE upon failure instead of -1. @@ -1119,7 +1145,7 @@ // Check validity of name, mail and homepage (if given). if (!$user->uid || isset($edit['is_anonymous'])) { - $node = node_load($edit['nid']); + $node = drupal_load('node', $edit['nid']); if (variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) > COMMENT_ANONYMOUS_MAYNOT_CONTACT) { if ($edit['name']) { $taken = db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE LOWER(name) = '%s'", $edit['name'])); @@ -1163,7 +1189,7 @@ function comment_form(&$form_state, $edit, $title = NULL) { global $user; $op = isset($_POST['op']) ? $_POST['op'] : ''; - $node = node_load($edit['nid']); + $node = drupal_load('node', $edit['nid']); if (!$user->uid && variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) != COMMENT_ANONYMOUS_MAYNOT_CONTACT) { drupal_add_js(drupal_get_path('module', 'comment') . '/comment.js'); @@ -1421,7 +1447,7 @@ $edit = $form_state['values']; drupal_set_title(t('Preview comment')); $output = ''; - $node = node_load($edit['nid']); + $node = drupal_load('node', $edit['nid']); // Invoke full validation for the form, to protect against cross site // request forgeries (CSRF) and setting arbitrary values for fields such as @@ -1537,11 +1563,10 @@ */ function comment_form_submit($form, &$form_state) { _comment_form_submit($form_state['values']); - if ($cid = comment_save($form_state['values'])) { - $node = node_load($form_state['values']['nid']); + if (drupal_save('comment', $form_state['values'])) { + $node = drupal_load('node', $form_state['values']['nid']); $page = comment_new_page_count($node->comment_count, 1, $node); - $form_state['redirect'] = array('node/' . $node->nid, $page, "comment-$cid"); - + $form_state['redirect'] = array('node/' . $node->nid, $page, 'comment-' . $form_state['values']['cid']); return; } } @@ -1577,7 +1602,7 @@ if ($visible) { $comment->comment = check_markup($comment->comment, $comment->format, FALSE); // Comment API hook. - comment_invoke_comment($comment, 'view'); + drupal_invoke_dataapi('comment', 'view', $comment); $output .= theme('comment', $comment, $node, $links); } else { @@ -1818,32 +1843,6 @@ } /** - * Invoke a hook_comment() operation in all modules. - * - * @param &$comment - * A comment object. - * @param $op - * A string containing the name of the comment operation. - * @return - * The returned value of the invoked hooks. - */ -function comment_invoke_comment(&$comment, $op) { - $return = array(); - foreach (module_implements('comment') as $name) { - $function = $name . '_comment'; - $result = $function($comment, $op); - if (isset($result) && is_array($result)) { - $return = array_merge($return, $result); - } - elseif (isset($result)) { - $return[] = $result; - } - } - - return $return; -} - -/** * Generate vancode. * * Consists of a leading character indicating length, followed by N digits Index: modules/comment/comment.install =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v retrieving revision 1.26 diff -u -r1.26 comment.install --- modules/comment/comment.install 17 Sep 2008 07:11:56 -0000 1.26 +++ modules/comment/comment.install 20 Sep 2008 09:13:23 -0000 @@ -43,7 +43,7 @@ function comment_update_6002() { // Comment module might not be enabled when this is run, but we need the // constants defined by the module for this update. - drupal_load('module', 'comment'); + drupal_load_file('module', 'comment'); $settings = array( 'comment_default_mode' => COMMENT_MODE_THREADED_EXPANDED, 'comment_default_order' => COMMENT_ORDER_NEWEST_FIRST, Index: modules/comment/comment.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.pages.inc,v retrieving revision 1.6 diff -u -r1.6 comment.pages.inc --- modules/comment/comment.pages.inc 24 Jun 2008 17:01:33 -0000 1.6 +++ modules/comment/comment.pages.inc 20 Sep 2008 09:13:23 -0000 @@ -121,7 +121,7 @@ */ function comment_approve($cid) { // Load the comment whose cid = $cid - if ($comment = comment_load($cid)) { + if ($comment = drupal_load('comment', $cid)) { $operations = comment_operations('publish'); db_query($operations['publish'][1], $cid); Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.145 diff -u -r1.145 path.module --- modules/path/path.module 17 Sep 2008 20:37:32 -0000 1.145 +++ modules/path/path.module 20 Sep 2008 09:13:24 -0000 @@ -119,12 +119,12 @@ /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). * * Allows URL aliases for nodes to be specified at node edit time rather * than through the administrative interface. */ -function path_nodeapi(&$node, $op, $arg) { +function path_node($op, &$node, $arg) { // Permissions are required for everything except node loading. if (user_access('create url aliases') || user_access('administer url aliases') || ($op == 'load')) { $language = isset($node->language) ? $node->language : ''; Index: modules/path/path.test =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.test,v retrieving revision 1.3 diff -u -r1.3 path.test --- modules/path/path.test 21 Aug 2008 19:36:37 -0000 1.3 +++ modules/path/path.test 20 Sep 2008 09:13:24 -0000 @@ -131,7 +131,7 @@ $this->drupalPost('node/add/page', $edit, t('Save')); // Check to make sure the node was created. - $node = node_load(array('title' => $edit['title'])); + $node = drupal_load('node', array('title' => $edit['title'])); $this->assertNotNull(($node === FALSE ? NULL : $node), 'Node found in database. %s'); Index: modules/blogapi/blogapi.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blogapi/blogapi.module,v retrieving revision 1.126 diff -u -r1.126 blogapi.module --- modules/blogapi/blogapi.module 17 Sep 2008 21:07:47 -0000 1.126 +++ modules/blogapi/blogapi.module 20 Sep 2008 09:13:23 -0000 @@ -221,7 +221,7 @@ $edit['date'] = format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O'); } - node_invoke_nodeapi($edit, 'blogapi new'); + drupal_invoke_dataapi('node', 'blogapi new', $edit); node_validate($edit); if ($errors = form_get_errors()) { @@ -249,7 +249,7 @@ return blogapi_error($user); } - $node = node_load($postid); + $node = drupal_load('node', $postid); if (!$node) { return blogapi_error(t('n/a')); } @@ -273,7 +273,7 @@ $node->body = $content; } - node_invoke_nodeapi($node, 'blogapi edit'); + drupal_invoke_dataapi('node', 'blogapi edit', $node); node_validate($node); if ($errors = form_get_errors()) { @@ -302,7 +302,7 @@ return blogapi_error($user); } - $node = node_load($postid); + $node = drupal_load('node', $postid); return _blogapi_get_post($node, TRUE); } @@ -447,7 +447,7 @@ return blogapi_error($user); } - $node = node_load($postid); + $node = drupal_load('node', $postid); $terms = module_invoke('taxonomy', 'node_get_terms', $node, 'tid'); $categories = array(); foreach ($terms as $term) { @@ -470,7 +470,7 @@ return blogapi_error($user); } - $node = node_load($postid); + $node = drupal_load('node', $postid); $node->taxonomy = array(); foreach ($categories as $category) { $node->taxonomy[] = $category['categoryId']; @@ -507,7 +507,7 @@ if (!$user->uid) { return blogapi_error($user); } - $node = node_load($postid); + $node = drupal_load('node', $postid); if (!$node) { return blogapi_error(t('Invalid post.')); Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.289 diff -u -r1.289 menu.inc --- includes/menu.inc 18 Sep 2008 10:44:19 -0000 1.289 +++ includes/menu.inc 20 Sep 2008 09:13:23 -0000 @@ -577,7 +577,7 @@ * * When a user arrives on a page such as node/5, this function determines * what "5" corresponds to, by inspecting the page's menu path definition, - * node/%node. This will call node_load(5) to load the corresponding node + * node/%node. This will call drupal_load('node', 5) to load the corresponding node * object. * * It also works in reverse, to allow the display of tabs and menu items which Index: includes/theme.maintenance.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.maintenance.inc,v retrieving revision 1.17 diff -u -r1.17 theme.maintenance.inc --- includes/theme.maintenance.inc 19 Sep 2008 07:53:59 -0000 1.17 +++ includes/theme.maintenance.inc 20 Sep 2008 09:13:23 -0000 @@ -40,8 +40,8 @@ $module_list['system']['filename'] = 'modules/system/system.module'; $module_list['filter']['filename'] = 'modules/filter/filter.module'; module_list(TRUE, FALSE, FALSE, $module_list); - drupal_load('module', 'system'); - drupal_load('module', 'filter'); + drupal_load_file('module', 'system'); + drupal_load_file('module', 'filter'); $theme = variable_get('maintenance_theme', 'minnelli'); } Index: includes/actions.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/actions.inc,v retrieving revision 1.17 diff -u -r1.17 actions.inc --- includes/actions.inc 15 Sep 2008 16:07:47 -0000 1.17 +++ includes/actions.inc 20 Sep 2008 09:13:23 -0000 @@ -115,7 +115,7 @@ * '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'), * ) * ) @@ -143,7 +143,7 @@ * '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'), * ), * ); Index: includes/module.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/module.inc,v retrieving revision 1.125 diff -u -r1.125 module.inc --- includes/module.inc 20 Sep 2008 03:49:23 -0000 1.125 +++ includes/module.inc 20 Sep 2008 09:13:23 -0000 @@ -11,7 +11,7 @@ */ function module_load_all() { foreach (module_list(TRUE, FALSE) as $module) { - drupal_load('module', $module); + drupal_load_file('module', $module); } } @@ -277,7 +277,7 @@ if ($existing->status == 0) { module_load_install($module); db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 1, 'module', $module); - drupal_load('module', $module); + drupal_load_file('module', $module); $invoke_modules[] = $module; } } Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.798 diff -u -r1.798 common.inc --- includes/common.inc 20 Sep 2008 03:49:23 -0000 1.798 +++ includes/common.inc 20 Sep 2008 09:13:23 -0000 @@ -2512,7 +2512,9 @@ require_once './includes/image.inc'; require_once './includes/form.inc'; require_once './includes/mail.inc'; + require_once './includes/dataapi.inc'; require_once './includes/actions.inc'; + // Set the Drupal custom error handler. set_error_handler('drupal_error_handler'); // Emit the correct charset HTTP header. Index: includes/install.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/install.inc,v retrieving revision 1.69 diff -u -r1.69 install.inc --- includes/install.inc 20 Sep 2008 03:49:23 -0000 1.69 +++ includes/install.inc 20 Sep 2008 09:13:23 -0000 @@ -560,7 +560,7 @@ */ function drupal_uninstall_module($module) { // First, retrieve all the module's menu paths from db. - drupal_load('module', $module); + drupal_load_file('module', $module); $paths = module_invoke($module, 'menu'); // Uninstall the module(s). Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.227 diff -u -r1.227 bootstrap.inc --- includes/bootstrap.inc 19 Sep 2008 07:53:59 -0000 1.227 +++ includes/bootstrap.inc 20 Sep 2008 09:13:23 -0000 @@ -592,7 +592,7 @@ * @return * TRUE if the item is loaded or has already been loaded. */ -function drupal_load($type, $name) { +function drupal_load_file($type, $name) { static $files = array(); if (isset($files[$type][$name])) { Index: update.php =================================================================== RCS file: /cvs/drupal/drupal/update.php,v retrieving revision 1.259 diff -u -r1.259 update.php --- update.php 19 Sep 2008 07:17:58 -0000 1.259 +++ update.php 20 Sep 2008 09:13:23 -0000 @@ -625,8 +625,8 @@ $module_list['system']['filename'] = 'modules/system/system.module'; $module_list['filter']['filename'] = 'modules/filter/filter.module'; module_list(TRUE, FALSE, FALSE, $module_list); - drupal_load('module', 'system'); - drupal_load('module', 'filter'); + drupal_load_file('module', 'system'); + drupal_load_file('module', 'filter'); // Set up $language, since the installer components require it. drupal_init_language(); Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.132 diff -u -r1.132 install.php --- install.php 20 Sep 2008 03:49:23 -0000 1.132 +++ install.php 20 Sep 2008 09:13:23 -0000 @@ -48,8 +48,8 @@ $module_list['system']['filename'] = 'modules/system/system.module'; $module_list['filter']['filename'] = 'modules/filter/filter.module'; module_list(TRUE, FALSE, FALSE, $module_list); - drupal_load('module', 'system'); - drupal_load('module', 'filter'); + drupal_load_file('module', 'system'); + drupal_load_file('module', 'filter'); // Set up theme system for the maintenance page. drupal_maintenance_theme(); Index: modules/book/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.module,v retrieving revision 1.468 diff -u -r1.468 book.module --- modules/book/book.module 17 Sep 2008 20:37:31 -0000 1.468 +++ modules/book/book.module 20 Sep 2008 09:13:23 -0000 @@ -668,12 +668,12 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). * * Appends book navigation to all nodes in the book, and handles book outline * insertions and updates via the node form. */ -function book_nodeapi(&$node, $op, $teaser, $page) { +function book_node($op, &$node, $teaser, $page) { switch ($op) { case 'load': // Note - we cannot use book_link_load() because it will call node_load(). Index: modules/taxonomy/taxonomy.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v retrieving revision 1.15 diff -u -r1.15 taxonomy.pages.inc --- modules/taxonomy/taxonomy.pages.inc 19 Sep 2008 20:25:03 -0000 1.15 +++ modules/taxonomy/taxonomy.pages.inc 20 Sep 2008 09:13:24 -0000 @@ -113,7 +113,7 @@ function taxonomy_term_edit($term) { if (isset($term)) { drupal_set_title(check_plain($term->name)); - return drupal_get_form('taxonomy_form_term', taxonomy_vocabulary_load($term->vid), (array)$term); + return drupal_get_form('taxonomy_form_term', drupal_load('vocabulary', $term->vid), (array)$term); } return drupal_not_found(); } Index: modules/taxonomy/taxonomy.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v retrieving revision 1.29 diff -u -r1.29 taxonomy.admin.inc --- modules/taxonomy/taxonomy.admin.inc 19 Sep 2008 20:25:03 -0000 1.29 +++ modules/taxonomy/taxonomy.admin.inc 20 Sep 2008 09:13:24 -0000 @@ -513,7 +513,7 @@ // Save all updated terms. foreach ($changed_terms as $term) { - taxonomy_save_term($term); + drupal_save('term', $term); } // Update the vocabulary hierarchy to flat or single hierarchy. @@ -747,7 +747,7 @@ return; } - switch (taxonomy_save_term($form_state['values'])) { + switch (drupal_save('term', $form_state['values'])) { case SAVED_NEW: drupal_set_message(t('Created new term %term.', array('%term' => $form_state['values']['name']))); watchdog('taxonomy', 'Created new term %term.', array('%term' => $form_state['values']['name']), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $form_state['values']['tid'] . '/edit')); @@ -833,7 +833,7 @@ * @see taxonomy_term_confirm_delete() */ function taxonomy_term_confirm_delete_submit($form, &$form_state) { - taxonomy_del_term($form_state['values']['tid']); + drupal_delete('term', $form_state['values']['tid']); taxonomy_check_vocabulary_hierarchy($form['#vocabulary'], $form_state['values']); drupal_set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name']))); watchdog('taxonomy', 'Deleted term %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE); @@ -848,7 +848,7 @@ * @see taxonomy_vocabulary_confirm_delete_submit() */ function taxonomy_vocabulary_confirm_delete(&$form_state, $vid) { - $vocabulary = taxonomy_vocabulary_load($vid); + $vocabulary = drupal_load('vocabulary', $vid); $form['#id'] = 'taxonomy_vocabulary_confirm_delete'; $form['type'] = array('#type' => 'value', '#value' => 'vocabulary'); @@ -884,7 +884,7 @@ * @see taxonomy_vocabulary_confirm_reset_alphabetical_submit() */ function taxonomy_vocabulary_confirm_reset_alphabetical(&$form_state, $vid) { - $vocabulary = taxonomy_vocabulary_load($vid); + $vocabulary = drupal_load('vocabulary', $vid); $form['type'] = array('#type' => 'value', '#value' => 'vocabulary'); $form['vid'] = array('#type' => 'value', '#value' => $vid); Index: modules/taxonomy/taxonomy.test =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v retrieving revision 1.6 diff -u -r1.6 taxonomy.test --- modules/taxonomy/taxonomy.test 19 Sep 2008 20:25:03 -0000 1.6 +++ modules/taxonomy/taxonomy.test 20 Sep 2008 09:13:24 -0000 @@ -56,7 +56,7 @@ } $edit['vid'] = $vid; // Get data using function. - $getEdit = taxonomy_vocabulary_load($vid); + $getEdit = drupal_load('vocabulary', $vid); foreach($getEdit as $key => $value ) { $this->assertEqual($value, $edit[$key], t('Checking value of @key.', array('@key' => $key))); } @@ -121,7 +121,7 @@ } $termsyn = implode("\n", $synonyms); $data = array('name' => $termname, 'description' => $termdesc, 'weight' => $termweight, 'synonyms' => $termsyn, 'vid' => $edit['vid'], 'tid' => 0, 'relations' => 0); - taxonomy_save_term($data); + drupal_save('term', $data); // Retrieve term and check all fields. $_tArray = taxonomy_get_term_by_name($termname); @@ -139,7 +139,7 @@ $relations[] = $staryTid; $termname = $this->randomName(20); $data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => 0, 'vid' => $edit['vid'], 'tid' => 0, 'relations' => array($staryTid)); - taxonomy_save_term($data); + drupal_save('term', $data); $_tArray = taxonomy_get_term_by_name($termname); $getTerm = $_tArray[0]; $relations[] = $getTerm->tid; @@ -147,7 +147,7 @@ // Creating another term related to 2 terms above. $termname = $this->randomName(20); $data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => 0, 'vid' => $edit['vid'], 'tid' => 0, 'relations' => array($staryTid, $getTerm->tid)); - taxonomy_save_term($data); + drupal_save('term', $data); $_tArray = taxonomy_get_term_by_name($termname); $getTerm = $_tArray[0]; @@ -197,7 +197,7 @@ // Create 1st term. $termname = $this->randomName(20); $data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => '', 'vid' => $edit['vid'], 'tid' => 0, 'relations' => 0); - taxonomy_save_term($data); + drupal_save('term', $data); $_tArray = taxonomy_get_term_by_name($termname); $parent = $_tArray[0]; @@ -390,7 +390,7 @@ $patternArray['body text'] = $body; $patternArray['title'] = $title; - $node = node_load(array('title' => $title)); + $node = drupal_load('node', array('title' => $title)); $this->drupalGet("node/$node->nid"); foreach($patternArray as $name => $termPattern) { @@ -433,7 +433,7 @@ } // Checking database fields. - $node = node_load(array('title' => $title)); + $node = drupal_load('node', array('title' => $title)); $result = db_query('SELECT tid FROM {term_node} WHERE vid = %d', $node->vid); while ($nodeRow = db_fetch_array($result)) { $this->assertTrue(in_array($nodeRow['tid'], $parent), t('Checking database field.')); Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.427 diff -u -r1.427 taxonomy.module --- modules/taxonomy/taxonomy.module 19 Sep 2008 20:25:03 -0000 1.427 +++ modules/taxonomy/taxonomy.module 20 Sep 2008 09:13:24 -0000 @@ -100,7 +100,7 @@ */ function taxonomy_term_path($term) { - $vocabulary = taxonomy_vocabulary_load($term->vid); + $vocabulary = drupal_load('vocabulary', $term->vid); if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) { return $path; } @@ -208,7 +208,7 @@ /** * Save a vocabulary given form values or an equivalent array. */ -function taxonomy_save_vocabulary(&$edit) { +function vocabulary_save(&$edit) { $edit['nodes'] = empty($edit['nodes']) ? array() : $edit['nodes']; if (!isset($edit['module'])) { @@ -249,18 +249,16 @@ * @return * Constant indicating items were deleted. */ -function taxonomy_del_vocabulary($vid) { - $vocabulary = (array) taxonomy_vocabulary_load($vid); +function vocabulary_delete($vid) { + $vocabulary = (array) drupal_load('vocabulary', $vid); db_query('DELETE FROM {vocabulary} WHERE vid = %d', $vid); db_query('DELETE FROM {vocabulary_node_types} WHERE vid = %d', $vid); $result = db_query('SELECT tid FROM {term_data} WHERE vid = %d', $vid); while ($term = db_fetch_object($result)) { - taxonomy_del_term($term->tid); + drupal_delete('term', $term->tid); } - module_invoke_all('taxonomy', 'delete', 'vocabulary', $vocabulary); - cache_clear_all(); return SAVED_DELETED; @@ -314,7 +312,7 @@ * @return * Status constant indicating if term was inserted or updated. */ -function taxonomy_save_term(&$form_values) { +function term_save(&$form_values) { $form_values += array( 'description' => '', 'weight' => 0 @@ -372,10 +370,6 @@ } } - if (isset($hook)) { - module_invoke_all('taxonomy', $hook, 'term', $form_values); - } - cache_clear_all(); return $status; @@ -389,7 +383,7 @@ * @return * Status constant indicating deletion. */ -function taxonomy_del_term($tid) { +function term_delete($tid) { $tids = array($tid); while ($tids) { $children_tids = $orphans = array(); @@ -412,8 +406,6 @@ db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $tid, $tid); db_query('DELETE FROM {term_synonym} WHERE tid = %d', $tid); db_query('DELETE FROM {term_node} WHERE tid = %d', $tid); - - module_invoke_all('taxonomy', 'delete', 'term', $term); } $tids = $orphans; @@ -428,7 +420,7 @@ * Generate a form element for selecting terms from a vocabulary. */ function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') { - $vocabulary = taxonomy_vocabulary_load($vid); + $vocabulary = drupal_load('vocabulary', $vid); $help = ($help) ? $help : $vocabulary->help; if (!$vocabulary->multiple) { @@ -647,7 +639,7 @@ $terms = $node->taxonomy; if (!empty($terms['tags'])) { foreach ($terms['tags'] as $vid => $vid_value) { - $vocabulary = taxonomy_vocabulary_load($vid); + $vocabulary = drupal_load('vocabulary', $vid); if (empty($vocabulary->tags)) { // see form_get_error $key = implode('][', $element['#parents']); // on why this is the key @@ -688,7 +680,7 @@ if (!$typed_term_tid) { $edit = array('vid' => $vid, 'name' => $typed_term); - $status = taxonomy_save_term($edit); + $status = drupal_save('term', $edit); $typed_term_tid = $edit['tid']; } @@ -991,7 +983,7 @@ * The vocabulary object with all of its metadata, if exists, FALSE otherwise. * Results are statically cached. */ -function taxonomy_vocabulary_load($vid) { +function vocabulary_load($vid) { static $vocabularies = array(); if (!isset($vocabularies[$vid])) { @@ -1035,7 +1027,7 @@ * @return Object * A term object. Results are statically cached. */ -function taxonomy_term_load($tid, $reset = FALSE) { +function term_load($tid, $reset = FALSE) { if (!is_numeric($tid)) { return FALSE; } @@ -1168,9 +1160,9 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). */ -function taxonomy_nodeapi($node, $op, $arg = 0) { +function taxonomy_node($op, $node, $arg = 0) { switch ($op) { case 'load': $output['taxonomy'] = taxonomy_node_get_terms($node); @@ -1209,7 +1201,7 @@ } /** - * Implementation of hook_nodeapi('update_index'). + * Implementation of hook_node('update_index'). */ function taxonomy_node_update_index(&$node) { $output = array(); @@ -1280,7 +1272,7 @@ $output .= '

    ' . t('Use the list below to configure and review the vocabularies defined on your site, or to list and manage the terms (tags) they contain. A vocabulary may (optionally) be tied to specific content types as shown in the Type column and, if so, will be displayed when creating or editing posts of that type. Multiple vocabularies tied to the same content type will be displayed in the order shown below. To change the order of a vocabulary, grab a drag-and-drop handle under the Name column and drag it to a new location in the list. (Grab a handle by clicking and holding the mouse while hovering over a handle icon.) Remember that your changes will not be saved until you click the Save button at the bottom of the page.') . '

    '; return $output; case 'admin/content/taxonomy/%/list': - $vocabulary = taxonomy_vocabulary_load($arg[3]); + $vocabulary = drupal_load('vocabulary', $arg[3]); if ($vocabulary->tags) { return '

    ' . t('%capital_name is a free-tagging vocabulary. To change the name or description of a term, click the edit link next to the term.', array('%capital_name' => drupal_ucfirst($vocabulary->name))) . '

    '; } Index: modules/upload/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v retrieving revision 1.206 diff -u -r1.206 upload.module --- modules/upload/upload.module 15 Sep 2008 09:28:50 -0000 1.206 +++ modules/upload/upload.module 20 Sep 2008 09:13:24 -0000 @@ -263,9 +263,9 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). */ -function upload_nodeapi(&$node, $op, $teaser) { +function upload_node($op, &$node, $teaser) { switch ($op) { case 'load': Index: modules/blog/blog.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/blog/blog.pages.inc,v retrieving revision 1.10 diff -u -r1.10 blog.pages.inc --- modules/blog/blog.pages.inc 22 May 2008 19:27:13 -0000 1.10 +++ modules/blog/blog.pages.inc 20 Sep 2008 09:13:23 -0000 @@ -29,7 +29,7 @@ $has_posts = FALSE; while ($node = db_fetch_object($result)) { - $output .= node_view(node_load($node->nid), 1); + $output .= node_view(drupal_load('node', $node->nid), 1); $has_posts = TRUE; } @@ -68,7 +68,7 @@ $has_posts = FALSE; while ($node = db_fetch_object($result)) { - $output .= node_view(node_load($node->nid), 1); + $output .= node_view(drupal_load('node', $node->nid), 1); $has_posts = TRUE; } Index: modules/translation/translation.module =================================================================== RCS file: /cvs/drupal/drupal/modules/translation/translation.module,v retrieving revision 1.29 diff -u -r1.29 translation.module --- modules/translation/translation.module 16 Aug 2008 21:36:57 -0000 1.29 +++ modules/translation/translation.module 20 Sep 2008 09:13:24 -0000 @@ -181,11 +181,11 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). * * Manages translation information for nodes. */ -function translation_nodeapi(&$node, $op, $teaser, $page) { +function translation_node($op, &$node, $teaser, $page) { // Only act if we are dealing with a content type supporting translations. if (!translation_supported_type($node->type)) { return; @@ -199,11 +199,11 @@ // We are translating a node from a source node, so // load the node to be translated and populate fields. $node->language = $language; - $node->translation_source = node_load($source_nid); + $node->translation_source = drupal_load('node', $source_nid); $node->title = $node->translation_source->title; $node->body = $node->translation_source->body; // Let every module add custom translated fields. - node_invoke_nodeapi($node, 'prepare translation'); + drupal_invoke_dataapi('node', 'prepare translation', $node); } break; Index: modules/translation/translation.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/translation/translation.pages.inc,v retrieving revision 1.3 diff -u -r1.3 translation.pages.inc --- modules/translation/translation.pages.inc 14 Apr 2008 17:48:42 -0000 1.3 +++ modules/translation/translation.pages.inc 20 Sep 2008 09:13:24 -0000 @@ -32,7 +32,7 @@ if (isset($translations[$language->language])) { // Existing translation in the translation set: display status. // We load the full node to check whether the user can edit it. - $translation_node = node_load($translations[$language->language]->nid); + $translation_node = drupal_load('node', $translations[$language->language]->nid); $title = l($translation_node->title, 'node/' . $translation_node->nid); if (node_access('update', $translation_node)) { $options[] = l(t('edit'), "node/$translation_node->nid/edit"); Index: modules/trigger/trigger.test =================================================================== RCS file: /cvs/drupal/drupal/modules/trigger/trigger.test,v retrieving revision 1.3 diff -u -r1.3 trigger.test --- modules/trigger/trigger.test 2 Jun 2008 17:39:12 -0000 1.3 +++ modules/trigger/trigger.test 20 Sep 2008 09:13:24 -0000 @@ -47,7 +47,7 @@ // Make sure the text we want appears. $this->assertRaw(t('!post %title has been created.', array ('!post' => 'Page', '%title' => $edit['title'])), t('Make sure the page has actually been created')); // Action should have been fired. - $loaded_node = node_load(array('title' => $edit['title']), NULL, TRUE); + $loaded_node = drupal_load('node', array('title' => $edit['title']), NULL, TRUE); $this->assertTrue($loaded_node->$info['property'] == $info['expected'], t('Make sure the @action action fired.', array('@action' => $info['name']))); // Leave action assigned for next test Index: modules/trigger/trigger.module =================================================================== RCS file: /cvs/drupal/drupal/modules/trigger/trigger.module,v retrieving revision 1.18 diff -u -r1.18 trigger.module --- modules/trigger/trigger.module 21 Aug 2008 19:36:38 -0000 1.18 +++ modules/trigger/trigger.module 20 Sep 2008 09:13:24 -0000 @@ -200,9 +200,9 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node(). */ -function trigger_nodeapi(&$node, $op, $a3, $a4) { +function trigger_node($op, &$node, $a3, $a4) { // Keep objects for reuse so that changes actions make to objects can persist. static $objects; // Prevent recursion by tracking which operations have already been called. @@ -341,7 +341,7 @@ case 'node': // If we are viewing an individual node, return the node. if ((arg(0) == 'node') && is_numeric(arg(1)) && (arg(2) == NULL)) { - return node_load(array('nid' => arg(1))); + return drupal_load('node', array('nid' => arg(1))); } } } Index: modules/dblog/dblog.test =================================================================== RCS file: /cvs/drupal/drupal/modules/dblog/dblog.test,v retrieving revision 1.9 diff -u -r1.9 dblog.test --- modules/dblog/dblog.test 17 Sep 2008 07:11:56 -0000 1.9 +++ modules/dblog/dblog.test 20 Sep 2008 09:13:23 -0000 @@ -265,7 +265,7 @@ $this->drupalPost('node/add/' . $type, $edit, t('Save')); $this->assertResponse(200); // Retrieve node object. - $node = node_load(array('title' => $title)); + $node = drupal_load('node', array('title' => $title)); $this->assertTrue($node != null, t('Node @title was loaded', array('@title' => $title))); // Edit node. $edit = $this->getContentUpdate($type); Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.623 diff -u -r1.623 system.module --- modules/system/system.module 20 Sep 2008 03:49:24 -0000 1.623 +++ modules/system/system.module 20 Sep 2008 09:13:24 -0000 @@ -1441,7 +1441,7 @@ 'description' => t('Display a message to the user'), 'configurable' => TRUE, 'hooks' => array( - 'nodeapi' => array('view', 'insert', 'update', 'delete'), + 'node' => array('view', 'insert', 'update', 'delete'), 'comment' => array('view', 'insert', 'update', 'delete'), 'user' => array('view', 'insert', 'update', 'delete', 'login'), 'taxonomy' => array('insert', 'update', 'delete'), @@ -1452,7 +1452,7 @@ 'type' => 'system', 'configurable' => TRUE, 'hooks' => array( - 'nodeapi' => array('view', 'insert', 'update', 'delete'), + 'node' => array('view', 'insert', 'update', 'delete'), 'comment' => array('view', 'insert', 'update', 'delete'), 'user' => array('view', 'insert', 'update', 'delete', 'login'), 'taxonomy' => array('insert', 'update', 'delete'), @@ -1469,7 +1469,7 @@ 'type' => 'system', 'configurable' => TRUE, 'hooks' => array( - 'nodeapi' => array('view', 'insert', 'update', 'delete'), + 'node' => array('view', 'insert', 'update', 'delete'), 'comment' => array('view', 'insert', 'update', 'delete'), 'user' => array('view', 'insert', 'update', 'delete', 'login'), ) @@ -1822,7 +1822,7 @@ global $user; switch ($context['hook']) { - case 'nodeapi': + case 'node': // Because this is not an action of type 'node' the node // will not be passed as $object, but it will still be available // in $context. @@ -1893,7 +1893,7 @@ ); if ($context['hook'] == 'taxonomy') { $object = $params['object']; - $vocabulary = taxonomy_vocabulary_load($object->vid); + $vocabulary = drupal_load('vocabulary', $object->vid); $variables += array( '%term_name' => $object->name, '%term_description' => $object->description, @@ -1952,7 +1952,7 @@ // are used a node object must be present to be the source // of substituted text. switch ($context['hook']) { - case 'nodeapi': + case 'node': // Because this is not an action of type 'node' the node // will not be passed as $object, but it will still be available // in $context. @@ -1964,7 +1964,7 @@ $node = node_load($comment->nid); break; case 'taxonomy': - $vocabulary = taxonomy_vocabulary_load($object->vid); + $vocabulary = drupal_load('vocabulary', $object->vid); $variables = array_merge($variables, array( '%term_name' => $object->name, '%term_description' => $object->description, Index: includes/dataapi.inc =================================================================== RCS file: includes/dataapi.inc diff -N includes/dataapi.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ includes/dataapi.inc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,102 @@ +