mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 21:13:57 +00:00
insert entries in person menu dynamically, according to acl
This commit is contained in:
@@ -26,6 +26,8 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -56,6 +58,10 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
{
|
||||
if ($subject instanceof Activity) {
|
||||
return \in_array($attribute, $this->getAttributes());
|
||||
} elseif ($subject instanceof Person) {
|
||||
return $attribute === self::SEE
|
||||
||
|
||||
$attribute === self::CREATE;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -66,6 +72,14 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
if (!$token->getUser() instanceof User) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($subject instanceof Person) {
|
||||
$centers = $this->helper->getReachableCenters($token->getUser(), new Role($attribute));
|
||||
|
||||
return \in_array($subject->getCenter(), $centers);
|
||||
}
|
||||
|
||||
/* @var $subject Activity */
|
||||
return $this->helper->userHasAccess($token->getUser(), $subject, $attribute);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user