From f16f45f3f315336572604740886150b1b48aa9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 5 Nov 2021 14:13:00 +0000 Subject: [PATCH] Bugfix/activity fix role inheritance --- CHANGELOG.md | 1 + .../ChillActivityExtension.php | 4 +++- .../Menu/AccompanyingCourseMenuBuilder.php | 17 ++++++++--------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b9bdde0a..e8ad8ebda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to * refactor `AuthorizationHelper` and `UserACLAwareRepository` to fix constructor, and separate logic for parent role helper into `ParentRoleHelper` * [main]: filter location and locationType in backend: exclude NULL names, only active and availableToUsers * [activity]: perform client-side validation & show/hide fields in the "new location" modal +* [activity]: fix inheritance for role `ACTIVITY FULL` and add missing acl in menu * [person] show current address in search results * [person] show alt names in search results * [admin]: links to activity admin section added again. diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php index a6f1d6a8a..f4aeba174 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php @@ -87,7 +87,9 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf ActivityVoter::UPDATE => array(ActivityVoter::SEE_DETAILS), ActivityVoter::CREATE => array(ActivityVoter::SEE_DETAILS), ActivityVoter::DELETE => array(ActivityVoter::SEE_DETAILS), - ActivityVoter::SEE_DETAILS => array(ActivityVoter::SEE) + ActivityVoter::SEE_DETAILS => array(ActivityVoter::SEE), + ActivityVoter::FULL => [ActivityVoter::CREATE, ActivityVoter::DELETE, + ActivityVoter::UPDATE], ) )); } diff --git a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php index 7d5ba520d..b8ea9bf9a 100644 --- a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -2,29 +2,27 @@ namespace Chill\ActivityBundle\Menu; +use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Knp\Menu\MenuItem; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { - protected TokenStorageInterface $tokenStorage; - - protected AuthorizationHelper $authorizationHelper; - protected TranslatorInterface $translator; + protected Security $security; + public function __construct( - TokenStorageInterface $tokenStorage, - AuthorizationHelper $authorizationHelper, + Security $security, TranslatorInterface $translator ) { + $this->security = $security; $this->translator = $translator; - $this->authorizationHelper = $authorizationHelper; - $this->tokenStorage = $tokenStorage; } public static function getMenuIds(): array { @@ -35,7 +33,8 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { $period = $parameters['accompanyingCourse']; - if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep()) { + if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep() + && $this->security->isGranted(ActivityVoter::SEE, $period)) { $menu->addChild($this->translator->trans('Activity'), [ 'route' => 'chill_activity_activity_list', 'routeParameters' => [