From 96cd18563b442f0a8b2421a3b3d00575e274ca05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 16 Apr 2018 17:18:59 +0200 Subject: [PATCH] include current role in ScopePickerType and UserPickerType Previously, only the "parent" roles were takent into account in those two types. This commit fixe the bug by adding the current role to the query. --- Form/Type/ScopePickerType.php | 5 ++++- Form/Type/UserPickerType.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Form/Type/ScopePickerType.php b/Form/Type/ScopePickerType.php index 9525e81f0..dbbc28255 100644 --- a/Form/Type/ScopePickerType.php +++ b/Form/Type/ScopePickerType.php @@ -113,6 +113,9 @@ class ScopePickerType extends AbstractType */ protected function buildAccessibleScopeQuery(Center $center, Role $role) { + $roles = $this->authorizationHelper->getParentRoles($role); + $roles[] = $role; + $qb = $this->scopeRepository->createQueryBuilder('s'); $qb // jointure to center @@ -128,7 +131,7 @@ class ScopePickerType extends AbstractType function(Role $role) { return $role->getRole(); }, - $this->authorizationHelper->getParentRoles($role) + $roles )) // user contraint ->andWhere(':user MEMBER OF gc.users') diff --git a/Form/Type/UserPickerType.php b/Form/Type/UserPickerType.php index fd7600bf9..a9a0bf62e 100644 --- a/Form/Type/UserPickerType.php +++ b/Form/Type/UserPickerType.php @@ -88,6 +88,9 @@ class UserPickerType extends AbstractType return $u->getUsername(); }) ->setNormalizer('query_builder', function(Options $options) { + $roles = $this->authorizationHelper->getParentRoles($options['role']); + $roles[] = $options['role']; + $qb = $this->userRepository->createQueryBuilder('u'); $qb // add center constraint @@ -103,7 +106,7 @@ class UserPickerType extends AbstractType 'roles', \array_map( function(Role $role) { return $role->getRole(); }, - $this->authorizationHelper->getParentRoles($options['role']) + $roles ) ) // add active constraint