You are here

function faq_node_access in Frequently Asked Questions 8

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

Implements hook_node_access().

File

./faq.module, line 36
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(NodeInterface $node, $op, AccountInterface $account) {

  // Ignore non-FAQ node.
  if ($node
    ->getType() !== 'faq') {
    return AccessResult::neutral();
  }
  if ($op == 'view') {
    return AccessResult::neutral();
  }
  elseif ($op == 'create' || $op == 'update' || $op == 'delete') {
    if (\Drupal::currentUser()
      ->hasPermission('administer faq')) {
      return AccessResult::allowed();
    }
  }
  return AccessResult::neutral();
}