You are here

function forum_access_nodeapi in Forum Access 5

Same name and namespace in other branches
  1. 6 forum_access.module \forum_access_nodeapi()

Implementation of hook_nodeapi().

Add ACL data to fresh forum posts.

File

./forum_access.module, line 359
forum_access.module

Code

function forum_access_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  static $old_tid = NULL;
  if ($node && $node->type == 'forum') {
    switch ($op) {
      case 'prepare':
        $old_tid = $node->tid;
        break;
      case 'update':
        if ($node->tid == $old_tid) {
          break;
        }
        $acl_id = db_result(db_query("SELECT acl_id from {acl} WHERE module = 'forum_access' AND name = '%d'", $old_tid));
        acl_node_remove_acl($node->nid, $acl_id);

      // fall through to 'insert' to enter the new tid...
      case 'insert':
        $acl_id = db_result(db_query("SELECT acl_id from {acl} WHERE module = 'forum_access' AND name = '%d'", $node->tid));
        acl_node_add_acl($node->nid, $acl_id, 1, 1, 1);
        $old_tid = NULL;
        break;
    }
  }
}