node_access_view_all_nodes
- Versions
- 4.6 – 7
node_access_view_all_nodes()
Determine whether the user has a global viewing grant for all nodes.
Related topics
Code
modules/node/node.module, line 2614
<?php
function node_access_view_all_nodes() {
static $access;
if (!isset($access)) {
// If no modules implement the node access system, access is always true.
if (!module_implements('node_grants')) {
$access = TRUE;
}
else {
$query = db_select('node_access');
$query->addExpression('COUNT(*)');
$query
->condition('nid', 0)
->condition('grant_view', 1, '>=');
$grants = db_or();
foreach (node_access_grants('view') as $realm => $gids) {
foreach ($gids as $gid) {
$grants->condition(db_and()
->condition('gid', $gid)
->condition('realm', $realm)
);
}
}
if (count($grants) > 0 ) {
$query->condition($grants);
}
$access = $query
->execute()
->fetchField();
}
}
return $access;
}
?>Login or register to post comments 