Loading module/Application/config/others/rapports.config.php +21 −18 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ namespace Application; use Application\Assertion\RapportActivite\RapportActiviteAssertion; use Application\Assertion\Rapport\RapportAssertion; use Application\Controller\Factory\Rapport\RapportActiviteControllerFactory; use Application\Controller\Factory\Rapport\RapportActiviteRechercheControllerFactory; use Application\Controller\Factory\Rapport\RapportCsiControllerFactory; Loading Loading @@ -81,7 +81,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_TELECHARGER_SIEN, ], 'resources' => ['Rapport'], 'assertion' => 'Assertion\\RapportActivite', /** @see RapportActiviteAssertion */ 'assertion' => 'Assertion\\Rapport', /** @see RapportAssertion */ ], ], ], Loading @@ -98,7 +98,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_LISTER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_LISTER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportActiviteController::class, Loading @@ -109,7 +109,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_TELECHARGER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_TELECHARGER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportActiviteController::class, Loading @@ -120,7 +120,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_TELEVERSER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_TELEVERSER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportActiviteController::class, Loading @@ -131,7 +131,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_SUPPRIMER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_SUPPRIMER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportActiviteRechercheController::class, Loading @@ -143,7 +143,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_RECHERCHER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_RECHERCHER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportActiviteRechercheController::class, Loading @@ -151,7 +151,7 @@ return [ 'telecharger-zip', ], 'privileges' => RapportPrivileges::RAPPORT_ACTIVITE_TELECHARGER_ZIP, 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportValidationController::class, Loading @@ -162,7 +162,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportValidationController::class, Loading @@ -173,7 +173,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], ////////////////////////////////////////// Rapports CSI ////////////////////////////////////////// Loading @@ -186,7 +186,7 @@ return [ RapportPrivileges::RAPPORT_CSI_LISTER_TOUT, RapportPrivileges::RAPPORT_CSI_LISTER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportCsiController::class, Loading @@ -197,7 +197,7 @@ return [ RapportPrivileges::RAPPORT_CSI_TELECHARGER_TOUT, RapportPrivileges::RAPPORT_CSI_TELECHARGER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportCsiController::class, Loading @@ -208,7 +208,7 @@ return [ RapportPrivileges::RAPPORT_CSI_TELEVERSER_TOUT, RapportPrivileges::RAPPORT_CSI_TELEVERSER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportCsiController::class, Loading @@ -219,7 +219,7 @@ return [ RapportPrivileges::RAPPORT_CSI_SUPPRIMER_TOUT, RapportPrivileges::RAPPORT_CSI_SUPPRIMER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportCsiRechercheController::class, Loading Loading @@ -250,7 +250,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_LISTER_TOUT, RapportPrivileges::RAPPORT_MIPARCOURS_LISTER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportMiparcoursController::class, Loading @@ -261,7 +261,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_TELECHARGER_TOUT, RapportPrivileges::RAPPORT_MIPARCOURS_TELECHARGER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportMiparcoursController::class, Loading @@ -272,7 +272,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_TELEVERSER_TOUT, RapportPrivileges::RAPPORT_MIPARCOURS_TELEVERSER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportMiparcoursController::class, Loading @@ -283,7 +283,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_TOUT, RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportMiparcoursRechercheController::class, Loading Loading @@ -676,6 +676,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_RECHERCHER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_RECHERCHER_SIEN, ], 'visible' => 'Assertion\\Rapport', ], 'rapport-csi' => [ 'label' => "Rapports CSI", Loading @@ -686,6 +687,7 @@ return [ RapportPrivileges::RAPPORT_CSI_RECHERCHER_TOUT, RapportPrivileges::RAPPORT_CSI_RECHERCHER_SIEN, ], 'visible' => 'Assertion\\Rapport', ], 'rapport-miparcours' => [ 'label' => "Rapports mi-parcours", Loading @@ -696,6 +698,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_RECHERCHER_TOUT, RapportPrivileges::RAPPORT_MIPARCOURS_RECHERCHER_SIEN, ], 'visible' => 'Assertion\\Rapport', ], '----------' => [ 'label' => null, Loading module/Application/config/others/these.config.php +3 −0 Original line number Diff line number Diff line Loading @@ -951,6 +951,7 @@ return [ 'these', ], 'resource' => PrivilegeController::getResourceId(RapportActiviteController::class, 'consulter'), 'visible' => 'Assertion\\Rapport', ], 'rapport-csi' => [ 'label' => 'Rapports CSI', Loading @@ -961,6 +962,7 @@ return [ 'these', ], 'resource' => PrivilegeController::getResourceId(RapportCsiController::class, 'consulter'), 'visible' => 'Assertion\\Rapport', ], 'rapport-miparcours' => [ 'label' => 'Rapports mi-parcours', Loading @@ -971,6 +973,7 @@ return [ 'these', ], 'resource' => PrivilegeController::getResourceId(RapportMiparcoursController::class, 'consulter'), 'visible' => 'Assertion\\Rapport', ], 'divider-2' => [ 'label' => null, Loading module/Application/src/Application/Assertion/RapportActivite/RapportActiviteAssertion.php→module/Application/src/Application/Assertion/Rapport/RapportAssertion.php +20 −30 Original line number Diff line number Diff line <?php namespace Application\Assertion\RapportActivite; namespace Application\Assertion\Rapport; use Application\Assertion\BaseAssertion; use Application\Entity\Db\Rapport; use Zend\Permissions\Acl\Resource\ResourceInterface; class RapportActiviteAssertion extends BaseAssertion /** * Class RapportAssertion * * @property \Application\Assertion\Rapport\RapportEntityAssertion $entityAssertion * @property \Application\Assertion\Rapport\RapportControllerAssertion $controllerAssertion * @property \Application\Assertion\Rapport\RapportPageAssertion $pageAssertion */ class RapportAssertion extends BaseAssertion { protected function getContext(): array { return [ 'these' => $this->getRouteMatch()->getThese(), 'rapport' => $this->getRouteMatch()->getRapport(), ]; } /** * @return self */ protected function initControllerAssertion(): self { $this->controllerAssertion->setContext([ 'rapport' => $this->getRapportActivite(), ]); $this->controllerAssertion->setContext($this->getContext()); return $this; } Loading @@ -25,9 +37,7 @@ class RapportActiviteAssertion extends BaseAssertion */ protected function initPageAssertion(): self { $this->pageAssertion->setContext([ 'rapport' => $this->getRapportActivite(), ]); $this->pageAssertion->setContext($this->getContext()); return $this; } Loading @@ -38,28 +48,8 @@ class RapportActiviteAssertion extends BaseAssertion */ protected function initEntityAssertion(ResourceInterface $entity): self { $this->entityAssertion->setContext([ 'rapport' => $entity, ]); $this->entityAssertion->setContext(['rapport' => $entity]); return $this; } /** * @return Rapport|null */ protected function getRapportActivite(): ?Rapport { $these = $this->getRouteMatch()->getThese(); $rapport = $this->getRouteMatch()->getRapport(); // if ($rapport === null) { // $rapport = new Rapport(); // if ($these !== null) { // $rapport->setThese($these); // } // } return $rapport; } } No newline at end of file module/Application/src/Application/Assertion/RapportActivite/RapportActiviteControllerAssertion.php→module/Application/src/Application/Assertion/Rapport/RapportControllerAssertion.php +17 −16 Original line number Diff line number Diff line <?php namespace Application\Assertion\RapportActivite; namespace Application\Assertion\Rapport; use Application\Assertion\ControllerAssertion; use Application\Assertion\ThrowsFailedAssertionExceptionTrait; use Application\Entity\Db\Doctorant; use Application\Entity\Db\Rapport; use Application\Entity\Db\These; use Application\Provider\Privilege\RapportPrivileges; use Application\Service\UserContextServiceAwareTrait; class RapportActiviteControllerAssertion extends ControllerAssertion class RapportControllerAssertion extends ControllerAssertion { use ThrowsFailedAssertionExceptionTrait; use UserContextServiceAwareTrait; /** * @var Rapport * @var \Application\Entity\Db\These */ private $rapport; private $these; /** * @param array $context */ public function setContext(array $context) { $this->rapport = $context['rapport'] ?? null; $this->these = $context['these'] ?? null; } /** * @inheritDoc */ public function assert($privilege = null) public function assert($privilege = null): bool { if ($this->rapport === null) { return true; } if ($this->rapport->getThese() === null) { if ($this->these === null) { return true; } Loading @@ -49,15 +42,23 @@ class RapportActiviteControllerAssertion extends ControllerAssertion { if ($doctorant = $this->userContextService->getIdentityDoctorant()) { $this->assertTrue( $this->rapport->getThese()->getDoctorant()->getId() === $doctorant->getId(), $this->these->getDoctorant()->getId() === $doctorant->getId(), "La thèse n'appartient pas au doctorant " . $doctorant ); } if ($roleEcoleDoctorale = $this->userContextService->getSelectedRoleDirecteurEcoleDoctorale()) { $this->assertTrue( $this->rapport->getThese()->getEcoleDoctorale()->getStructure()->getId() === $roleEcoleDoctorale->getStructure()->getId(), $this->these->getEcoleDoctorale()->getStructure()->getId() === $roleEcoleDoctorale->getStructure()->getId(), "La thèse n'est pas rattachée à l'ED " . $roleEcoleDoctorale->getStructure()->getCode() ); } if ($this->userContextService->getSelectedRoleDirecteurThese()) { $individuUtilisateur = $this->userContextService->getIdentityDb()->getIndividu(); $this->assertTrue( $this->these->hasActeurWithRole($individuUtilisateur, \Application\Entity\Db\Role::CODE_DIRECTEUR_THESE) || $this->these->hasActeurWithRole($individuUtilisateur, \Application\Entity\Db\Role::CODE_CODIRECTEUR_THESE), "La thèse n'est pas dirigée par " . $individuUtilisateur ); } } } No newline at end of file module/Application/src/Application/Assertion/RapportActivite/RapportActiviteEntityAssertion.php→module/Application/src/Application/Assertion/Rapport/RapportEntityAssertion.php +36 −4 Original line number Diff line number Diff line <?php namespace Application\Assertion\RapportActivite; namespace Application\Assertion\Rapport; use Application\Assertion\Exception\FailedAssertionException; use Application\Assertion\Interfaces\EntityAssertionInterface; use Application\Assertion\ThrowsFailedAssertionExceptionTrait; use Application\Entity\Db\Rapport; use Application\Entity\Db\Role; use Application\Entity\Db\These; use Application\Entity\Db\TypeValidation; use Application\Provider\Privilege\RapportPrivileges; use Application\Service\UserContextServiceAwareTrait; class RapportActiviteEntityAssertion implements EntityAssertionInterface class RapportEntityAssertion implements EntityAssertionInterface { use UserContextServiceAwareTrait; use ThrowsFailedAssertionExceptionTrait; Loading Loading @@ -45,6 +45,16 @@ class RapportActiviteEntityAssertion implements EntityAssertionInterface case RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_SIEN: case RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_TOUT: case RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_SIEN: case RapportPrivileges::RAPPORT_CSI_TELEVERSER_TOUT: case RapportPrivileges::RAPPORT_CSI_TELEVERSER_SIEN: case RapportPrivileges::RAPPORT_CSI_SUPPRIMER_TOUT: case RapportPrivileges::RAPPORT_CSI_SUPPRIMER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_TELEVERSER_TOUT: case RapportPrivileges::RAPPORT_MIPARCOURS_TELEVERSER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_TOUT: case RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_SIEN: $this->assertEtatThese(); } Loading @@ -56,6 +66,14 @@ class RapportActiviteEntityAssertion implements EntityAssertionInterface case RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_SIEN: case RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_TOUT: case RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_SIEN: case RapportPrivileges::RAPPORT_CSI_TELEVERSER_SIEN: case RapportPrivileges::RAPPORT_CSI_SUPPRIMER_SIEN: case RapportPrivileges::RAPPORT_CSI_TELECHARGER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_TELEVERSER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_TELECHARGER_SIEN: $this->assertAppartenanceThese(); } Loading @@ -64,6 +82,12 @@ class RapportActiviteEntityAssertion implements EntityAssertionInterface case RapportPrivileges::RAPPORT_ACTIVITE_SUPPRIMER_SIEN: case RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_TOUT: case RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_SIEN: case RapportPrivileges::RAPPORT_CSI_SUPPRIMER_TOUT: case RapportPrivileges::RAPPORT_CSI_SUPPRIMER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_TOUT: case RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_SIEN: $this->assertAucuneValidation(); } Loading @@ -84,6 +108,14 @@ class RapportActiviteEntityAssertion implements EntityAssertionInterface "La thèse n'est pas rattachée à l'ED " . $roleEcoleDoctorale->getStructure()->getCode() ); } if ($this->userContextService->getSelectedRoleDirecteurThese()) { $individuUtilisateur = $this->userContextService->getIdentityDb()->getIndividu(); $this->assertTrue( $this->rapport->getThese()->hasActeurWithRole($individuUtilisateur, Role::CODE_DIRECTEUR_THESE) || $this->rapport->getThese()->hasActeurWithRole($individuUtilisateur, Role::CODE_CODIRECTEUR_THESE), "La thèse n'est pas dirigée par " . $individuUtilisateur ); } } private function assertEtatThese() Loading @@ -97,7 +129,7 @@ class RapportActiviteEntityAssertion implements EntityAssertionInterface private function assertAucuneValidation() { $this->assertTrue( $this->rapport->getRapportValidationOfType(TypeValidation::CODE_RAPPORT_ACTIVITE) === null, $this->rapport->getRapportValidation() === null, "Le rapport ne doit pas avoir été validé" ); } Loading Loading
module/Application/config/others/rapports.config.php +21 −18 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ namespace Application; use Application\Assertion\RapportActivite\RapportActiviteAssertion; use Application\Assertion\Rapport\RapportAssertion; use Application\Controller\Factory\Rapport\RapportActiviteControllerFactory; use Application\Controller\Factory\Rapport\RapportActiviteRechercheControllerFactory; use Application\Controller\Factory\Rapport\RapportCsiControllerFactory; Loading Loading @@ -81,7 +81,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_TELECHARGER_SIEN, ], 'resources' => ['Rapport'], 'assertion' => 'Assertion\\RapportActivite', /** @see RapportActiviteAssertion */ 'assertion' => 'Assertion\\Rapport', /** @see RapportAssertion */ ], ], ], Loading @@ -98,7 +98,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_LISTER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_LISTER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportActiviteController::class, Loading @@ -109,7 +109,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_TELECHARGER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_TELECHARGER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportActiviteController::class, Loading @@ -120,7 +120,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_TELEVERSER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_TELEVERSER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportActiviteController::class, Loading @@ -131,7 +131,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_SUPPRIMER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_SUPPRIMER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportActiviteRechercheController::class, Loading @@ -143,7 +143,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_RECHERCHER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_RECHERCHER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportActiviteRechercheController::class, Loading @@ -151,7 +151,7 @@ return [ 'telecharger-zip', ], 'privileges' => RapportPrivileges::RAPPORT_ACTIVITE_TELECHARGER_ZIP, 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportValidationController::class, Loading @@ -162,7 +162,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportValidationController::class, Loading @@ -173,7 +173,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], ////////////////////////////////////////// Rapports CSI ////////////////////////////////////////// Loading @@ -186,7 +186,7 @@ return [ RapportPrivileges::RAPPORT_CSI_LISTER_TOUT, RapportPrivileges::RAPPORT_CSI_LISTER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportCsiController::class, Loading @@ -197,7 +197,7 @@ return [ RapportPrivileges::RAPPORT_CSI_TELECHARGER_TOUT, RapportPrivileges::RAPPORT_CSI_TELECHARGER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportCsiController::class, Loading @@ -208,7 +208,7 @@ return [ RapportPrivileges::RAPPORT_CSI_TELEVERSER_TOUT, RapportPrivileges::RAPPORT_CSI_TELEVERSER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportCsiController::class, Loading @@ -219,7 +219,7 @@ return [ RapportPrivileges::RAPPORT_CSI_SUPPRIMER_TOUT, RapportPrivileges::RAPPORT_CSI_SUPPRIMER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportCsiRechercheController::class, Loading Loading @@ -250,7 +250,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_LISTER_TOUT, RapportPrivileges::RAPPORT_MIPARCOURS_LISTER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportMiparcoursController::class, Loading @@ -261,7 +261,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_TELECHARGER_TOUT, RapportPrivileges::RAPPORT_MIPARCOURS_TELECHARGER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportMiparcoursController::class, Loading @@ -272,7 +272,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_TELEVERSER_TOUT, RapportPrivileges::RAPPORT_MIPARCOURS_TELEVERSER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportMiparcoursController::class, Loading @@ -283,7 +283,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_TOUT, RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_SIEN, ], 'assertion' => 'Assertion\\RapportActivite', 'assertion' => 'Assertion\\Rapport', ], [ 'controller' => RapportMiparcoursRechercheController::class, Loading Loading @@ -676,6 +676,7 @@ return [ RapportPrivileges::RAPPORT_ACTIVITE_RECHERCHER_TOUT, RapportPrivileges::RAPPORT_ACTIVITE_RECHERCHER_SIEN, ], 'visible' => 'Assertion\\Rapport', ], 'rapport-csi' => [ 'label' => "Rapports CSI", Loading @@ -686,6 +687,7 @@ return [ RapportPrivileges::RAPPORT_CSI_RECHERCHER_TOUT, RapportPrivileges::RAPPORT_CSI_RECHERCHER_SIEN, ], 'visible' => 'Assertion\\Rapport', ], 'rapport-miparcours' => [ 'label' => "Rapports mi-parcours", Loading @@ -696,6 +698,7 @@ return [ RapportPrivileges::RAPPORT_MIPARCOURS_RECHERCHER_TOUT, RapportPrivileges::RAPPORT_MIPARCOURS_RECHERCHER_SIEN, ], 'visible' => 'Assertion\\Rapport', ], '----------' => [ 'label' => null, Loading
module/Application/config/others/these.config.php +3 −0 Original line number Diff line number Diff line Loading @@ -951,6 +951,7 @@ return [ 'these', ], 'resource' => PrivilegeController::getResourceId(RapportActiviteController::class, 'consulter'), 'visible' => 'Assertion\\Rapport', ], 'rapport-csi' => [ 'label' => 'Rapports CSI', Loading @@ -961,6 +962,7 @@ return [ 'these', ], 'resource' => PrivilegeController::getResourceId(RapportCsiController::class, 'consulter'), 'visible' => 'Assertion\\Rapport', ], 'rapport-miparcours' => [ 'label' => 'Rapports mi-parcours', Loading @@ -971,6 +973,7 @@ return [ 'these', ], 'resource' => PrivilegeController::getResourceId(RapportMiparcoursController::class, 'consulter'), 'visible' => 'Assertion\\Rapport', ], 'divider-2' => [ 'label' => null, Loading
module/Application/src/Application/Assertion/RapportActivite/RapportActiviteAssertion.php→module/Application/src/Application/Assertion/Rapport/RapportAssertion.php +20 −30 Original line number Diff line number Diff line <?php namespace Application\Assertion\RapportActivite; namespace Application\Assertion\Rapport; use Application\Assertion\BaseAssertion; use Application\Entity\Db\Rapport; use Zend\Permissions\Acl\Resource\ResourceInterface; class RapportActiviteAssertion extends BaseAssertion /** * Class RapportAssertion * * @property \Application\Assertion\Rapport\RapportEntityAssertion $entityAssertion * @property \Application\Assertion\Rapport\RapportControllerAssertion $controllerAssertion * @property \Application\Assertion\Rapport\RapportPageAssertion $pageAssertion */ class RapportAssertion extends BaseAssertion { protected function getContext(): array { return [ 'these' => $this->getRouteMatch()->getThese(), 'rapport' => $this->getRouteMatch()->getRapport(), ]; } /** * @return self */ protected function initControllerAssertion(): self { $this->controllerAssertion->setContext([ 'rapport' => $this->getRapportActivite(), ]); $this->controllerAssertion->setContext($this->getContext()); return $this; } Loading @@ -25,9 +37,7 @@ class RapportActiviteAssertion extends BaseAssertion */ protected function initPageAssertion(): self { $this->pageAssertion->setContext([ 'rapport' => $this->getRapportActivite(), ]); $this->pageAssertion->setContext($this->getContext()); return $this; } Loading @@ -38,28 +48,8 @@ class RapportActiviteAssertion extends BaseAssertion */ protected function initEntityAssertion(ResourceInterface $entity): self { $this->entityAssertion->setContext([ 'rapport' => $entity, ]); $this->entityAssertion->setContext(['rapport' => $entity]); return $this; } /** * @return Rapport|null */ protected function getRapportActivite(): ?Rapport { $these = $this->getRouteMatch()->getThese(); $rapport = $this->getRouteMatch()->getRapport(); // if ($rapport === null) { // $rapport = new Rapport(); // if ($these !== null) { // $rapport->setThese($these); // } // } return $rapport; } } No newline at end of file
module/Application/src/Application/Assertion/RapportActivite/RapportActiviteControllerAssertion.php→module/Application/src/Application/Assertion/Rapport/RapportControllerAssertion.php +17 −16 Original line number Diff line number Diff line <?php namespace Application\Assertion\RapportActivite; namespace Application\Assertion\Rapport; use Application\Assertion\ControllerAssertion; use Application\Assertion\ThrowsFailedAssertionExceptionTrait; use Application\Entity\Db\Doctorant; use Application\Entity\Db\Rapport; use Application\Entity\Db\These; use Application\Provider\Privilege\RapportPrivileges; use Application\Service\UserContextServiceAwareTrait; class RapportActiviteControllerAssertion extends ControllerAssertion class RapportControllerAssertion extends ControllerAssertion { use ThrowsFailedAssertionExceptionTrait; use UserContextServiceAwareTrait; /** * @var Rapport * @var \Application\Entity\Db\These */ private $rapport; private $these; /** * @param array $context */ public function setContext(array $context) { $this->rapport = $context['rapport'] ?? null; $this->these = $context['these'] ?? null; } /** * @inheritDoc */ public function assert($privilege = null) public function assert($privilege = null): bool { if ($this->rapport === null) { return true; } if ($this->rapport->getThese() === null) { if ($this->these === null) { return true; } Loading @@ -49,15 +42,23 @@ class RapportActiviteControllerAssertion extends ControllerAssertion { if ($doctorant = $this->userContextService->getIdentityDoctorant()) { $this->assertTrue( $this->rapport->getThese()->getDoctorant()->getId() === $doctorant->getId(), $this->these->getDoctorant()->getId() === $doctorant->getId(), "La thèse n'appartient pas au doctorant " . $doctorant ); } if ($roleEcoleDoctorale = $this->userContextService->getSelectedRoleDirecteurEcoleDoctorale()) { $this->assertTrue( $this->rapport->getThese()->getEcoleDoctorale()->getStructure()->getId() === $roleEcoleDoctorale->getStructure()->getId(), $this->these->getEcoleDoctorale()->getStructure()->getId() === $roleEcoleDoctorale->getStructure()->getId(), "La thèse n'est pas rattachée à l'ED " . $roleEcoleDoctorale->getStructure()->getCode() ); } if ($this->userContextService->getSelectedRoleDirecteurThese()) { $individuUtilisateur = $this->userContextService->getIdentityDb()->getIndividu(); $this->assertTrue( $this->these->hasActeurWithRole($individuUtilisateur, \Application\Entity\Db\Role::CODE_DIRECTEUR_THESE) || $this->these->hasActeurWithRole($individuUtilisateur, \Application\Entity\Db\Role::CODE_CODIRECTEUR_THESE), "La thèse n'est pas dirigée par " . $individuUtilisateur ); } } } No newline at end of file
module/Application/src/Application/Assertion/RapportActivite/RapportActiviteEntityAssertion.php→module/Application/src/Application/Assertion/Rapport/RapportEntityAssertion.php +36 −4 Original line number Diff line number Diff line <?php namespace Application\Assertion\RapportActivite; namespace Application\Assertion\Rapport; use Application\Assertion\Exception\FailedAssertionException; use Application\Assertion\Interfaces\EntityAssertionInterface; use Application\Assertion\ThrowsFailedAssertionExceptionTrait; use Application\Entity\Db\Rapport; use Application\Entity\Db\Role; use Application\Entity\Db\These; use Application\Entity\Db\TypeValidation; use Application\Provider\Privilege\RapportPrivileges; use Application\Service\UserContextServiceAwareTrait; class RapportActiviteEntityAssertion implements EntityAssertionInterface class RapportEntityAssertion implements EntityAssertionInterface { use UserContextServiceAwareTrait; use ThrowsFailedAssertionExceptionTrait; Loading Loading @@ -45,6 +45,16 @@ class RapportActiviteEntityAssertion implements EntityAssertionInterface case RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_SIEN: case RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_TOUT: case RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_SIEN: case RapportPrivileges::RAPPORT_CSI_TELEVERSER_TOUT: case RapportPrivileges::RAPPORT_CSI_TELEVERSER_SIEN: case RapportPrivileges::RAPPORT_CSI_SUPPRIMER_TOUT: case RapportPrivileges::RAPPORT_CSI_SUPPRIMER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_TELEVERSER_TOUT: case RapportPrivileges::RAPPORT_MIPARCOURS_TELEVERSER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_TOUT: case RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_SIEN: $this->assertEtatThese(); } Loading @@ -56,6 +66,14 @@ class RapportActiviteEntityAssertion implements EntityAssertionInterface case RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_SIEN: case RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_TOUT: case RapportPrivileges::RAPPORT_ACTIVITE_DEVALIDER_SIEN: case RapportPrivileges::RAPPORT_CSI_TELEVERSER_SIEN: case RapportPrivileges::RAPPORT_CSI_SUPPRIMER_SIEN: case RapportPrivileges::RAPPORT_CSI_TELECHARGER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_TELEVERSER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_TELECHARGER_SIEN: $this->assertAppartenanceThese(); } Loading @@ -64,6 +82,12 @@ class RapportActiviteEntityAssertion implements EntityAssertionInterface case RapportPrivileges::RAPPORT_ACTIVITE_SUPPRIMER_SIEN: case RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_TOUT: case RapportPrivileges::RAPPORT_ACTIVITE_VALIDER_SIEN: case RapportPrivileges::RAPPORT_CSI_SUPPRIMER_TOUT: case RapportPrivileges::RAPPORT_CSI_SUPPRIMER_SIEN: case RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_TOUT: case RapportPrivileges::RAPPORT_MIPARCOURS_SUPPRIMER_SIEN: $this->assertAucuneValidation(); } Loading @@ -84,6 +108,14 @@ class RapportActiviteEntityAssertion implements EntityAssertionInterface "La thèse n'est pas rattachée à l'ED " . $roleEcoleDoctorale->getStructure()->getCode() ); } if ($this->userContextService->getSelectedRoleDirecteurThese()) { $individuUtilisateur = $this->userContextService->getIdentityDb()->getIndividu(); $this->assertTrue( $this->rapport->getThese()->hasActeurWithRole($individuUtilisateur, Role::CODE_DIRECTEUR_THESE) || $this->rapport->getThese()->hasActeurWithRole($individuUtilisateur, Role::CODE_CODIRECTEUR_THESE), "La thèse n'est pas dirigée par " . $individuUtilisateur ); } } private function assertEtatThese() Loading @@ -97,7 +129,7 @@ class RapportActiviteEntityAssertion implements EntityAssertionInterface private function assertAucuneValidation() { $this->assertTrue( $this->rapport->getRapportValidationOfType(TypeValidation::CODE_RAPPORT_ACTIVITE) === null, $this->rapport->getRapportValidation() === null, "Le rapport ne doit pas avoir été validé" ); } Loading