From 7a927653045e7c9b32803ce4a03d5deb092bcd97 Mon Sep 17 00:00:00 2001 From: Moreau Elise <moreau.elise13@gmail.com> Date: Sun, 11 Oct 2020 12:59:34 +0200 Subject: [PATCH] in search action, only show accessibles groups --- src/Application/Actions/Search/SearchAction.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Application/Actions/Search/SearchAction.php b/src/Application/Actions/Search/SearchAction.php index 06fc138..9fc4aa2 100644 --- a/src/Application/Actions/Search/SearchAction.php +++ b/src/Application/Actions/Search/SearchAction.php @@ -45,7 +45,15 @@ class SearchAction extends Action $groups_query = $this->groupRepository->createQueryBuilder('g'); $groups_list = $groups_query ->where('g.name LIKE :search') - ->setParameter('search', '%' . $search . '%') + ->andWhere($groups_query->expr()->orX( + $groups_query->expr()->eq('g.private', '0'), + $groups_query->expr()->isMemberOf(':user_id', 'g.users') + + )) + ->setParameters(array( + ':user_id' => $_SESSION['userId'], + ':search' => '%' . $search . '%' + )) ->getQuery() ->getResult(); -- GitLab