You are here

function nodeaccess_access in Nodeaccess 7

Same name and namespace in other branches
  1. 5 nodeaccess.module \nodeaccess_access()
  2. 6.2 nodeaccess.module \nodeaccess_access()
  3. 6 nodeaccess.module \nodeaccess_access()

Determine access to Grant tab.

Parameters

$op:

$node:

$account:

Return value

bool Whether the user has access to the grant tab.

1 string reference to 'nodeaccess_access'
nodeaccess_menu in ./nodeaccess.module
Implements hook_menu().

File

./nodeaccess.module, line 142
Provide per node access control

Code

function nodeaccess_access($op, $node, $account = NULL) {
  global $user;
  if (!$node) {
    return FALSE;
  }

  // Apparently D7 no longer defaults to admin getting anything?
  if (user_access('administer nodeaccess')) {
    return TRUE;
  }

  // If no user object is supplied, the access check is for the current user.
  if (empty($account)) {
    $account = $user;
  }
  $allowed_types = variable_get('nodeaccess-types', array());
  if ($op == 'grant') {
    if ($node->nid && isset($allowed_types[$node->type]) && !empty($allowed_types[$node->type]) && (user_access('grant node permissions', $account) || user_access('grant editable node permissions', $account) && node_access('update', $node, $account) || user_access('grant deletable node permissions', $account) && node_access('delete', $node, $account) || user_access('grant own node permissions', $account) && $account->uid == $node->uid)) {
      return TRUE;
    }
  }
  return FALSE;
}