node_access_view_all_nodes

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 node_access_view_all_nodes()

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

Verwandte Themen

▾ 3 functions call node_access_view_all_nodes()

hook_query_TAG_alter in modules/system/system.api.php
Perform alterations to a structured query for a given tag.
node_db_rewrite_sql in modules/node/node.module
Implementation of hook_db_rewrite_sql().
node_query_node_access_alter in modules/node/node.module
Implementation of hook_query_TAG_alter().

Code

modules/node/node.module, line 2556

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

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen