Same name and namespace in other branches
  1. 8.9.x core/modules/node/src/Plugin/views/filter/Access.php \Drupal\node\Plugin\views\filter\Access::query()
  2. 9 core/modules/node/src/Plugin/views/filter/Access.php \Drupal\node\Plugin\views\filter\Access::query()

See _node_access_where_sql() for a non-views query based implementation.

File

core/modules/node/src/Plugin/views/filter/Access.php, line 28

Class

Access

Namespace

Drupal\node\Plugin\views\filter

Code

public function query() {
  $account = $this->view
    ->getUser();
  if (!$account
    ->hasPermission('bypass node access')) {
    $table = $this
      ->ensureMyTable();
    $grants = $this->query
      ->getConnection()
      ->condition('OR');
    foreach (node_access_grants('view', $account) as $realm => $gids) {
      foreach ($gids as $gid) {
        $grants
          ->condition($this->query
          ->getConnection()
          ->condition('AND')
          ->condition($table . '.gid', $gid)
          ->condition($table . '.realm', $realm));
      }
    }
    $this->query
      ->addWhere('AND', $grants);
    $this->query
      ->addWhere('AND', $table . '.grant_view', 1, '>=');
  }
}