public function Access::query

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

Overrides FilterPluginBase::query

File

drupal/core/modules/node/lib/Drupal/node/Plugin/views/filter/Access.php, line 34
Definition of Drupal\node\Plugin\views\filter\Access.

Class

Access
Filter by node_access records.

Namespace

Drupal\node\Plugin\views\filter

Code

public function query() {
  if (!user_access('administer nodes')) {
    $table = $this
      ->ensureMyTable();
    $grants = db_or();
    foreach (node_access_grants('view') as $realm => $gids) {
      foreach ($gids as $gid) {
        $grants
          ->condition(db_and()
          ->condition($table . '.gid', $gid)
          ->condition($table . '.realm', $realm));
      }
    }
    $this->query
      ->add_where('AND', $grants);
    $this->query
      ->add_where('AND', $table . '.grant_view', 1, '>=');
  }
}