You are here

function nodehierarchyaccess_nodeapi in Node Hierarchy 5

Same name and namespace in other branches
  1. 6.3 nodehierarchyaccess/nodehierarchyaccess.module \nodehierarchyaccess_nodeapi()
  2. 6.2 nodehierarchyaccess/nodehierarchyaccess.module \nodehierarchyaccess_nodeapi()

Implementation of hook_nodeapi().

File

nodehierarchyaccess/nodehierarchyaccess.module, line 22
A module to integrate nodehierarchy and nodeaccess.

Code

function nodehierarchyaccess_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

  // don't do anything unless nodeaccess and nodehierarchy are installed and the node has an assigned parent
  if (!module_exists("nodeaccess") || !module_exists("nodehierarchy") || !isset($node->parent) || !$node->parent) {
    return;
  }
  switch ($op) {
    case 'insert':
    case 'update':

      // if the parent is not the same, copy the new parent's grants
      if ($node->parent != $node->old_parent) {
        _nodehierarchyaccess_copy_parent_grants($node);
      }
      break;
  }
}