Version 1
[yaffs-website] / web / core / modules / node / src / Plugin / views / filter / Status.php
diff --git a/web/core/modules/node/src/Plugin/views/filter/Status.php b/web/core/modules/node/src/Plugin/views/filter/Status.php
new file mode 100644 (file)
index 0000000..194df7a
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+namespace Drupal\node\Plugin\views\filter;
+
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\views\Plugin\views\filter\FilterPluginBase;
+
+/**
+ * Filter by published status.
+ *
+ * @ingroup views_filter_handlers
+ *
+ * @ViewsFilter("node_status")
+ */
+class Status extends FilterPluginBase {
+
+  public function adminSummary() { }
+
+  protected function operatorForm(&$form, FormStateInterface $form_state) { }
+
+  public function canExpose() { return FALSE; }
+
+  public function query() {
+    $table = $this->ensureMyTable();
+    $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");
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCacheContexts() {
+    $contexts = parent::getCacheContexts();
+
+    $contexts[] = 'user';
+
+    return $contexts;
+  }
+
+}