function Access::query
Same name in other branches
- 9 core/modules/node/src/Plugin/views/filter/Access.php \Drupal\node\Plugin\views\filter\Access::query()
- 8.9.x core/modules/node/src/Plugin/views/filter/Access.php \Drupal\node\Plugin\views\filter\Access::query()
- 11.x 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 28
Class
- Access
- Filter by node_access records.
Namespace
Drupal\node\Plugin\views\filterCode
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, '>=');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.