"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/modules/node/src/Plugin/views/filter/Status.php" (26 Nov 2020, 1093 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Status.php" see the Fossies "Dox" file reference documentation.

    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() {
   22     return FALSE;
   23   }
   24 
   25   public function query() {
   26     $table = $this->ensureMyTable();
   27     $snippet = "$table.status = 1 OR ($table.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_NODES*** = 1) OR ***BYPASS_NODE_ACCESS*** = 1";
   28     if ($this->moduleHandler->moduleExists('content_moderation')) {
   29       $snippet .= ' OR ***VIEW_ANY_UNPUBLISHED_NODES*** = 1';
   30     }
   31     $this->query->addWhereExpression($this->options['group'], $snippet);
   32   }
   33 
   34   /**
   35    * {@inheritdoc}
   36    */
   37   public function getCacheContexts() {
   38     $contexts = parent::getCacheContexts();
   39 
   40     $contexts[] = 'user';
   41 
   42     return $contexts;
   43   }
   44 
   45 }