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.module, line 1989

<?php
function node_access_view_all_nodes() {
  static $access;

  if (!isset($access)) {
    $sql = 'SELECT COUNT(*) FROM {node_access} WHERE nid = 0 AND CONCAT(realm, gid) IN (';
    $grants = array();
    foreach (node_access_grants('view') as $realm => $gids) {
      foreach ($gids as $gid) {
        $grants[] = "'". $realm . $gid ."'";
      }
    }
    $sql .= implode(',', $grants) .') AND grant_view = 1';
    $result = db_query($sql, $node->nid);
    $access = db_result($result);
  }

  return $access;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.