public function NodeStatus::query in view_unpublished 8
Add this filter to the query.
Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.
Overrides Status::query
File
- src/
Plugin/ views/ filter/ NodeStatus.php, line 20
Class
- NodeStatus
- Filter by view all unpublished permissions granted by view_unpublished.
Namespace
Drupal\view_unpublished\Plugin\views\filterCode
public function query() {
$table = $this
->ensureMyTable();
$snippet = "{$table}.status = 1 OR ({$table}.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_NODES*** = 1) OR ***VIEWUNPUBLISHED_ANY*** = 1 OR ***BYPASS_NODE_ACCESS*** = 1";
if ($this->moduleHandler
->moduleExists('content_moderation')) {
$snippet .= ' OR ***VIEW_ANY_UNPUBLISHED_NODES*** = 1';
}
$where_per_type = [];
foreach (NodeType::loadMultiple() as $type) {
$type_id = $type
->id();
$where_per_type[] = "({$table}.type = '{$type_id}' AND ***VIEWUNPUBLISHED_TYPE_{$type_id}*** = 1)";
}
if (!empty($where_per_type)) {
$where_per_type = implode(' OR ', $where_per_type);
$snippet .= " OR {$where_per_type}";
}
$this->query
->addWhereExpression($this->options['group'], $snippet);
}