You are here

function faq_node_access in Frequently Asked Questions 7

Same name and namespace in other branches
  1. 8 faq.module \faq_node_access()

Implements hook_node_access().

File

./faq.module, line 48
The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.

Code

function faq_node_access($node, $op, $account = NULL) {
  global $user;
  if (empty($account)) {
    $account = $user;
  }

  // Ignore non-FAQ node.
  if ((is_object($node) ? $node->type : $node) !== 'faq') {
    return NODE_ACCESS_IGNORE;
  }
  if ($op != 'create') {
    $node = (object) $node;
  }
  if ($op == 'view') {
    return NODE_ACCESS_IGNORE;
  }
  elseif ($op == 'create' || $op == 'update' || $op == 'delete') {
    if (user_access('administer faq')) {
      return NODE_ACCESS_ALLOW;
    }
  }
  return NODE_ACCESS_IGNORE;
}