From dae9d485748dd6b11477eb82f8b8c70af9e8e147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 30 Mar 2022 15:26:45 +0200 Subject: [PATCH] really do not show thirdparty which are not active --- .../Repository/ThirdPartyACLAwareRepository.php | 6 ++++++ .../ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php index 2a57a2f55..f67417767 100644 --- a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php +++ b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php @@ -34,6 +34,12 @@ final class ThirdPartyACLAwareRepository implements ThirdPartyACLAwareRepository { $qb = $this->thirdPartyRepository->createQueryBuilder('tp'); + $qb->leftJoin('tp.parent', 'parent') + ->andWhere($qb->expr()->andX( + 'tp.active = \'TRUE\'', + $qb->expr()->orX($qb->expr()->isNull('parent'), 'parent.active = \'TRUE\'') + )); + if (null !== $filterString) { $qb->andWhere($qb->expr()->like('tp.canonicalized', 'LOWER(UNACCENT(:filterString))')) ->setParameter('filterString', '%' . $filterString . '%'); diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php index d4b59ab37..3c03b7f8a 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php @@ -113,7 +113,8 @@ class ThirdPartyApiSearch implements SearchApiInterface [], ...$pertinenceArgs )) - ->andWhereClause(implode(' AND ', $wheres), array_merge( + ->andWhereClause(implode(' AND ', $wheres) + .' AND tparty.active IS TRUE and (parent.active IS TRUE OR parent IS NULL)', array_merge( [], ...$whereArgs ));