Loading config/application.config.php +1 −0 Changes for config/application.config.php: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ $modules = [ 'UnicaenUtilisateurLdapAdapter', 'Mailing', 'UnicaenUtilisateur', 'UnicaenEtat', 'UnicaenDocument', 'UnicaenValidation', 'Autoform', Loading module/Application/src/Application/Assertion/StructureAssertion.php +1 −1 Changes for module/Application/src/Application/Assertion/StructureAssertion.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ class StructureAssertion extends AbstractAssertion { $isGestionnaire = $this->getStructureService()->isGestionnaire($entity, $user); } $isResponsable = false; if ($role->getRoleId() === RoleConstant::GESTIONNAIRE) { if ($role->getRoleId() === RoleConstant::RESPONSABLE) { $isResponsable = $this->getStructureService()->isResponsable($entity, $user); } Loading module/Application/src/Application/Controller/IndexController.php +4 −0 Changes for module/Application/src/Application/Controller/IndexController.php: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -59,6 +59,10 @@ class IndexController extends AbstractActionController $structures = $this->getStructureService()->getStructuresByGestionnaire($connectedUser); if (!empty($structures)) return $this->redirect()->toRoute('structure/afficher', ['structure' => $structures[0]->getId()], [], true); break; case RoleConstant::RESPONSABLE : $structures = $this->getStructureService()->getStructuresByResponsable($connectedUser); if (!empty($structures)) return $this->redirect()->toRoute('structure/afficher', ['structure' => $structures[0]->getId()], [], true); break; case RoleConstant::VALIDATEUR : return $this->redirect()->toRoute('index-validateur', [], [], true); break; Loading module/Application/src/Application/Controller/StructureController.php +19 −0 Changes for module/Application/src/Application/Controller/StructureController.php: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -64,6 +64,12 @@ class StructureController extends AbstractActionController { usort($structures, function(Structure $a, Structure $b) {return $a->getLibelleCourt() > $b->getLibelleCourt();}); $selecteur = $structures; } if ($role->getRoleId() === RoleConstant::RESPONSABLE) { $user = $this->getUserService()->getConnectedUser(); $structures = $this->getStructureService()->getStructuresByResponsable($user); usort($structures, function(Structure $a, Structure $b) {return $a->getLibelleCourt() > $b->getLibelleCourt();}); $selecteur = $structures; } if ($role->getRoleId() === RoleConstant::ADMIN_TECH OR $role->getRoleId() === RoleConstant::ADMIN_FONC OR $role->getRoleId() === RoleConstant::OBSERVATEUR) { $unicaen = $this->getStructureService()->getStructure(1); $structures = $this->getStructureService()->getSousStructures($unicaen, true); Loading Loading @@ -193,6 +199,12 @@ class StructureController extends AbstractActionController { $structure->removeGestionnaire($gestionnaire); $this->getStructureService()->update($structure); $structures = $this->getStructureService()->getStructuresByGestionnaire($gestionnaire); if (empty($structures)) { $role = $this->getRoleService()->getRoleByCode(RoleConstant::GESTIONNAIRE); $this->getUserService()->removeRole($gestionnaire, $role); } return $this->redirect()->toRoute('structure/afficher', ['structure' => $structure->getId()], [], true); } Loading Loading @@ -242,6 +254,13 @@ class StructureController extends AbstractActionController { $structure->removeResponsable($responsable); $this->getStructureService()->update($structure); $structures = $this->getStructureService()->getStructuresByResponsable($responsable); if (empty($structures)) { $role = $this->getRoleService()->getRoleByCode(RoleConstant::RESPONSABLE); $this->getUserService()->removeRole($responsable, $role); } return $this->redirect()->toRoute('structure/afficher', ['structure' => $structure->getId()], [], true); } Loading module/Application/src/Application/Service/Structure/StructureService.php +22 −0 Changes for module/Application/src/Application/Service/Structure/StructureService.php: 22 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -144,6 +144,28 @@ class StructureService return $result; } /** * @param User $user * @param bool $ouverte * @return Structure[] */ public function getStructuresByResponsable($user, $ouverte = true) { $qb = $this->getEntityManager()->getRepository(Structure::class)->createQueryBuilder('structure') ->join('structure.responsables', 'responsableSelection') ->addSelect('responsable')->join('structure.responsables', 'responsable') ->andWhere('responsableSelection.id = :userId') ->setParameter('userId', $user->getId()) ->orderBy('structure.libelleCourt') ->andWhere("structure.histo IS NULL") ; if ($ouverte) $qb = $qb->andWhere("structure.fermeture IS NULL"); $result = $qb->getQuery()->getResult(); return $result; } /** * @param Structure $structure * @param boolean $ouverte Loading Loading
config/application.config.php +1 −0 Changes for config/application.config.php: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ $modules = [ 'UnicaenUtilisateurLdapAdapter', 'Mailing', 'UnicaenUtilisateur', 'UnicaenEtat', 'UnicaenDocument', 'UnicaenValidation', 'Autoform', Loading
module/Application/src/Application/Assertion/StructureAssertion.php +1 −1 Changes for module/Application/src/Application/Assertion/StructureAssertion.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ class StructureAssertion extends AbstractAssertion { $isGestionnaire = $this->getStructureService()->isGestionnaire($entity, $user); } $isResponsable = false; if ($role->getRoleId() === RoleConstant::GESTIONNAIRE) { if ($role->getRoleId() === RoleConstant::RESPONSABLE) { $isResponsable = $this->getStructureService()->isResponsable($entity, $user); } Loading
module/Application/src/Application/Controller/IndexController.php +4 −0 Changes for module/Application/src/Application/Controller/IndexController.php: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -59,6 +59,10 @@ class IndexController extends AbstractActionController $structures = $this->getStructureService()->getStructuresByGestionnaire($connectedUser); if (!empty($structures)) return $this->redirect()->toRoute('structure/afficher', ['structure' => $structures[0]->getId()], [], true); break; case RoleConstant::RESPONSABLE : $structures = $this->getStructureService()->getStructuresByResponsable($connectedUser); if (!empty($structures)) return $this->redirect()->toRoute('structure/afficher', ['structure' => $structures[0]->getId()], [], true); break; case RoleConstant::VALIDATEUR : return $this->redirect()->toRoute('index-validateur', [], [], true); break; Loading
module/Application/src/Application/Controller/StructureController.php +19 −0 Changes for module/Application/src/Application/Controller/StructureController.php: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -64,6 +64,12 @@ class StructureController extends AbstractActionController { usort($structures, function(Structure $a, Structure $b) {return $a->getLibelleCourt() > $b->getLibelleCourt();}); $selecteur = $structures; } if ($role->getRoleId() === RoleConstant::RESPONSABLE) { $user = $this->getUserService()->getConnectedUser(); $structures = $this->getStructureService()->getStructuresByResponsable($user); usort($structures, function(Structure $a, Structure $b) {return $a->getLibelleCourt() > $b->getLibelleCourt();}); $selecteur = $structures; } if ($role->getRoleId() === RoleConstant::ADMIN_TECH OR $role->getRoleId() === RoleConstant::ADMIN_FONC OR $role->getRoleId() === RoleConstant::OBSERVATEUR) { $unicaen = $this->getStructureService()->getStructure(1); $structures = $this->getStructureService()->getSousStructures($unicaen, true); Loading Loading @@ -193,6 +199,12 @@ class StructureController extends AbstractActionController { $structure->removeGestionnaire($gestionnaire); $this->getStructureService()->update($structure); $structures = $this->getStructureService()->getStructuresByGestionnaire($gestionnaire); if (empty($structures)) { $role = $this->getRoleService()->getRoleByCode(RoleConstant::GESTIONNAIRE); $this->getUserService()->removeRole($gestionnaire, $role); } return $this->redirect()->toRoute('structure/afficher', ['structure' => $structure->getId()], [], true); } Loading Loading @@ -242,6 +254,13 @@ class StructureController extends AbstractActionController { $structure->removeResponsable($responsable); $this->getStructureService()->update($structure); $structures = $this->getStructureService()->getStructuresByResponsable($responsable); if (empty($structures)) { $role = $this->getRoleService()->getRoleByCode(RoleConstant::RESPONSABLE); $this->getUserService()->removeRole($responsable, $role); } return $this->redirect()->toRoute('structure/afficher', ['structure' => $structure->getId()], [], true); } Loading
module/Application/src/Application/Service/Structure/StructureService.php +22 −0 Changes for module/Application/src/Application/Service/Structure/StructureService.php: 22 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -144,6 +144,28 @@ class StructureService return $result; } /** * @param User $user * @param bool $ouverte * @return Structure[] */ public function getStructuresByResponsable($user, $ouverte = true) { $qb = $this->getEntityManager()->getRepository(Structure::class)->createQueryBuilder('structure') ->join('structure.responsables', 'responsableSelection') ->addSelect('responsable')->join('structure.responsables', 'responsable') ->andWhere('responsableSelection.id = :userId') ->setParameter('userId', $user->getId()) ->orderBy('structure.libelleCourt') ->andWhere("structure.histo IS NULL") ; if ($ouverte) $qb = $qb->andWhere("structure.fermeture IS NULL"); $result = $qb->getQuery()->getResult(); return $result; } /** * @param Structure $structure * @param boolean $ouverte Loading