Version 1
[yaffs-website] / web / core / modules / node / src / Plugin / views / filter / Status.php
1 <?php
2
3 namespace Drupal\node\Plugin\views\filter;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\filter\FilterPluginBase;
7
8 /**
9  * Filter by published status.
10  *
11  * @ingroup views_filter_handlers
12  *
13  * @ViewsFilter("node_status")
14  */
15 class Status extends FilterPluginBase {
16
17   public function adminSummary() { }
18
19   protected function operatorForm(&$form, FormStateInterface $form_state) { }
20
21   public function canExpose() { return FALSE; }
22
23   public function query() {
24     $table = $this->ensureMyTable();
25     $this->query->addWhereExpression($this->options['group'], "$table.status = 1 OR ($table.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_NODES*** = 1) OR ***BYPASS_NODE_ACCESS*** = 1");
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function getCacheContexts() {
32     $contexts = parent::getCacheContexts();
33
34     $contexts[] = 'user';
35
36     return $contexts;
37   }
38
39 }