function node_access_grants

Fetches an array of permission IDs granted to the given user ID.

The implementation here provides only the universal "all" grant. A node access module should implement hook_node_grants() to provide a grant list for the user.

After the default grants have been loaded, we allow modules to alter the grants array by reference. This hook allows for complex business logic to be applied when integrating multiple node access modules.

Parameters

$op: The operation that the user is trying to perform.

$account: (optional) The user object for the user performing the operation. If omitted, the current user is used. Defaults to NULL.

Return value

An associative array in which the keys are realms, and the values are arrays of grants for those realms.

Related topics

5 calls to node_access_grants()
Access::query in drupal/core/modules/node/lib/Drupal/node/Plugin/views/filter/Access.php
See _node_access_where_sql() for a non-views query based implementation.
hook_query_TAG_alter in drupal/core/modules/system/system.api.php
Perform alterations to a structured query for a given tag.
NodeAccessController::accessGrants in drupal/core/modules/node/lib/Drupal/node/NodeAccessController.php
Determines access to nodes based on node grants.
node_access_view_all_nodes in drupal/core/modules/node/node.module
Determines whether the user has a global viewing grant for all nodes.
node_query_node_access_alter in drupal/core/modules/node/node.module
Implements hook_query_TAG_alter().

File

drupal/core/modules/node/node.module, line 2649
The core module that allows content to be submitted to the site.

Code

function node_access_grants($op, $account = NULL) {
  if (!isset($account)) {
    $account = $GLOBALS['user'];
  }

  // Fetch node access grants from other modules.
  $grants = module_invoke_all('node_grants', $account, $op);

  // Allow modules to alter the assigned grants.
  drupal_alter('node_grants', $grants, $account, $op);
  return array_merge(array(
    'all' => array(
      0,
    ),
  ), $grants);
}