From 191cd74367d9793cc3da9bf21502de5125efd9cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20L=C3=A9cluse?= <laurent.lecluse@unicaen.fr> Date: Wed, 10 Feb 2021 15:40:49 +0100 Subject: [PATCH] =?UTF-8?q?Nouveau=20privil=C3=A8ge=20pour=20permettre=20d?= =?UTF-8?q?e=20saisir=20sur=20r=C3=A9f=C3=A9rentiel=20sur=20n'importe=20qu?= =?UTF-8?q?elle=20composante?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/privileges.php | 13 ++++---- .../Assertion/ServiceAssertion.php | 33 +++++++++---------- .../Provider/Privilege/Privileges.php | 1 + 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/data/privileges.php b/data/privileges.php index 2442cdd8e4..91236813b6 100644 --- a/data/privileges.php +++ b/data/privileges.php @@ -113,12 +113,13 @@ return [ 'referentiel' => [ 'libelle' => 'Référentiel', 'privileges' => [ - 'visualisation' => 'Visualisation', - 'edition' => 'Édition', - 'validation' => 'Validation', - 'admin-edition' => 'Administration - Édition', - 'devalidation' => 'Dévalidation', - 'admin-visualisation' => 'Administration - Visualisation', + 'visualisation' => 'Visualisation', + 'edition' => 'Édition', + 'validation' => 'Validation', + 'admin-edition' => 'Administration - Édition', + 'devalidation' => 'Dévalidation', + 'admin-visualisation' => 'Administration - Visualisation', + 'saisie-toutes-composantes' => 'Saisie sans contrainte de composante', ], ], diff --git a/module/Application/src/Application/Assertion/ServiceAssertion.php b/module/Application/src/Application/Assertion/ServiceAssertion.php index 63df3ac0d8..93fcae027b 100755 --- a/module/Application/src/Application/Assertion/ServiceAssertion.php +++ b/module/Application/src/Application/Assertion/ServiceAssertion.php @@ -34,7 +34,6 @@ class ServiceAssertion extends AbstractAssertion use TypeVolumeHoraireServiceAwareTrait; - /* ---- Routage général ---- */ public function __invoke(array $page) // gestion des visibilités de menus { @@ -284,23 +283,23 @@ class ServiceAssertion extends AbstractAssertion protected function assertServiceReferentielEdition(Role $role, ServiceReferentiel $serviceReferentiel) { - $structure = $role->getStructure(); - $asserts = []; - - if ($structure) { - $structureAffectation = $serviceReferentiel->getIntervenant() ? $serviceReferentiel->getIntervenant()->getStructure() : null; - $structureEnseignement = $serviceReferentiel->getStructure(); - - if ($structureAffectation && $structureEnseignement) { - // cas d'un intervenant d'une autre structure prenant un enseignement dans une autre structure - $asserts[] = $structure == $structureAffectation || $structure == $structureEnseignement; // le service doit avoir un lien avec la structure - } elseif ($structureAffectation && !$structureEnseignement) { - // cas d'un intervenant prenant des enseignements à l'extérieur - $asserts[] = $structure == $structureAffectation; - } elseif (!$structureAffectation && $structureEnseignement) { - // cas d'un intervenant extérieur prenant des enseignements de la composante - $asserts[] = $structure == $structureEnseignement; + if (!$role->hasPrivilege(Privileges::REFERENTIEL_SAISIE_TOUTES_COMPOSANTES)) { + // Si on n'a pas le privilège pour pouvoir du référentiel dans toutes les composantes sans restriction + if ($structure = $role->getStructure()) { + $structureAffectation = $serviceReferentiel->getIntervenant() ? $serviceReferentiel->getIntervenant()->getStructure() : null; + $structureEnseignement = $serviceReferentiel->getStructure(); + + if ($structureAffectation && $structureEnseignement) { + // cas d'un intervenant d'une autre structure prenant un enseignement dans une autre structure + $asserts[] = $structure == $structureAffectation || $structure == $structureEnseignement; // le service doit avoir un lien avec la structure + } elseif ($structureAffectation && !$structureEnseignement) { + // cas d'un intervenant prenant des enseignements à l'extérieur + $asserts[] = $structure == $structureAffectation; + } elseif (!$structureAffectation && $structureEnseignement) { + // cas d'un intervenant extérieur prenant des enseignements de la composante + $asserts[] = $structure == $structureEnseignement; + } } } diff --git a/module/Application/src/Application/Provider/Privilege/Privileges.php b/module/Application/src/Application/Provider/Privilege/Privileges.php index e8e5bf6473..ec640ac7e7 100755 --- a/module/Application/src/Application/Provider/Privilege/Privileges.php +++ b/module/Application/src/Application/Provider/Privilege/Privileges.php @@ -184,5 +184,6 @@ class Privileges extends \UnicaenAuth\Provider\Privilege\Privileges const UNICAEN_TBL_UPDATE_ACTUPROC = 'unicaen-tbl-update-actuproc'; const WORKFLOW_DEPENDANCES_EDITION = 'workflow-dependances-edition'; const WORKFLOW_DEPENDANCES_VISUALISATION = 'workflow-dependances-visualisation'; + const REFERENTIEL_SAISIE_TOUTES_COMPOSANTES = 'referentiel-saisie-toutes-composantes'; } \ No newline at end of file -- GitLab