1 node.module | node_access_acquire_grants(Node $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, allows these grants to be altered via hook_node_access_records_alter() implementations, and saves the collected and altered grants to the database.
Parameters
Node $node: The $node to acquire grants for.
$delete: (optional) Whether to delete existing node access records before inserting new ones. Defaults to TRUE.
Related topics
File
- core/
modules/ node/ node.module, line 3245 - The core module that allows content to be submitted to the site.
Code
function node_access_acquire_grants(Node $node, $delete = TRUE) {
$grants = module_invoke_all('node_access_records', $node);
// Let modules alter the grants.
backdrop_alter('node_access_records', $grants, $node);
// If no grants are set and the node is published, then use the default grant.
if (empty($grants) && !empty($node->status)) {
$grants[] = array('realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0);
}
_node_access_write_grants($node, $grants, NULL, $delete);
}