mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 10:03:49 +00:00
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.
This commit is contained in:
@@ -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')
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user