You are here

function faq_access in Frequently Asked Questions 6

Same name and namespace in other branches
  1. 5.2 faq.module \faq_access()
  2. 5 faq.module \faq_access()

Implements hook_access().

File

./faq.module, line 37
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_access($op, $node, $account = NULL) {
  global $user;
  if (empty($account)) {
    $account = $user;
  }
  if ($op != 'create') {
    $node = (object) $node;
  }
  if ($op == 'create') {
    if (user_access('create faq')) {
      return TRUE;
    }
  }
  elseif ($op == 'update') {
    if (user_access('edit faq')) {
      return TRUE;
    }
    elseif (user_access('edit own faq') && $account->uid == $node->uid) {
      return TRUE;
    }
  }
  elseif ($op == 'delete') {
    if (user_access('delete faq content')) {
      return TRUE;
    }
    elseif (user_access('delete own faq content') && $account->uid == $node->uid) {
      return TRUE;
    }
  }
}