function node_add_node_grants_to_query

Helper function to create the or condition for a node grants check.

Parameters

$account: The grants to add to the query, usually gotten via node_access_grants().

$table_alias: Optional, the alias to the node access table.

Return value

TRUE if the operation may be performed, FALSE otherwise.

Related topics

3 calls to node_add_node_grants_to_query()
node_access in modules/node/node.module
Determines whether the current user may perform the operation on the node.
node_access_view_all_nodes in modules/node/node.module
Determines whether the user has a global viewing grant for all nodes.
_node_query_node_access_alter in modules/node/node.module
Helper for node access functions.

File

modules/node/node.module, line 3092

Code

function node_add_node_grants_to_query($node_access_grants, $table_alias = '') {
    $grants = db_or();
    $prefix = $table_alias ? $table_alias . '.' : '';
    foreach ($node_access_grants as $realm => $gids) {
        if (!empty($gids)) {
            $grants->condition(db_and()->condition($prefix . 'gid', $gids, 'IN')
                ->condition($prefix . 'realm', $realm));
        }
    }
    return $grants;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.