node_access_view_all_nodes

  1. drupal
    1. 5
    2. 6
    3. 7
    4. 8
Versions
5 – 6 node_access_view_all_nodes()
7 – 8 node_access_view_all_nodes($account = NULL)

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

Related topics

Code

modules/node/node.module, line 2899

<?php
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;
}
?>