diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 09668f0e3..62a3d80d8 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -114,6 +114,11 @@ class ChillMainExtension extends Extension implements $config['available_countries'] ); + $container->setParameter( + 'chill_main.access_global_history', + $config['access_global_history'] + ); + $container->setParameter( 'chill_main.routing.resources', $config['routing']['resources'] diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index be8baf79a..7ced6aac6 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -113,6 +113,9 @@ class Configuration implements ConfigurationInterface ->end() ->end() ->end() + ->booleanNode('access_global_history') + ->defaultTrue() + ->end() ->arrayNode('redis') ->children() ->scalarNode('host') diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php index 1a5ae9afe..10acf2d6c 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/SectionMenuBuilder.php @@ -14,6 +14,7 @@ namespace Chill\MainBundle\Routing\MenuBuilder; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\MainBundle\Security\Authorization\ChillExportVoter; use Knp\Menu\MenuItem; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -22,23 +23,20 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class SectionMenuBuilder implements LocalMenuBuilderInterface { - /** - * @var AuthorizationCheckerInterface - */ - protected $authorizationChecker; + protected AuthorizationCheckerInterface $authorizationChecker; - /** - * @var TranslatorInterface - */ - protected $translator; + protected ParameterBagInterface $parameterBag; + + protected TranslatorInterface $translator; /** * SectionMenuBuilder constructor. */ - public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator) + public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator, ParameterBagInterface $parameterBag) { $this->authorizationChecker = $authorizationChecker; $this->translator = $translator; + $this->parameterBag = $parameterBag; } /** @@ -54,14 +52,16 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface 'order' => 0, ]); - $menu->addChild($this->translator->trans('Global timeline'), [ - 'route' => 'chill_center_timeline', - ]) - ->setExtras( - [ - 'order' => 10, - ] - ); + if ($this->parameterBag->get('chill_main.access_global_history')) { + $menu->addChild($this->translator->trans('Global timeline'), [ + 'route' => 'chill_center_timeline', + ]) + ->setExtras( + [ + 'order' => 10, + ] + ); + } if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) { $menu->addChild($this->translator->trans('Export Menu'), [ diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 1f85e4ad0..6d2bf6d18 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -59,6 +59,16 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $config['allow_multiple_simultaneous_accompanying_periods'] ); + $container->setParameter( + 'chill_person.create_person_allowed', + $config['create_person_allowed'] + ); + + $container->setParameter( + 'chill_person.create_parcours_allowed', + $config['create_parcours_allowed'] + ); + // register all configuration in a unique parameter $container->setParameter('chill_person', $config); diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php index 8a0cab301..7b483a633 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/Configuration.php @@ -62,6 +62,12 @@ class Configuration implements ConfigurationInterface ->end() // children for 'validation', parent = validation ->end() //validation, parent = children of root ->end() // children of root, parent = root + ->booleanNode('create_person_allowed') + ->defaultTrue() + ->end() + ->booleanNode('create_parcours_allowed') + ->defaultTrue() + ->end() ->arrayNode('person_fields') ->canBeDisabled() ->children() diff --git a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php index 4635eb4fc..357cf38be 100644 --- a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Menu; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Knp\Menu\MenuItem; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -29,10 +30,11 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface /** * SectionMenuBuilder constructor. */ - public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator) + public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator, ParameterBagInterface $parameterBag) { $this->authorizationChecker = $authorizationChecker; $this->translator = $translator; + $this->parameterBag = $parameterBag; } /** @@ -40,7 +42,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface */ public function buildMenu($menuId, MenuItem $menu, array $parameters) { - if ($this->authorizationChecker->isGranted(PersonVoter::CREATE)) { + if ($this->authorizationChecker->isGranted(PersonVoter::CREATE) && $this->parameterBag->get('chill_person.create_person_allowed')) { $menu->addChild($this->translator->trans('Add a person'), [ 'route' => 'chill_person_new', ]) @@ -50,13 +52,15 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface ]); } - $menu->addChild($this->translator->trans('Create an accompanying course'), [ - 'route' => 'chill_person_accompanying_course_new', - ]) - ->setExtras([ - 'order' => 11, - 'icons' => ['plus'], - ]); + if ($this->parameterBag->get('chill_person.create_parcours_allowed')) { + $menu->addChild($this->translator->trans('Create an accompanying course'), [ + 'route' => 'chill_person_accompanying_course_new', + ]) + ->setExtras([ + 'order' => 11, + 'icons' => ['plus'], + ]); + } $menu->addChild($this->translator->trans('Accompanying courses of users'), [ 'route' => 'chill_course_list_reassign',