You are here

function node_tools_nodeapi in Module Grants 6.3

Same name and namespace in other branches
  1. 6.4 node_tools/node_tools.module \node_tools_nodeapi()

Implementation of hook_nodeapi().

We use this mainly to set up some useful node properties that can be read later, whether it be in this module or another, thus removing the need for multiple calls to retrieve the same info in various places.

File

node_tools/node_tools.module, line 16
Generic reusable functions involving node objects.

Code

function node_tools_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {
    case 'presave':
    case 'load':

      // get here immediately after the node is fetched from db
      if (!isset($node->current_revision_id) && isset($node->nid)) {
        $node->current_revision_id = node_tools_get_current_node_revision_id($node->nid);
        $node->is_current = node_tools_revision_is_current($node);
        $node->num_revisions = node_tools_get_number_of_revisions($node->nid);
      }

      //$node->uid and $node->revision_uid were already set in node_load()

      //$node->revision is set as part of 'prepare'-op, see node_object_prepare()
      break;
  }
}