Loading front/Mission/OffreEmploi.vue +5 −6 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ <div class="card-header"> <h4> {{ offre.titre }}</h4> <span class="badge rounded-pill bg-info">{{ offre.nombreHeures }} heure(s)</span> <span class="badge rounded-pill bg-info">{{ offre.nombrePostes }} poste(s)</span> <span class="badge rounded-pill bg-info">{{ offre.nombrePostes }} poste(s) restant(s)</span> <span v-if="offre.validation && !this.public" class="badge rounded-pill bg-success">Valider le <u-date :value="offre.validation.histoCreation"/> par {{ offre.validation.histoCreateur.displayName }}</span> <span v-if="!offre.validation && !this.public" class="badge rounded-pill bg-warning"> En attente de validation par la DRH</span> Loading @@ -30,19 +30,19 @@ </div> <div class="card-footer"> <div class="d-grid gap-2 d-md-flex justify-content-md-end"> <a v-if="offre.validation && this.canValider && !this.public" <a v-if="offre.validation && offre.canValide && !this.public" :href="devaliderUrl" class="btn btn-danger" @click.prevent="devalider">Devalider</a> <a v-if="!offre.validation && this.canValider && !this.public" <a v-if="!offre.validation && offre.canValide && !this.public" :href="validerUrl" class="btn btn-success" @click.prevent="valider">Valider</a> <a v-if="this.canModifier && !this.public" <a v-if="offre.canSaisie && !this.public" :href="saisirUrl" class="btn btn-primary" @click.prevent="saisir">Modifier</a> <a v-if="this.canSupprimer && !this.public" <a v-if="offre.canSupprime && !this.public" :href="supprimerUrl" class="btn btn-danger" data-title="Suppression de l'offre" Loading Loading @@ -122,7 +122,6 @@ export default { utilisateur: {required: false}, intervenant: {required: false}, extended: {type: Boolean, required: false}, canModifier: {type: Boolean, required: false}, canPostuler: {type: Boolean, required: false}, canValider: {type: Boolean, required: false}, canSupprimer: {type: Boolean, required: false}, Loading module/Application/config/gestion.config.php +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ return [ Privileges::PILOTAGE_VISUALISATION, Privileges::BUDGET_VISUALISATION, Privileges::INDICATEUR_VISUALISATION, Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], 'assertion' => Assertion\GestionAssertion::class, ], Loading module/Mission/config/module.config.php +0 −118 Original line number Diff line number Diff line Loading @@ -128,63 +128,6 @@ return [ ], ], ], 'offre-emploi' => [ 'route' => '/offre-emploi', 'controller' => OffreEmploiController::class, 'action' => 'index', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, 'may_terminate' => true, 'child_routes' => [ 'saisir' => [ 'route' => '/saisir[/:offreEmploi]', 'controller' => OffreEmploiController::class, 'action' => 'saisir', ], 'get' => [ 'route' => '/get/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'get', ], 'liste' => [ 'route' => '/liste', 'controller' => OffreEmploiController::class, 'action' => 'liste', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], 'supprimer' => [ 'route' => '/supprimer/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'supprimer', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], 'valider' => [ 'route' => '/valider/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'valider', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], 'devalider' => [ 'route' => '/devalider/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'devalider', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], 'postuler' => [ 'route' => '/postuler/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'postuler', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_POSTULER, ], 'public' => [ 'route' => '/public[/:offreEmploi]', 'controller' => OffreEmploiController::class, 'action' => 'public', ], ], ], 'missions-type' => [ 'route' => '/missions-type', 'controller' => MissionTypeController::class, Loading Loading @@ -253,31 +196,6 @@ return [ ], ], 'gestion' => [ 'pages' => [ 'offres-emploi' => [ 'label' => "Offre emplois étudiants", 'icon' => 'fas fa-duotone fa-pen-to-square', 'title' => "Offre", 'route' => 'offre-emploi', 'resource' => PrivilegeController::getResourceId(OffreEmploiController::class, 'index'), 'order' => 60, 'color' => '#217DD8', 'pages' => [ 'offre' => [ 'label' => "Consulter la liste des offres", 'icon' => 'fas fa-duotone fa-pen-to-square', 'title' => "Consulter la liste des emplois étudiants", 'route' => 'offre-emploi', 'resource' => PrivilegeController::getResourceId(OffreEmploiController::class, 'index'), 'order' => 10, 'color' => '#217DD8', ], ], ], ], ], ], Loading Loading @@ -312,59 +230,23 @@ return [ Privileges::MISSION_SUPPRESSION_TYPE, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['index', 'saisir',], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['supprimer'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_SUPPRESSION, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['valider', 'devalider'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['postuler'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_POSTULER, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['public', 'list', 'get'], 'roles' => ['guest'], ], ], 'controllers' => [ MissionController::class => Controller\MissionControllerFactory::class, MissionTypeController::class => Controller\MissionTypeControllerFactory::class, OffreEmploiController::class => OffreEmploiControllerFactory::class, ], 'services' => [ MissionTypeService::class => MissionTypeServiceFactory::class, Assertion\MissionAssertion::class => AssertionFactory::class, Service\MissionService::class => Service\MissionServiceFactory::class, OffreEmploiService::class => OffreEmploiServiceFactory::class, ], 'forms' => [ Form\MissionForm::class => Form\MissionFormFactory::class, Form\MissionSuiviForm::class => Form\MissionSuiviFormFactory::class, Form\OffreEmploiForm::class => Form\OffreEmploiFormFactory::class, ], 'view_helpers' => [ Loading module/Mission/config/offre-emploi.config.php 0 → 100644 +180 −0 Original line number Diff line number Diff line <?php namespace Mission; use Application\Entity\Db\WfEtape; use Application\Provider\Privilege\Privileges; use Mission\Controller\MissionController; use Mission\Controller\MissionTypeController; use Mission\Controller\OffreEmploiController; use Mission\Controller\OffreEmploiControllerFactory; use Mission\Service\MissionTypeService; use Mission\Service\MissionTypeServiceFactory; use Service\Controller\ModificationServiceDuController; use UnicaenPrivilege\Assertion\AssertionFactory; use UnicaenPrivilege\Guard\PrivilegeController; use Mission\Service\OffreEmploiService; use Mission\Service\OffreEmploiServiceFactory; return [ 'routes' => [ 'offre-emploi' => [ 'route' => '/offre-emploi', 'controller' => OffreEmploiController::class, 'action' => 'index', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, 'may_terminate' => true, 'child_routes' => [ 'saisir' => [ 'route' => '/saisir[/:offreEmploi]', 'controller' => OffreEmploiController::class, 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_MODIFIER, 'action' => 'saisir', ], 'get' => [ 'route' => '/get/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'get', ], 'liste' => [ 'route' => '/liste', 'controller' => OffreEmploiController::class, 'action' => 'liste', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], 'supprimer' => [ 'route' => '/supprimer/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'supprimer', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_SUPPRESSION, ], 'valider' => [ 'route' => '/valider/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'valider', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], 'devalider' => [ 'route' => '/devalider/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'devalider', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], 'postuler' => [ 'route' => '/postuler/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'postuler', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_POSTULER, ], 'public' => [ 'route' => '/public[/:offreEmploi]', 'controller' => OffreEmploiController::class, 'action' => 'public', ], ], ], ], 'navigation' => [ 'gestion' => [ 'pages' => [ 'offres-emploi' => [ 'label' => "Offre emplois étudiants", 'icon' => 'fas fa-duotone fa-pen-to-square', 'title' => "Offre", 'route' => 'offre-emploi', 'resource' => PrivilegeController::getResourceId(OffreEmploiController::class, 'index'), 'order' => 60, 'color' => '#217DD8', 'pages' => [ 'offre' => [ 'label' => "Consulter la liste des offres", 'icon' => 'fas fa-duotone fa-pen-to-square', 'title' => "Consulter la liste des emplois étudiants", 'route' => 'offre-emploi', 'resource' => PrivilegeController::getResourceId(OffreEmploiController::class, 'index'), 'order' => 10, 'color' => '#217DD8', ], ], ], ], ], ], 'rules' => [ [ 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_MODIFIER, Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], 'resources' => 'OffreEmploi', 'assertion' => Assertion\OffreEmploiAssertion::class, ], ], 'guards' => [ [ 'controller' => OffreEmploiController::class, 'action' => ['index', 'saisir',], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['supprimer'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_SUPPRESSION, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['valider', 'devalider'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['postuler'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_POSTULER, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['public', 'list', 'get'], 'roles' => ['guest'], ], ], 'controllers' => [ OffreEmploiController::class => OffreEmploiControllerFactory::class, ], 'services' => [ OffreEmploiService::class => OffreEmploiServiceFactory::class, Assertion\OffreEmploiAssertion::class => AssertionFactory::class, ], 'forms' => [ Form\OffreEmploiForm::class => Form\OffreEmploiFormFactory::class, ], 'view_helpers' => [ ], ]; No newline at end of file module/Mission/src/Assertion/OffreEmploiAssertion.php 0 → 100755 +89 −0 Original line number Diff line number Diff line <?php namespace Mission\Assertion; use Application\Acl\Role; use Application\Entity\Db\Structure; use Application\Provider\Privilege\Privileges; use Mission\Entity\Db\OffreEmploi; use UnicaenPrivilege\Assertion\AbstractAssertion; use Laminas\Permissions\Acl\Resource\ResourceInterface; use UnicaenPrivilege\View\Privilege\PrivilegeViewHelper; /** * Description of MissionAssertion * * @author Antony Le Courtes <antony.lecourtes at unicaen.fr> */ class OffreEmploiAssertion extends AbstractAssertion { protected function assertEntity(ResourceInterface $entity = null, $privilege = null) { /** @var Role $role */ $role = $this->getRole(); if (!$role instanceof Role) return false; if ($privilege && !$role->hasPrivilege($privilege)) return false; switch (true) { case $entity instanceof OffreEmploi: switch ($privilege) { case Privileges::MISSION_OFFRE_EMPLOI_MODIFIER: return $this->assertOffreEmploiEdition($role, $entity); case Privileges::MISSION_OFFRE_EMPLOI_VALIDER: return $this->assertOffreEmploiValidation($role, $entity); } break; } return true; } protected function assertOffreEmploiEdition(Role $role, OffreEmploi $offre) { return $this->asserts([ $offre->canSaisie(), $this->assertOffreEmploi($role, $offre), ]); } protected function assertOffreEmploiValidation(Role $role, OffreEmploi $offre) { return $this->asserts([ $offre->canSaisie(), $this->assertOffreEmploi($role, $offre), ]); } protected function assertOffreEmploi(Role $role, OffreEmploi $offre) { return $this->asserts([ $this->assertStructure($role, $offre->getStructure()), ]); } protected function assertStructure(Role $role, ?Structure $structure): bool { if (!$structure) { return true; } if (!$role->getStructure()) { return true; } return $role->getStructure() === $structure; } } No newline at end of file Loading
front/Mission/OffreEmploi.vue +5 −6 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ <div class="card-header"> <h4> {{ offre.titre }}</h4> <span class="badge rounded-pill bg-info">{{ offre.nombreHeures }} heure(s)</span> <span class="badge rounded-pill bg-info">{{ offre.nombrePostes }} poste(s)</span> <span class="badge rounded-pill bg-info">{{ offre.nombrePostes }} poste(s) restant(s)</span> <span v-if="offre.validation && !this.public" class="badge rounded-pill bg-success">Valider le <u-date :value="offre.validation.histoCreation"/> par {{ offre.validation.histoCreateur.displayName }}</span> <span v-if="!offre.validation && !this.public" class="badge rounded-pill bg-warning"> En attente de validation par la DRH</span> Loading @@ -30,19 +30,19 @@ </div> <div class="card-footer"> <div class="d-grid gap-2 d-md-flex justify-content-md-end"> <a v-if="offre.validation && this.canValider && !this.public" <a v-if="offre.validation && offre.canValide && !this.public" :href="devaliderUrl" class="btn btn-danger" @click.prevent="devalider">Devalider</a> <a v-if="!offre.validation && this.canValider && !this.public" <a v-if="!offre.validation && offre.canValide && !this.public" :href="validerUrl" class="btn btn-success" @click.prevent="valider">Valider</a> <a v-if="this.canModifier && !this.public" <a v-if="offre.canSaisie && !this.public" :href="saisirUrl" class="btn btn-primary" @click.prevent="saisir">Modifier</a> <a v-if="this.canSupprimer && !this.public" <a v-if="offre.canSupprime && !this.public" :href="supprimerUrl" class="btn btn-danger" data-title="Suppression de l'offre" Loading Loading @@ -122,7 +122,6 @@ export default { utilisateur: {required: false}, intervenant: {required: false}, extended: {type: Boolean, required: false}, canModifier: {type: Boolean, required: false}, canPostuler: {type: Boolean, required: false}, canValider: {type: Boolean, required: false}, canSupprimer: {type: Boolean, required: false}, Loading
module/Application/config/gestion.config.php +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ return [ Privileges::PILOTAGE_VISUALISATION, Privileges::BUDGET_VISUALISATION, Privileges::INDICATEUR_VISUALISATION, Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], 'assertion' => Assertion\GestionAssertion::class, ], Loading
module/Mission/config/module.config.php +0 −118 Original line number Diff line number Diff line Loading @@ -128,63 +128,6 @@ return [ ], ], ], 'offre-emploi' => [ 'route' => '/offre-emploi', 'controller' => OffreEmploiController::class, 'action' => 'index', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, 'may_terminate' => true, 'child_routes' => [ 'saisir' => [ 'route' => '/saisir[/:offreEmploi]', 'controller' => OffreEmploiController::class, 'action' => 'saisir', ], 'get' => [ 'route' => '/get/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'get', ], 'liste' => [ 'route' => '/liste', 'controller' => OffreEmploiController::class, 'action' => 'liste', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], 'supprimer' => [ 'route' => '/supprimer/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'supprimer', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], 'valider' => [ 'route' => '/valider/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'valider', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], 'devalider' => [ 'route' => '/devalider/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'devalider', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], 'postuler' => [ 'route' => '/postuler/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'postuler', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_POSTULER, ], 'public' => [ 'route' => '/public[/:offreEmploi]', 'controller' => OffreEmploiController::class, 'action' => 'public', ], ], ], 'missions-type' => [ 'route' => '/missions-type', 'controller' => MissionTypeController::class, Loading Loading @@ -253,31 +196,6 @@ return [ ], ], 'gestion' => [ 'pages' => [ 'offres-emploi' => [ 'label' => "Offre emplois étudiants", 'icon' => 'fas fa-duotone fa-pen-to-square', 'title' => "Offre", 'route' => 'offre-emploi', 'resource' => PrivilegeController::getResourceId(OffreEmploiController::class, 'index'), 'order' => 60, 'color' => '#217DD8', 'pages' => [ 'offre' => [ 'label' => "Consulter la liste des offres", 'icon' => 'fas fa-duotone fa-pen-to-square', 'title' => "Consulter la liste des emplois étudiants", 'route' => 'offre-emploi', 'resource' => PrivilegeController::getResourceId(OffreEmploiController::class, 'index'), 'order' => 10, 'color' => '#217DD8', ], ], ], ], ], ], Loading Loading @@ -312,59 +230,23 @@ return [ Privileges::MISSION_SUPPRESSION_TYPE, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['index', 'saisir',], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['supprimer'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_SUPPRESSION, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['valider', 'devalider'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['postuler'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_POSTULER, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['public', 'list', 'get'], 'roles' => ['guest'], ], ], 'controllers' => [ MissionController::class => Controller\MissionControllerFactory::class, MissionTypeController::class => Controller\MissionTypeControllerFactory::class, OffreEmploiController::class => OffreEmploiControllerFactory::class, ], 'services' => [ MissionTypeService::class => MissionTypeServiceFactory::class, Assertion\MissionAssertion::class => AssertionFactory::class, Service\MissionService::class => Service\MissionServiceFactory::class, OffreEmploiService::class => OffreEmploiServiceFactory::class, ], 'forms' => [ Form\MissionForm::class => Form\MissionFormFactory::class, Form\MissionSuiviForm::class => Form\MissionSuiviFormFactory::class, Form\OffreEmploiForm::class => Form\OffreEmploiFormFactory::class, ], 'view_helpers' => [ Loading
module/Mission/config/offre-emploi.config.php 0 → 100644 +180 −0 Original line number Diff line number Diff line <?php namespace Mission; use Application\Entity\Db\WfEtape; use Application\Provider\Privilege\Privileges; use Mission\Controller\MissionController; use Mission\Controller\MissionTypeController; use Mission\Controller\OffreEmploiController; use Mission\Controller\OffreEmploiControllerFactory; use Mission\Service\MissionTypeService; use Mission\Service\MissionTypeServiceFactory; use Service\Controller\ModificationServiceDuController; use UnicaenPrivilege\Assertion\AssertionFactory; use UnicaenPrivilege\Guard\PrivilegeController; use Mission\Service\OffreEmploiService; use Mission\Service\OffreEmploiServiceFactory; return [ 'routes' => [ 'offre-emploi' => [ 'route' => '/offre-emploi', 'controller' => OffreEmploiController::class, 'action' => 'index', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, 'may_terminate' => true, 'child_routes' => [ 'saisir' => [ 'route' => '/saisir[/:offreEmploi]', 'controller' => OffreEmploiController::class, 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_MODIFIER, 'action' => 'saisir', ], 'get' => [ 'route' => '/get/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'get', ], 'liste' => [ 'route' => '/liste', 'controller' => OffreEmploiController::class, 'action' => 'liste', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], 'supprimer' => [ 'route' => '/supprimer/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'supprimer', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_SUPPRESSION, ], 'valider' => [ 'route' => '/valider/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'valider', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], 'devalider' => [ 'route' => '/devalider/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'devalider', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], 'postuler' => [ 'route' => '/postuler/:offreEmploi', 'controller' => OffreEmploiController::class, 'action' => 'postuler', 'privileges' => Privileges::MISSION_OFFRE_EMPLOI_POSTULER, ], 'public' => [ 'route' => '/public[/:offreEmploi]', 'controller' => OffreEmploiController::class, 'action' => 'public', ], ], ], ], 'navigation' => [ 'gestion' => [ 'pages' => [ 'offres-emploi' => [ 'label' => "Offre emplois étudiants", 'icon' => 'fas fa-duotone fa-pen-to-square', 'title' => "Offre", 'route' => 'offre-emploi', 'resource' => PrivilegeController::getResourceId(OffreEmploiController::class, 'index'), 'order' => 60, 'color' => '#217DD8', 'pages' => [ 'offre' => [ 'label' => "Consulter la liste des offres", 'icon' => 'fas fa-duotone fa-pen-to-square', 'title' => "Consulter la liste des emplois étudiants", 'route' => 'offre-emploi', 'resource' => PrivilegeController::getResourceId(OffreEmploiController::class, 'index'), 'order' => 10, 'color' => '#217DD8', ], ], ], ], ], ], 'rules' => [ [ 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_MODIFIER, Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], 'resources' => 'OffreEmploi', 'assertion' => Assertion\OffreEmploiAssertion::class, ], ], 'guards' => [ [ 'controller' => OffreEmploiController::class, 'action' => ['index', 'saisir',], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_VISUALISATION, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['supprimer'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_SUPPRESSION, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['valider', 'devalider'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_VALIDER, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['postuler'], 'privileges' => [ Privileges::MISSION_OFFRE_EMPLOI_POSTULER, ], ], [ 'controller' => OffreEmploiController::class, 'action' => ['public', 'list', 'get'], 'roles' => ['guest'], ], ], 'controllers' => [ OffreEmploiController::class => OffreEmploiControllerFactory::class, ], 'services' => [ OffreEmploiService::class => OffreEmploiServiceFactory::class, Assertion\OffreEmploiAssertion::class => AssertionFactory::class, ], 'forms' => [ Form\OffreEmploiForm::class => Form\OffreEmploiFormFactory::class, ], 'view_helpers' => [ ], ]; No newline at end of file
module/Mission/src/Assertion/OffreEmploiAssertion.php 0 → 100755 +89 −0 Original line number Diff line number Diff line <?php namespace Mission\Assertion; use Application\Acl\Role; use Application\Entity\Db\Structure; use Application\Provider\Privilege\Privileges; use Mission\Entity\Db\OffreEmploi; use UnicaenPrivilege\Assertion\AbstractAssertion; use Laminas\Permissions\Acl\Resource\ResourceInterface; use UnicaenPrivilege\View\Privilege\PrivilegeViewHelper; /** * Description of MissionAssertion * * @author Antony Le Courtes <antony.lecourtes at unicaen.fr> */ class OffreEmploiAssertion extends AbstractAssertion { protected function assertEntity(ResourceInterface $entity = null, $privilege = null) { /** @var Role $role */ $role = $this->getRole(); if (!$role instanceof Role) return false; if ($privilege && !$role->hasPrivilege($privilege)) return false; switch (true) { case $entity instanceof OffreEmploi: switch ($privilege) { case Privileges::MISSION_OFFRE_EMPLOI_MODIFIER: return $this->assertOffreEmploiEdition($role, $entity); case Privileges::MISSION_OFFRE_EMPLOI_VALIDER: return $this->assertOffreEmploiValidation($role, $entity); } break; } return true; } protected function assertOffreEmploiEdition(Role $role, OffreEmploi $offre) { return $this->asserts([ $offre->canSaisie(), $this->assertOffreEmploi($role, $offre), ]); } protected function assertOffreEmploiValidation(Role $role, OffreEmploi $offre) { return $this->asserts([ $offre->canSaisie(), $this->assertOffreEmploi($role, $offre), ]); } protected function assertOffreEmploi(Role $role, OffreEmploi $offre) { return $this->asserts([ $this->assertStructure($role, $offre->getStructure()), ]); } protected function assertStructure(Role $role, ?Structure $structure): bool { if (!$structure) { return true; } if (!$role->getStructure()) { return true; } return $role->getStructure() === $structure; } } No newline at end of file