You are here

function node_access_view_all_nodes in Drupal 4

Same name and namespace in other branches
  1. 8 core/modules/node/node.module \node_access_view_all_nodes()
  2. 5 modules/node/node.module \node_access_view_all_nodes()
  3. 6 modules/node/node.module \node_access_view_all_nodes()
  4. 7 modules/node/node.module \node_access_view_all_nodes()
  5. 9 core/modules/node/node.module \node_access_view_all_nodes()

Determine whether the user has a global viewing grant for all nodes.

Related topics

1 call to node_access_view_all_nodes()
node_db_rewrite_sql in modules/node.module
Implementation of hook_db_rewrite_sql

File

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

Code

function node_access_view_all_nodes() {
  static $access;
  if (!isset($access)) {
    $grants = array();
    foreach (node_access_grants('view') as $realm => $gids) {
      foreach ($gids as $gid) {
        $grants[] = "(gid = {$gid} AND realm = '{$realm}')";
      }
    }
    $grants_sql = '';
    if (count($grants)) {
      $grants_sql = 'AND (' . implode(' OR ', $grants) . ')';
    }
    $sql = "SELECT COUNT(*) FROM {node_access} WHERE nid = 0 {$grants_sql} AND grant_view >= 1";
    $result = db_query($sql);
    $access = db_result($result);
  }
  return $access;
}