mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
add entry "add a person" in section dynamically + right on exports
This commit is contained in:
@@ -26,6 +26,7 @@ use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -61,6 +62,8 @@ class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte
|
||||
return \in_array($attribute, [
|
||||
self::STATS, self::LISTS
|
||||
]);
|
||||
} elseif ($subject === null) {
|
||||
return $attribute === self::CREATE;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -72,6 +75,13 @@ class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($subject === null) {
|
||||
$centers = $this->helper->getReachableCenters($token->getUser(),
|
||||
new Role($attribute));
|
||||
|
||||
return count($centers) > 0;
|
||||
}
|
||||
|
||||
return $this->helper->userHasAccess($token->getUser(), $subject, $attribute);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user