node_access_acquire_grants

  1. drupal
    1. 5
    2. 8
    3. 6
    4. 7
Versions
5 node_access_acquire_grants($node)
8 node_access_acquire_grants($node, $delete = TRUE)
6 node_access_acquire_grants($node)
7 node_access_acquire_grants($node, $delete = TRUE)

Gets the list of node access grants and writes them to the database.

This function is called when a node is saved, and can also be called by modules if something other than a node save causes node access permissions to change. It collects all node access grants for the node from hook_node_access_records() implementations and saves the collected grants to the database.

Parameters

$node The $node to acquire grants for.

Related topics

▾ 3 functions call node_access_acquire_grants()

node_access_rebuild in modules/node/node.module
Rebuild the node access database. This is occasionally needed by modules that make system-wide changes to access levels.
node_save in modules/node/node.module
Save a node object into the database.
_node_access_rebuild_batch_operation in modules/node/node.module
Batch operation for node_access_rebuild_batch.

Code

modules/node/node.module, line 2210

<?php
function node_access_acquire_grants($node) {
  $grants = module_invoke_all('node_access_records', $node);
  if (empty($grants)) {
    $grants[] = array(
      'realm' => 'all',
      'gid' => 0,
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
    );
  }
  else {
    // retain grants by highest priority
    $grant_by_priority = array();
    foreach ($grants as $g) {
      $grant_by_priority[intval($g['priority'])][] = $g;
    }
    krsort($grant_by_priority);
    $grants = array_shift($grant_by_priority);
  }

  node_access_write_grants($node, $grants);
}
?>