You are here

function faq_ask_node_access in FAQ_Ask 7

Same name and namespace in other branches
  1. 8 faq_ask.module \faq_ask_node_access()

Implements hook_node_access().

Parameters

string $op: The type of node access we are handling

object $node: Node object we are checking the access to

obhect $account: Account object of the current user

Return value

boolean TRUE if access is granted, FALSE if not.

File

./faq_ask.module, line 78
This module is an add-on to the FAQ module that allows users with the 'ask question' permission to create a question which will be queued for an 'expert' to answer.

Code

function faq_ask_node_access($op, $node, $account) {

  // If node is already published, it's not ours any more.
  if (!is_object($node)) {
    return NULL;
  }
  if ($node->status == 1) {
    return NULL;
  }
  if ($op == 'create') {
    return user_access('ask question') || user_access('answer question');
  }
  else {

    // We don't include "edit own" because the intent is they can edit their own until it's published.
    return user_access('answer question') || $account->uid == $node->uid;
  }
}