[main] allow hide change user password menu

This commit is contained in:
nobohan 2022-05-16 13:52:55 +02:00
parent 8eef073988
commit f77031630f
4 changed files with 25 additions and 9 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to
## Unreleased
<!-- write down unreleased development here -->
* [main] allow hide change user password menu (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/577)
* [main] filter user jobs by active jobs (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/577)
* [main] add civility to User (entity, migration and form type) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/577)

View File

@ -129,6 +129,11 @@ class ChillMainExtension extends Extension implements
$config['access_global_history']
);
$container->setParameter(
'chill_main.access_user_change_password',
$config['access_user_change_password']
);
$container->setParameter(
'chill_main.routing.resources',
$config['routing']['resources']

View File

@ -116,6 +116,9 @@ class Configuration implements ConfigurationInterface
->booleanNode('access_global_history')
->defaultTrue()
->end()
->booleanNode('access_user_change_password')
->defaultTrue()
->end()
->arrayNode('redis')
->children()
->scalarNode('host')

View File

@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Notification\Counter\NotificationByUserCounter;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Chill\MainBundle\Workflow\Counter\WorkflowByUserCounter;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -28,16 +29,20 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
private WorkflowByUserCounter $workflowByUserCounter;
protected ParameterBagInterface $parameterBag;
public function __construct(
NotificationByUserCounter $notificationByUserCounter,
WorkflowByUserCounter $workflowByUserCounter,
Security $security,
TranslatorInterface $translator
TranslatorInterface $translator,
ParameterBagInterface $parameterBag
) {
$this->notificationByUserCounter = $notificationByUserCounter;
$this->workflowByUserCounter = $workflowByUserCounter;
$this->security = $security;
$this->translator = $translator;
$this->parameterBag = $parameterBag;
}
public function buildMenu($menuId, \Knp\Menu\MenuItem $menu, array $parameters)
@ -85,6 +90,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
'order' => 700,
]);
if ($this->parameterBag->get('chill_main.access_user_change_password')) {
$menu
->addChild(
'Change password',
@ -94,6 +100,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
'order' => 99999999998,
]);
}
}
$menu
->addChild(