Loading module/These/src/These/Assertion/These/TheseAssertion.php +37 −30 Changes for module/These/src/These/Assertion/These/TheseAssertion.php: 37 added lines, 30 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Application\Assertion\AbstractAssertion; use Application\Assertion\Exception\FailedAssertionException; use Application\Entity\Db\Role; use Depot\Acl\WfEtapeResource; use Individu\Entity\Db\Individu; use Laminas\Permissions\Acl\Resource\ResourceInterface; use These\Entity\Db\These; use These\Provider\Privilege\ThesePrivileges; Loading Loading @@ -69,34 +70,7 @@ class TheseAssertion extends AbstractAssertion switch (true) { case $privilege === ThesePrivileges::THESE_CONSULTATION_SES_THESES: case $privilege === ThesePrivileges::THESE_MODIFICATION_SES_THESES: // doctorant if ($role->getCode() === Role::CODE_DOCTORANT) return $these->getDoctorant()->getIndividu() === $individu; // directeur if ($role->getCode() === Role::CODE_DIRECTEUR_THESE) { $directeurs = $these->getActeursByRoleCode(Role::CODE_DIRECTEUR_THESE); $individus = []; foreach ($directeurs as $directeur) $individus[] = $directeur->getIndividu(); return (array_search($individu, $individus) !== false); } if ($role->getCode() === Role::CODE_CODIRECTEUR_THESE) { $directeurs = $these->getActeursByRoleCode(Role::CODE_CODIRECTEUR_THESE); $individus = []; foreach ($directeurs as $directeur) $individus[] = $directeur->getIndividu(); return (array_search($individu, $individus) !== false); } // structure // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isEcoleDoctorale() : if (in_array($role->getCode(), [Role::CODE_RESP_ED, Role::CODE_GEST_ED])) { return $these->getEcoleDoctorale()->getStructure() === $role->getStructure(); } // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isUniteRecherche() : if (in_array($role->getCode(), [Role::CODE_RESP_UR, Role::CODE_GEST_UR])) { return $these->getUniteRecherche()->getStructure() === $role->getStructure(); } // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isEtablissement() : if ($role->getCode() === Role::CODE_ADMIN || $role->getCode() === Role::CODE_BDD || $role->getCode() === Role::CODE_BU) return $these->getEtablissement()->getStructure() === $role->getStructure(); break; $this->canGererThese($role, $individu, $these); } return true; Loading @@ -123,8 +97,9 @@ class TheseAssertion extends AbstractAssertion // if (! $this->userContextService->isStructureDuRoleRespecteeForThese($this->these)) { // return false; // } return true; $role = $this->userContextService->getSelectedIdentityRole(); $individu = $this->userContextService->getIdentityIndividu(); return $this->canGererThese($role, $individu, $this->these); } protected function assertControllerAsDoctorant(): bool Loading @@ -141,4 +116,36 @@ class TheseAssertion extends AbstractAssertion return $this->these->getDoctorant()->getId() === $identityDoctorant->getId(); } protected function canGererThese(Role $role, Individu $individu, These $these){ // doctorant if ($role->getCode() === Role::CODE_DOCTORANT) return $these->getDoctorant()->getIndividu() === $individu; // directeur if ($role->getCode() === Role::CODE_DIRECTEUR_THESE) { $directeurs = $these->getActeursByRoleCode(Role::CODE_DIRECTEUR_THESE); $individus = []; foreach ($directeurs as $directeur) $individus[] = $directeur->getIndividu(); return (array_search($individu, $individus) !== false); } if ($role->getCode() === Role::CODE_CODIRECTEUR_THESE) { $directeurs = $these->getActeursByRoleCode(Role::CODE_CODIRECTEUR_THESE); $individus = []; foreach ($directeurs as $directeur) $individus[] = $directeur->getIndividu(); return (array_search($individu, $individus) !== false); } // structure // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isEcoleDoctorale() : if (in_array($role->getCode(), [Role::CODE_RESP_ED, Role::CODE_GEST_ED])) { return $these->getEcoleDoctorale()->getStructure() === $role->getStructure(); } // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isUniteRecherche() : if (in_array($role->getCode(), [Role::CODE_RESP_UR, Role::CODE_GEST_UR])) { return $these->getUniteRecherche()->getStructure() === $role->getStructure(); } // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isEtablissement() : if ($role->getCode() === Role::CODE_ADMIN || $role->getCode() === Role::CODE_BDD || $role->getCode() === Role::CODE_BU) return $these->getEtablissement()->getStructure() === $role->getStructure(); return true; } } No newline at end of file module/These/src/These/Controller/TheseSaisieController.php +1 −1 Changes for module/These/src/These/Controller/TheseSaisieController.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ class TheseSaisieController extends AbstractController $this->flashMessenger()->addSuccessMessage("Thèse modifiée avec succès."); return $this->redirect()->toRoute('these/identite', ['these' => $these->getId()], ['fragment' => $domaine], true); return $this->redirect()->toRoute('these/identite', ['these' => $these->getId()], [], true); } private function getErrorMessages(): array Loading Loading
module/These/src/These/Assertion/These/TheseAssertion.php +37 −30 Changes for module/These/src/These/Assertion/These/TheseAssertion.php: 37 added lines, 30 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Application\Assertion\AbstractAssertion; use Application\Assertion\Exception\FailedAssertionException; use Application\Entity\Db\Role; use Depot\Acl\WfEtapeResource; use Individu\Entity\Db\Individu; use Laminas\Permissions\Acl\Resource\ResourceInterface; use These\Entity\Db\These; use These\Provider\Privilege\ThesePrivileges; Loading Loading @@ -69,34 +70,7 @@ class TheseAssertion extends AbstractAssertion switch (true) { case $privilege === ThesePrivileges::THESE_CONSULTATION_SES_THESES: case $privilege === ThesePrivileges::THESE_MODIFICATION_SES_THESES: // doctorant if ($role->getCode() === Role::CODE_DOCTORANT) return $these->getDoctorant()->getIndividu() === $individu; // directeur if ($role->getCode() === Role::CODE_DIRECTEUR_THESE) { $directeurs = $these->getActeursByRoleCode(Role::CODE_DIRECTEUR_THESE); $individus = []; foreach ($directeurs as $directeur) $individus[] = $directeur->getIndividu(); return (array_search($individu, $individus) !== false); } if ($role->getCode() === Role::CODE_CODIRECTEUR_THESE) { $directeurs = $these->getActeursByRoleCode(Role::CODE_CODIRECTEUR_THESE); $individus = []; foreach ($directeurs as $directeur) $individus[] = $directeur->getIndividu(); return (array_search($individu, $individus) !== false); } // structure // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isEcoleDoctorale() : if (in_array($role->getCode(), [Role::CODE_RESP_ED, Role::CODE_GEST_ED])) { return $these->getEcoleDoctorale()->getStructure() === $role->getStructure(); } // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isUniteRecherche() : if (in_array($role->getCode(), [Role::CODE_RESP_UR, Role::CODE_GEST_UR])) { return $these->getUniteRecherche()->getStructure() === $role->getStructure(); } // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isEtablissement() : if ($role->getCode() === Role::CODE_ADMIN || $role->getCode() === Role::CODE_BDD || $role->getCode() === Role::CODE_BU) return $these->getEtablissement()->getStructure() === $role->getStructure(); break; $this->canGererThese($role, $individu, $these); } return true; Loading @@ -123,8 +97,9 @@ class TheseAssertion extends AbstractAssertion // if (! $this->userContextService->isStructureDuRoleRespecteeForThese($this->these)) { // return false; // } return true; $role = $this->userContextService->getSelectedIdentityRole(); $individu = $this->userContextService->getIdentityIndividu(); return $this->canGererThese($role, $individu, $this->these); } protected function assertControllerAsDoctorant(): bool Loading @@ -141,4 +116,36 @@ class TheseAssertion extends AbstractAssertion return $this->these->getDoctorant()->getId() === $identityDoctorant->getId(); } protected function canGererThese(Role $role, Individu $individu, These $these){ // doctorant if ($role->getCode() === Role::CODE_DOCTORANT) return $these->getDoctorant()->getIndividu() === $individu; // directeur if ($role->getCode() === Role::CODE_DIRECTEUR_THESE) { $directeurs = $these->getActeursByRoleCode(Role::CODE_DIRECTEUR_THESE); $individus = []; foreach ($directeurs as $directeur) $individus[] = $directeur->getIndividu(); return (array_search($individu, $individus) !== false); } if ($role->getCode() === Role::CODE_CODIRECTEUR_THESE) { $directeurs = $these->getActeursByRoleCode(Role::CODE_CODIRECTEUR_THESE); $individus = []; foreach ($directeurs as $directeur) $individus[] = $directeur->getIndividu(); return (array_search($individu, $individus) !== false); } // structure // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isEcoleDoctorale() : if (in_array($role->getCode(), [Role::CODE_RESP_ED, Role::CODE_GEST_ED])) { return $these->getEcoleDoctorale()->getStructure() === $role->getStructure(); } // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isUniteRecherche() : if (in_array($role->getCode(), [Role::CODE_RESP_UR, Role::CODE_GEST_UR])) { return $these->getUniteRecherche()->getStructure() === $role->getStructure(); } // todo : remplacer par $role->isStructureDependant() && $role->getTypeStructureDependant()->isEtablissement() : if ($role->getCode() === Role::CODE_ADMIN || $role->getCode() === Role::CODE_BDD || $role->getCode() === Role::CODE_BU) return $these->getEtablissement()->getStructure() === $role->getStructure(); return true; } } No newline at end of file
module/These/src/These/Controller/TheseSaisieController.php +1 −1 Changes for module/These/src/These/Controller/TheseSaisieController.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ class TheseSaisieController extends AbstractController $this->flashMessenger()->addSuccessMessage("Thèse modifiée avec succès."); return $this->redirect()->toRoute('these/identite', ['these' => $these->getId()], ['fragment' => $domaine], true); return $this->redirect()->toRoute('these/identite', ['these' => $these->getId()], [], true); } private function getErrorMessages(): array Loading