From ec1ec0d0cb33ac205fa45b8944a923024a49afdb Mon Sep 17 00:00:00 2001 From: Anatolii Poliakov Date: Wed, 8 Dec 2021 13:12:31 +0200 Subject: [PATCH] Fix issues with unpublished amenities --- .../src/Plugin/views/filter/BetterTaxonomyIndexTid.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openy_taxonomy/src/Plugin/views/filter/BetterTaxonomyIndexTid.php b/openy_taxonomy/src/Plugin/views/filter/BetterTaxonomyIndexTid.php index f92f4de1..0fe1af2e 100644 --- a/openy_taxonomy/src/Plugin/views/filter/BetterTaxonomyIndexTid.php +++ b/openy_taxonomy/src/Plugin/views/filter/BetterTaxonomyIndexTid.php @@ -197,6 +197,10 @@ protected function valueForm(&$form, FormStateInterface $form_state) { if ($tree) { foreach ($tree as $term) { + + if (!$term->isPublished() && !$this->currentUser->hasPermission('administer taxonomy')) { + continue; + } $choice = new \stdClass(); $choice->option = [$term->id() => str_repeat('-', $term->depth) . \Drupal::service('entity.repository')->getTranslationFromContext($term)->label()]; $options[] = $choice; @@ -208,6 +212,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { $query = \Drupal::entityQuery('taxonomy_term') // @todo Sorting on vocabulary properties - // https://www.drupal.org/node/1821274. + ->condition('status', TRUE) ->sort('weight') ->sort('name') ->addTag('taxonomy_term_access');