Commit 3d15a3e9 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ouverture dans l'assertion de la gestion des elements des agents pour les...

Ouverture dans l'assertion de la gestion des elements des agents pour les rôles Supérieur et Autorité
parent dbaff85b
Loading
Loading
Loading
Loading
+10 −18
Changes for module/Application/src/Application/Assertion/AgentAssertion.php: 10 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -30,28 +30,16 @@ class AgentAssertion extends AbstractAssertion {
        $role = $this->getUserService()->getConnectedRole();


        $isGestionnaire = false;
        if ($role->getRoleId() === RoleProvider::GESTIONNAIRE) {
            $structures = [];
            foreach ($entity->getGrades() as $grade) {
                $structures[] = $grade->getStructure();
            }
            foreach ($structures as $structure) {
                $isGestionnaire = $this->getStructureService()->isGestionnaire($structure, $agent);
                if ($isGestionnaire) break;
            }
        }
        $isResponsable = false;
        if ($role->getRoleId() === RoleProvider::RESPONSABLE) {

        $structures = [];
        foreach ($entity->getAffectations() as $affectation) {
            $structures[] = $affectation->getStructure();
        }
            foreach ($structures as $structure) {
                $isResponsable = $this->getStructureService()->isResponsable($structure, $agent);
                if ($isResponsable) break;
            }
        }
        $isResponsable = false; $isGestionnaire = false; $isSuperieur = false; $isAutorite = false;
        if ($role->getRoleId() === RoleProvider::RESPONSABLE)  $isResponsable = $this->getStructureService()->isResponsableS($structures, $agent);
        if ($role->getRoleId() === RoleProvider::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->hasSuperieurHierarchique($agent);

        switch($privilege) {
            case AgentPrivileges::AGENT_ACQUIS_AFFICHER:
@@ -70,6 +58,10 @@ class AgentAssertion extends AbstractAssertion {
                            return $isGestionnaire;
                    case RoleProvider::RESPONSABLE:
                        return $isResponsable;
                    case Agent::ROLE_SUPERIEURE;
                        return $isSuperieur;
                    case Agent::ROLE_AUTORITE;
                        return $isAutorite;
                }
                return false;
            case AgentPrivileges::AGENT_ELEMENT_DETRUIRE:
−4
Changes for module/Application/src/Application/Controller/IndexController.php: 0 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -37,9 +37,6 @@ class IndexController extends AbstractActionController
        if ($agent !== null && $agent->getUtilisateur() === null) {
            $agent->setUtilisateur($connectedUser);
            $this->getAgentService()->update($agent);
//            $personnel = $this->getRoleService()->findByRoleId(RoleConstant::PERSONNEL);
//            $hasAgent = $connectedUser->hasRole($personnel);
//            if (! $hasAgent) $this->getUserService()->addRole($connectedUser, $personnel);
            return $this->redirect()->toRoute('agent/afficher', ['agent' => $agent->getId()], [], true);
        }

@@ -63,7 +60,6 @@ class IndexController extends AbstractActionController
                    break;
                case EntretienProfessionnelConstant::ROLE_DELEGUE :
                    return $this->redirect()->toRoute('entretien-professionnel/index-delegue', [], [], true);
                    break;
                case Agent::ROLE_SUPERIEURE :
                    /** @see IndexController::indexSuperieurAction() */
                    return $this->redirect()->toRoute('index-superieur', [], [], true);