diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 5fa0bca35..c947e7474 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -17,7 +17,7 @@ use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable; use Chill\MainBundle\Entity\HasCenterInterface; -use Chill\MainBundle\Entity\HasScopeInterface; +use Chill\MainBundle\Entity\HasScopesInterface; use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; @@ -55,7 +55,7 @@ use Symfony\Component\Validator\Constraints as Assert; * getUserFunction="getUser", * path="scope") */ -class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface, HasCenterInterface, HasScopeInterface +class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface, HasCenterInterface, HasScopesInterface { public const SENTRECEIVED_RECEIVED = 'received'; @@ -422,6 +422,19 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac return $this->scope; } + public function getScopes(): array + { + if (null !== $this->getAccompanyingPeriod()) { + return $this->getAccompanyingPeriod()->getScopes(); + } + + if (null !== $this->getPerson()) { + return [$this->scope]; + } + + return []; + } + public function getSentReceived(): string { return $this->sentReceived; diff --git a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php index 42a73762c..570c41d14 100644 --- a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php +++ b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php @@ -133,7 +133,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn // change attribute CREATE if (self::CREATE === $attribute) { - return $this->voterHelper->voteOnAttribute(self::CREATE_PERSON, null, $token); + return $this->voterHelper->voteOnAttribute(self::CREATE_PERSON, $subject->getPerson(), $token); } } elseif ($subject->getAccompanyingPeriod() instanceof AccompanyingPeriod) { if (!$this->security->isGranted(AccompanyingPeriodVoter::SEE, $subject->getAccompanyingPeriod())) {