public function Access::query in Zircon Profile 8.0
Same name and namespace in other branches
- 8 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.
Overrides FilterPluginBase::query
File
- core/
modules/ node/ src/ Plugin/ views/ filter/ Access.php, line 31 - Contains \Drupal\node\Plugin\views\filter\Access.
Class
- Access
- Filter by node_access records.
Namespace
Drupal\node\Plugin\views\filterCode
public function query() {
$account = $this->view
->getUser();
if (!$account
->hasPermission('administer nodes')) {
$table = $this
->ensureMyTable();
$grants = db_or();
foreach (node_access_grants('view', $account) as $realm => $gids) {
foreach ($gids as $gid) {
$grants
->condition(db_and()
->condition($table . '.gid', $gid)
->condition($table . '.realm', $realm));
}
}
$this->query
->addWhere('AND', $grants);
$this->query
->addWhere('AND', $table . '.grant_view', 1, '>=');
}
}