Loading documentation/release/3.1.5.md +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ * Ajout des temoins hiérarchique et fonctionnelle pour les affectations * Ajout du pourcentage de l'affectation pour les affectations * Contrôle de l'affichage des infos de l'agent soumi à privilèges spécifiques * [FIX] correction de la route de retour lors de l'abonnement/désabonnement à une formation * [Formation] Ajout d'un bouton pour changer l'état vers un état donné sans respecter le circuit * [Structure] Retrait de la nommination manuelle des responsables et gestionnaires (on se fie plus qu'au référentiel) Loading module/Application/config/merged/agent.config.php +15 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace Application; use Application\Assertion\AgentAffichageAssertion; use Application\Assertion\AgentAffichageAssertionFactory; use Application\Assertion\AgentAssertion; use Application\Assertion\AgentAssertionFactory; use Application\Controller\AgentController; Loading @@ -14,6 +16,7 @@ use Application\Form\SelectionAgent\SelectionAgentForm; use Application\Form\SelectionAgent\SelectionAgentFormFactory; use Application\Form\SelectionAgent\SelectionAgentHydrator; use Application\Form\SelectionAgent\SelectionAgentHydratorFactory; use Application\Provider\Privilege\AgentaffichagePrivileges; use Application\Provider\Privilege\AgentPrivileges; use Application\Service\Agent\AgentService; use Application\Service\Agent\AgentServiceFactory; Loading Loading @@ -62,6 +65,17 @@ return [ 'resources' => ['Agent'], 'assertion' => AgentAssertion::class ], [ 'privileges' => [ AgentaffichagePrivileges::AGENTAFFICHAGE_SUPERIEUR, AgentaffichagePrivileges::AGENTAFFICHAGE_AUTORITE, AgentaffichagePrivileges::AGENTAFFICHAGE_COMPTE, AgentaffichagePrivileges::AGENTAFFICHAGE_CARRIERECOMPLETE, AgentaffichagePrivileges::AGENTAFFICHAGE_DATERESUME, ], 'resources' => ['Agent'], 'assertion' => AgentAffichageAssertion::class ], ], ], ], Loading Loading @@ -376,6 +390,7 @@ return [ 'service_manager' => [ 'factories' => [ AgentAssertion::class => AgentAssertionFactory::class, AgentAffichageAssertion::class => AgentAffichageAssertionFactory::class, AgentService::class => AgentServiceFactory::class, AgentAffectationService::class => AgentAffectationServiceFactory::class, Loading module/Application/src/Application/Assertion/AgentAffichageAssertion.php 0 → 100644 +79 −0 Original line number Diff line number Diff line <?php namespace Application\Assertion; use Application\Entity\Db\Agent; use Application\Provider\Privilege\AgentaffichagePrivileges; use Application\Provider\Role\RoleProvider as AppRoleProvider; use Application\Service\Agent\AgentServiceAwareTrait; use Application\Service\AgentAffectation\AgentAffectationServiceAwareTrait; use Structure\Provider\Role\RoleProvider as StructureRoleProvider; use Structure\Service\Structure\StructureServiceAwareTrait; use UnicaenPrivilege\Assertion\AbstractAssertion; use UnicaenUtilisateur\Service\User\UserServiceAwareTrait; use Laminas\Permissions\Acl\Resource\ResourceInterface; /** Note : pas besoin d'assertion de controller car cela n'est que de la gestion d'affichage sans routing */ class AgentAffichageAssertion extends AbstractAssertion { use AgentServiceAwareTrait; use AgentAffectationServiceAwareTrait; use StructureServiceAwareTrait; use UserServiceAwareTrait; protected function assertEntity(ResourceInterface $entity = null, $privilege = null): bool { if (!$entity instanceof Agent) { return false; } /** @var Agent $entity */ $user = $this->getUserService()->getConnectedUser(); $agent = $this->getAgentService()->getAgentByUser($user); $role = $this->getUserService()->getConnectedRole(); $structures = []; foreach ($entity->getAffectations() as $affectation) { $structures[] = $affectation->getStructure(); } foreach ($entity->getStructuresForcees() as $structureAgentForce) { $structures[] = $structureAgentForce->getStructure(); } $isResponsable = false; $isGestionnaire = false; $isSuperieur = false; $isAutorite = false; if ($role->getRoleId() === StructureRoleProvider::RESPONSABLE) $isResponsable = $this->getStructureService()->isResponsableS($structures, $agent); if ($role->getRoleId() === StructureRoleProvider::GESTIONNAIRE) $isGestionnaire = $this->getStructureService()->isGestionnaireS($structures, $agent); if ($role->getRoleId() === Agent::ROLE_SUPERIEURE) $isSuperieur = $entity->hasSuperieurHierarchique($agent); if ($role->getRoleId() === Agent::ROLE_AUTORITE) $isAutorite = $entity->hasAutoriteHierarchique($agent); switch ($privilege) { case AgentaffichagePrivileges::AGENTAFFICHAGE_COMPTE : case AgentaffichagePrivileges::AGENTAFFICHAGE_AUTORITE : case AgentaffichagePrivileges::AGENTAFFICHAGE_SUPERIEUR : case AgentaffichagePrivileges::AGENTAFFICHAGE_CARRIERECOMPLETE : case AgentaffichagePrivileges::AGENTAFFICHAGE_DATERESUME : switch ($role->getRoleId()) { case AppRoleProvider::ADMIN_FONC: case AppRoleProvider::ADMIN_TECH: case AppRoleProvider::OBSERVATEUR: return true; case StructureRoleProvider::RESPONSABLE: return $isResponsable; case StructureRoleProvider::GESTIONNAIRE: return $isGestionnaire; case Agent::ROLE_SUPERIEURE: return $isSuperieur; case Agent::ROLE_AUTORITE: return $isAutorite; case AppRoleProvider::AGENT : return $entity === $agent; } return false; } return true; } } No newline at end of file module/Application/src/Application/Assertion/AgentAffichageAssertionFactory.php 0 → 100644 +48 −0 Original line number Diff line number Diff line <?php namespace Application\Assertion; use Application\Service\Agent\AgentService; use Application\Service\AgentAffectation\AgentAffectationService; use Interop\Container\ContainerInterface; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use Structure\Service\Structure\StructureService; use UnicaenUtilisateur\Service\User\UserService; use Laminas\Mvc\Application; class AgentAffichageAssertionFactory { /** * @param ContainerInterface $container * @return AgentAssertion * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function __invoke(ContainerInterface $container): AgentAssertion { /** * @var AgentService $agentService * @var AgentAffectationService $agentAffectationService * @var StructureService $structureService * @var UserService $userService */ $agentService = $container->get(AgentService::class); $agentAffectationService = $container->get(AgentAffectationService::class); $structureService = $container->get(StructureService::class); $userService = $container->get(UserService::class); /** @var AgentAssertion $assertion */ $assertion = new AgentAssertion(); $assertion->setAgentService($agentService); $assertion->setAgentAffectationService($agentAffectationService); $assertion->setStructureService($structureService); $assertion->setUserService($userService); /* @var $application Application */ $application = $container->get('Application'); $mvcEvent = $application->getMvcEvent(); $assertion->setMvcEvent($mvcEvent); return $assertion; } } No newline at end of file module/Application/src/Application/Provider/Privilege/AgentaffichagePrivileges.php 0 → 100644 +14 −0 Original line number Diff line number Diff line <?php namespace Application\Provider\Privilege; use UnicaenPrivilege\Provider\Privilege\Privileges; class AgentaffichagePrivileges extends Privileges { const AGENTAFFICHAGE_SUPERIEUR = 'agentaffichage-agentaffichage_superieur'; const AGENTAFFICHAGE_AUTORITE = 'agentaffichage-agentaffichage_autorite'; const AGENTAFFICHAGE_DATERESUME = 'agentaffichage-agentaffichage_dateresume'; const AGENTAFFICHAGE_CARRIERECOMPLETE = 'agentaffichage-agentaffichage_carrierecomplete'; const AGENTAFFICHAGE_COMPTE = 'agentaffichage-agentaffichage_compte'; } Loading
documentation/release/3.1.5.md +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ * Ajout des temoins hiérarchique et fonctionnelle pour les affectations * Ajout du pourcentage de l'affectation pour les affectations * Contrôle de l'affichage des infos de l'agent soumi à privilèges spécifiques * [FIX] correction de la route de retour lors de l'abonnement/désabonnement à une formation * [Formation] Ajout d'un bouton pour changer l'état vers un état donné sans respecter le circuit * [Structure] Retrait de la nommination manuelle des responsables et gestionnaires (on se fie plus qu'au référentiel) Loading
module/Application/config/merged/agent.config.php +15 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace Application; use Application\Assertion\AgentAffichageAssertion; use Application\Assertion\AgentAffichageAssertionFactory; use Application\Assertion\AgentAssertion; use Application\Assertion\AgentAssertionFactory; use Application\Controller\AgentController; Loading @@ -14,6 +16,7 @@ use Application\Form\SelectionAgent\SelectionAgentForm; use Application\Form\SelectionAgent\SelectionAgentFormFactory; use Application\Form\SelectionAgent\SelectionAgentHydrator; use Application\Form\SelectionAgent\SelectionAgentHydratorFactory; use Application\Provider\Privilege\AgentaffichagePrivileges; use Application\Provider\Privilege\AgentPrivileges; use Application\Service\Agent\AgentService; use Application\Service\Agent\AgentServiceFactory; Loading Loading @@ -62,6 +65,17 @@ return [ 'resources' => ['Agent'], 'assertion' => AgentAssertion::class ], [ 'privileges' => [ AgentaffichagePrivileges::AGENTAFFICHAGE_SUPERIEUR, AgentaffichagePrivileges::AGENTAFFICHAGE_AUTORITE, AgentaffichagePrivileges::AGENTAFFICHAGE_COMPTE, AgentaffichagePrivileges::AGENTAFFICHAGE_CARRIERECOMPLETE, AgentaffichagePrivileges::AGENTAFFICHAGE_DATERESUME, ], 'resources' => ['Agent'], 'assertion' => AgentAffichageAssertion::class ], ], ], ], Loading Loading @@ -376,6 +390,7 @@ return [ 'service_manager' => [ 'factories' => [ AgentAssertion::class => AgentAssertionFactory::class, AgentAffichageAssertion::class => AgentAffichageAssertionFactory::class, AgentService::class => AgentServiceFactory::class, AgentAffectationService::class => AgentAffectationServiceFactory::class, Loading
module/Application/src/Application/Assertion/AgentAffichageAssertion.php 0 → 100644 +79 −0 Original line number Diff line number Diff line <?php namespace Application\Assertion; use Application\Entity\Db\Agent; use Application\Provider\Privilege\AgentaffichagePrivileges; use Application\Provider\Role\RoleProvider as AppRoleProvider; use Application\Service\Agent\AgentServiceAwareTrait; use Application\Service\AgentAffectation\AgentAffectationServiceAwareTrait; use Structure\Provider\Role\RoleProvider as StructureRoleProvider; use Structure\Service\Structure\StructureServiceAwareTrait; use UnicaenPrivilege\Assertion\AbstractAssertion; use UnicaenUtilisateur\Service\User\UserServiceAwareTrait; use Laminas\Permissions\Acl\Resource\ResourceInterface; /** Note : pas besoin d'assertion de controller car cela n'est que de la gestion d'affichage sans routing */ class AgentAffichageAssertion extends AbstractAssertion { use AgentServiceAwareTrait; use AgentAffectationServiceAwareTrait; use StructureServiceAwareTrait; use UserServiceAwareTrait; protected function assertEntity(ResourceInterface $entity = null, $privilege = null): bool { if (!$entity instanceof Agent) { return false; } /** @var Agent $entity */ $user = $this->getUserService()->getConnectedUser(); $agent = $this->getAgentService()->getAgentByUser($user); $role = $this->getUserService()->getConnectedRole(); $structures = []; foreach ($entity->getAffectations() as $affectation) { $structures[] = $affectation->getStructure(); } foreach ($entity->getStructuresForcees() as $structureAgentForce) { $structures[] = $structureAgentForce->getStructure(); } $isResponsable = false; $isGestionnaire = false; $isSuperieur = false; $isAutorite = false; if ($role->getRoleId() === StructureRoleProvider::RESPONSABLE) $isResponsable = $this->getStructureService()->isResponsableS($structures, $agent); if ($role->getRoleId() === StructureRoleProvider::GESTIONNAIRE) $isGestionnaire = $this->getStructureService()->isGestionnaireS($structures, $agent); if ($role->getRoleId() === Agent::ROLE_SUPERIEURE) $isSuperieur = $entity->hasSuperieurHierarchique($agent); if ($role->getRoleId() === Agent::ROLE_AUTORITE) $isAutorite = $entity->hasAutoriteHierarchique($agent); switch ($privilege) { case AgentaffichagePrivileges::AGENTAFFICHAGE_COMPTE : case AgentaffichagePrivileges::AGENTAFFICHAGE_AUTORITE : case AgentaffichagePrivileges::AGENTAFFICHAGE_SUPERIEUR : case AgentaffichagePrivileges::AGENTAFFICHAGE_CARRIERECOMPLETE : case AgentaffichagePrivileges::AGENTAFFICHAGE_DATERESUME : switch ($role->getRoleId()) { case AppRoleProvider::ADMIN_FONC: case AppRoleProvider::ADMIN_TECH: case AppRoleProvider::OBSERVATEUR: return true; case StructureRoleProvider::RESPONSABLE: return $isResponsable; case StructureRoleProvider::GESTIONNAIRE: return $isGestionnaire; case Agent::ROLE_SUPERIEURE: return $isSuperieur; case Agent::ROLE_AUTORITE: return $isAutorite; case AppRoleProvider::AGENT : return $entity === $agent; } return false; } return true; } } No newline at end of file
module/Application/src/Application/Assertion/AgentAffichageAssertionFactory.php 0 → 100644 +48 −0 Original line number Diff line number Diff line <?php namespace Application\Assertion; use Application\Service\Agent\AgentService; use Application\Service\AgentAffectation\AgentAffectationService; use Interop\Container\ContainerInterface; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use Structure\Service\Structure\StructureService; use UnicaenUtilisateur\Service\User\UserService; use Laminas\Mvc\Application; class AgentAffichageAssertionFactory { /** * @param ContainerInterface $container * @return AgentAssertion * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function __invoke(ContainerInterface $container): AgentAssertion { /** * @var AgentService $agentService * @var AgentAffectationService $agentAffectationService * @var StructureService $structureService * @var UserService $userService */ $agentService = $container->get(AgentService::class); $agentAffectationService = $container->get(AgentAffectationService::class); $structureService = $container->get(StructureService::class); $userService = $container->get(UserService::class); /** @var AgentAssertion $assertion */ $assertion = new AgentAssertion(); $assertion->setAgentService($agentService); $assertion->setAgentAffectationService($agentAffectationService); $assertion->setStructureService($structureService); $assertion->setUserService($userService); /* @var $application Application */ $application = $container->get('Application'); $mvcEvent = $application->getMvcEvent(); $assertion->setMvcEvent($mvcEvent); return $assertion; } } No newline at end of file
module/Application/src/Application/Provider/Privilege/AgentaffichagePrivileges.php 0 → 100644 +14 −0 Original line number Diff line number Diff line <?php namespace Application\Provider\Privilege; use UnicaenPrivilege\Provider\Privilege\Privileges; class AgentaffichagePrivileges extends Privileges { const AGENTAFFICHAGE_SUPERIEUR = 'agentaffichage-agentaffichage_superieur'; const AGENTAFFICHAGE_AUTORITE = 'agentaffichage-agentaffichage_autorite'; const AGENTAFFICHAGE_DATERESUME = 'agentaffichage-agentaffichage_dateresume'; const AGENTAFFICHAGE_CARRIERECOMPLETE = 'agentaffichage-agentaffichage_carrierecomplete'; const AGENTAFFICHAGE_COMPTE = 'agentaffichage-agentaffichage_compte'; }