diff --git a/module/Application/autoload_classmap.php b/module/Application/autoload_classmap.php index 20698905a842dafa3f5cb3cfdfdb450c271029a7..47693c063b1ed9ae4bac71b7df2a277d61a4e886 100644 --- a/module/Application/autoload_classmap.php +++ b/module/Application/autoload_classmap.php @@ -613,12 +613,10 @@ return array( 'Application\Traits\ServiceAPayerAwareTrait' => __DIR__ . '/src/Application/Traits/ServiceAPayerAwareTrait.php', 'Application\Assertion\ModificationServiceDuAssertion' => __DIR__ . '/src/Application/Assertion/ModificationServiceDuAssertion.php', 'Application\Assertion\IntervenantAssertion' => __DIR__ . '/src/Application/Assertion/IntervenantAssertion.php', - 'Application\Assertion\ServiceReferentielAssertion' => __DIR__ . '/src/Application/Assertion/ServiceReferentielAssertion.php', 'Application\Assertion\ContratAssertion' => __DIR__ . '/src/Application/Assertion/ContratAssertion.php', 'Application\Assertion\OffreDeFormationAssertion' => __DIR__ . '/src/Application/Assertion/OffreDeFormationAssertion.php', 'Application\Assertion\ValidationServiceAssertion' => __DIR__ . '/src/Application/Assertion/ValidationServiceAssertion.php', 'Application\Assertion\ValidationDossierAssertion' => __DIR__ . '/src/Application/Assertion/ValidationDossierAssertion.php', - 'Application\Assertion\ServiceAssertion' => __DIR__ . '/src/Application/Assertion/ServiceAssertion.php', 'Application\Assertion\ValidationEnsRefAbstractAssertion' => __DIR__ . '/src/Application/Assertion/ValidationEnsRefAbstractAssertion.php', 'Application\Assertion\MiseEnPaiementAssertion' => __DIR__ . '/src/Application/Assertion/MiseEnPaiementAssertion.php', 'Application\Assertion\OldAbstractAssertion' => __DIR__ . '/src/Application/Assertion/OldAbstractAssertion.php', diff --git a/module/Application/config/indicateur.config.php b/module/Application/config/indicateur.config.php index 483fb61b86feceaf7d830352b664627e1839493d..6417b6798e3f5657cbb2b72ea3343e1b3cdf3c13 100644 --- a/module/Application/config/indicateur.config.php +++ b/module/Application/config/indicateur.config.php @@ -2,8 +2,6 @@ namespace Application; -use Application\Acl\AdministrateurRole; -use Application\Acl\ComposanteRole; use UnicaenAuth\Guard\PrivilegeController; return [ @@ -130,7 +128,7 @@ return [ 'result-item-donnees-perso-modif', 'purger-indicateur-donnees-perso-modif' ], - 'roles' => ['user', ComposanteRole::ROLE_ID, AdministrateurRole::ROLE_ID], + 'roles' => ['user'], ], ], ], diff --git a/module/Application/config/module.config.php b/module/Application/config/module.config.php index 6a92c71e8fc14a83ce6218e438ef2de7a2c94586..308fc0b13a5e089e7245d9f9b091ee1021d2e37f 100755 --- a/module/Application/config/module.config.php +++ b/module/Application/config/module.config.php @@ -3,11 +3,6 @@ namespace Application; use UnicaenAuth\Provider\Rule\PrivilegeRuleProvider; -const R_ADMINISTRATEUR = Acl\AdministrateurRole::ROLE_ID; -const R_COMPOSANTE = Acl\ComposanteRole::ROLE_ID; -const R_ETABLISSEMENT = Acl\EtablissementRole::ROLE_ID; -const R_INTERVENANT = Acl\IntervenantRole::ROLE_ID; - $main = [ 'doctrine' => [ @@ -126,15 +121,6 @@ $main = [ 'role_providers' => [ 'ApplicationRoleProvider' => [ Acl\Role::class, - - Acl\AdministrateurRole::class, - - Acl\ComposanteRole::class, - - Acl\EtablissementRole::class, - Acl\IntervenantRole::class, - Acl\IntervenantExterieurRole::class, - Acl\IntervenantPermanentRole::class, ], ], 'guards' => [ diff --git a/module/Application/config/notification.config.php b/module/Application/config/notification.config.php index 48090af27cda0c7cd4cb8716881af3de600440d3..7de77751d4b522c32012f10481618e1e34503c3e 100644 --- a/module/Application/config/notification.config.php +++ b/module/Application/config/notification.config.php @@ -2,9 +2,6 @@ namespace Application; -use Application\Acl\AdministrateurRole; -use Application\Acl\ComposanteRole; - return [ 'router' => [ 'routes' => [ @@ -115,12 +112,12 @@ return [ [ 'controller' => 'Application\Controller\Notification', 'action' => ['indicateurs', 'indicateur-fetch-title', 'notifier-indicateur-personnel'], - 'roles' => [AdministrateurRole::ROLE_ID], + 'roles' => ['user'], ], [ 'controller' => 'Application\Controller\Notification', 'action' => ['indicateur-intervenants'], - 'roles' => [ComposanteRole::ROLE_ID, AdministrateurRole::ROLE_ID], + 'roles' => ['user'], ], [ 'controller' => 'Application\Controller\Notification', diff --git a/module/Application/config/service.config.php b/module/Application/config/service.config.php index 7ef5dbb01b7f113a0952ce9794e5be4959041af4..b58c1eae297c3c36a461292f893fd21d8bdca5a4 100644 --- a/module/Application/config/service.config.php +++ b/module/Application/config/service.config.php @@ -455,9 +455,7 @@ return [ 'ServiceRechercheFormHydrator' => Form\Service\RechercheFormHydrator::class, 'FormServiceReferentielSaisieFieldsetHydrator' => Form\ServiceReferentiel\SaisieFieldsetHydrator::class, 'FormServiceReferentielSaisieHydrator' => Form\ServiceReferentiel\SaisieHydrator::class, - 'ServiceAssertion' => Assertion\ServiceAssertionOld::class, 'assertionService' => Assertion\ServiceAssertion::class, - 'ServiceReferentielAssertion' => Assertion\ServiceReferentielAssertion::class, 'processusService' => Processus\ServiceProcessus::class, 'processusServiceReferentiel' => Processus\ServiceReferentielProcessus::class, ], diff --git a/module/Application/src/Application/Acl/AdministrateurRole.php b/module/Application/src/Application/Acl/AdministrateurRole.php deleted file mode 100644 index 6fe8aeaabceeb1cb46f9873897fb62220d61ffdf..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Acl/AdministrateurRole.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Application\Acl; - -use Application\Entity\Db\Interfaces\StructureAwareInterface; -use Application\Entity\Db\Traits\StructureAwareTrait; -use Application\Entity\Db\Interfaces\PersonnelAwareInterface; -use Application\Entity\Db\Traits\PersonnelAwareTrait; - -/** - * Rôle père de tous les rôles "administrateur". - * - * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> - */ -class AdministrateurRole extends Role implements StructureAwareInterface, PersonnelAwareInterface -{ - use StructureAwareTrait; - use PersonnelAwareTrait; - - const ROLE_ID = 'administrateur'; - - public function __construct($id = self::ROLE_ID, $parent = Role::ROLE_ID, $name = 'Administrateur', $description = null, $selectable = true) - { - parent::__construct($id, $parent, $name, $description, $selectable); - } - - /** - * Retourne la représentation littérale de cet objet. - * - * @return string - */ - public function __toString() - { - return $this->getRoleName() . (($s = $this->getStructure()) ? " ($s)" : null); - } -} \ No newline at end of file diff --git a/module/Application/src/Application/Acl/ComposanteRole.php b/module/Application/src/Application/Acl/ComposanteRole.php deleted file mode 100644 index 321ee7ad198bf2fde3edf75c3c80fa8194729515..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Acl/ComposanteRole.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -namespace Application\Acl; - -use Application\Entity\Db\Interfaces\StructureAwareInterface; -use Application\Entity\Db\Traits\StructureAwareTrait; -use Application\Entity\Db\Interfaces\PersonnelAwareInterface; -use Application\Entity\Db\Traits\PersonnelAwareTrait; - -/** - * Rôle père de tous les rôles "composante". - * - * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> - */ -class ComposanteRole extends Role implements StructureAwareInterface, PersonnelAwareInterface -{ - use StructureAwareTrait; - use PersonnelAwareTrait; - - const ROLE_ID = 'composante'; - - public function __construct($id = self::ROLE_ID, $parent = Role::ROLE_ID, $name = 'Composante', $description = null, $selectable = true) - { - parent::__construct($id, $parent, $name, $description, $selectable); - } - - /** - * Returns the string identifier of the Role - * - * @return string - */ - public function getRoleId() - { - if ($structure = $this->getStructure()){ - return static::ROLE_ID.'-'.$structure->getSourceCode(); - }else{ - return static::ROLE_ID; - } - } - - /** - * Retourne la représentation littérale de cet objet. - * - * @return string - */ - public function __toString() - { - return sprintf($this->getRoleName()); - } -} - -class DirecteurComposanteRole extends ComposanteRole -{ - const ROLE_ID = 'directeur-composante'; - - public function __construct($id = self::ROLE_ID, $parent = ComposanteRole::ROLE_ID, $name = 'Directeur de composante', $description = null, $selectable = true) - { - parent::__construct($id, $parent, $name, $description, $selectable); - } -} - -class GestionnaireComposanteRole extends ComposanteRole -{ - const ROLE_ID = 'gestionnaire-composante'; - - public function __construct($id = self::ROLE_ID, $parent = ComposanteRole::ROLE_ID, $name = 'Gestionnaire de composante', $description = null, $selectable = true) - { - parent::__construct($id, $parent, $name, $description, $selectable); - } -} - -class ResponsableComposanteRole extends ComposanteRole -{ - const ROLE_ID = 'responsable-composante'; - - public function __construct($id = self::ROLE_ID, $parent = ComposanteRole::ROLE_ID, $name = 'Responsable de composante', $description = null, $selectable = true) - { - parent::__construct($id, $parent, $name, $description, $selectable); - } -} diff --git a/module/Application/src/Application/Acl/EtablissementRole.php b/module/Application/src/Application/Acl/EtablissementRole.php deleted file mode 100644 index 900830ea4d1764579cf3fb10508525147b863dfe..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Acl/EtablissementRole.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace Application\Acl; - -use Application\Entity\Db\Interfaces\PersonnelAwareInterface; -use Application\Entity\Db\Traits\PersonnelAwareTrait; - -/** - * Rôle père de tous les rôles "composante". - * - * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> - */ -class EtablissementRole extends Role implements PersonnelAwareInterface -{ - use PersonnelAwareTrait; - - const ROLE_ID = 'etablissement'; - - public function __construct($id = self::ROLE_ID, $parent = Role::ROLE_ID, $name = 'Établissement', $description = null, $selectable = true) - { - parent::__construct($id, $parent, $name, $description, $selectable); - } - -} diff --git a/module/Application/src/Application/Acl/IntervenantRole.php b/module/Application/src/Application/Acl/IntervenantRole.php deleted file mode 100644 index 5d275da8d19de11d2709620c1f9bd8514b13c3f5..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Acl/IntervenantRole.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -namespace Application\Acl; - -/** - * Description of IntervenantRole - * - * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> - */ -class IntervenantRole extends Role -{ - const ROLE_ID = "intervenant"; - - public function __construct($id = self::ROLE_ID, $parent = Role::ROLE_ID, $name = 'Intervenant', $description = null, $selectable = true) - { - parent::__construct($id, $parent, $name, $description, $selectable); - } -} - - - -class IntervenantPermanentRole extends IntervenantRole -{ - const ROLE_ID = "intervenant-permanent"; - - public function __construct($id = self::ROLE_ID, $parent = IntervenantRole::ROLE_ID, $name = "Intervenant permanent", $description = null, $selectable = true) - { - parent::__construct($id, $parent, $name, $description, $selectable); - } -} - - - -class IntervenantExterieurRole extends IntervenantRole -{ - const ROLE_ID = "intervenant-exterieur"; - protected $parent = IntervenantRole::ROLE_ID; - - public function __construct($id = self::ROLE_ID, $parent = IntervenantRole::ROLE_ID, $name = "Intervenant vacataire", $description = null, $selectable = true) - { - parent::__construct($id, $parent, $name, $description, $selectable); - } -} \ No newline at end of file diff --git a/module/Application/src/Application/Assertion/ServiceAssertionOld.php b/module/Application/src/Application/Assertion/ServiceAssertionOld.php deleted file mode 100644 index 636070e0a972049831895556f807b3d225ece4c1..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Assertion/ServiceAssertionOld.php +++ /dev/null @@ -1,314 +0,0 @@ -<?php - -namespace Application\Assertion; - -use Application\Acl\AdministrateurRole; -use Application\Acl\EtablissementRole; -use Application\Acl\IntervenantRole; -use Application\Entity\Db\Intervenant; -use Application\Entity\Db\Service; -use Zend\Permissions\Acl\Acl; -use Zend\Permissions\Acl\Resource\ResourceInterface; -use Zend\Permissions\Acl\Role\RoleInterface; -use Application\Entity\Db\TypeVolumeHoraire; -use DateTime; -use Application\Acl\IntervenantPermanentRole; -use Application\Rule\Paiement\MiseEnPaiementExisteRule; - -/** - * Description of Service - * - * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> - */ -class ServiceAssertionOld extends OldAbstractAssertion -{ - use \Application\Service\Traits\ValidationAwareTrait; - use \Application\Service\Traits\MiseEnPaiementAwareTrait; - - /** - * @var Service - */ - protected $resource; - - /** - * @var Intervenant - */ - protected $intervenant; - - /** - * @var TypeVolumeHoraire - */ - protected $typeVolumeHoraire; - - /** - * @var boolean - */ - protected $inCxtPrevu; - - /** - * @var boolean - */ - protected $inCxtRealise; - - /** - * Returns true if and only if the assertion conditions are met - * - * This method is passed the ACL, Role, Resource, and privilege to which the authorization query applies. If the - * $role, $resource, or $privilege parameters are null, it means that the query applies to all Roles, Resources, or - * privileges, respectively. - * - * @param Acl $acl - * @param RoleInterface $role - * @param ResourceInterface $resource - * @param string $privilege - * @return bool - */ - public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null) - { - parent::assert($acl, $role, $resource, $privilege); - - if ($this->resource instanceof Service) { - $this->intervenant = $this->resource->getIntervenant(); - $this->typeVolumeHoraire = $this->resource->getTypeVolumeHoraire(); - $this->inCxtPrevu = $this->typeVolumeHoraire && $this->typeVolumeHoraire->getCode() === TypeVolumeHoraire::CODE_PREVU; - $this->inCxtRealise = $this->typeVolumeHoraire && $this->typeVolumeHoraire->getCode() === TypeVolumeHoraire::CODE_REALISE; - - return $this->assertEntityOld(); - } - - return true; - } - - /** - * - * @todo gérer les autres types de rôles - * - * @return boolean - */ - protected function assertEntityOld() - { - if (! $this->assertClotureRealise()) { - return false; - } - if (! $this->assertMiseEnPaiement()) { - return false; - } - - /********************************************************* - * Rôle administrateur - *********************************************************/ - if ($this->role instanceof AdministrateurRole) { - return true; - } - - if ($this->resource->getElementPedagogique()) { - $serviceStructure = $this->resource->getElementPedagogique()->getStructure(); - }else{ - $serviceStructure = null; - } - if ($this->intervenant) { - $intervenantStructure = $this->resource->getIntervenant()->getStructure(); - } - - /********************************************************* - * Rôle intervenant - *********************************************************/ - if ($this->role instanceof IntervenantRole) { - if (!$this->intervenant->getStatut()->getPeutSaisirService()) { - return false; - } - - if ($this->isDateFinPrivilegeDepassee()) { - return false; - } - - if (!$this->intervenant || $this->intervenant == $this->role->getIntervenant()) { - return true; // Un intervenant ne peut travailler qu'avec ses services ou avec un service non enregistré - } - } - - /********************************************************* - * Rôle Composante - *********************************************************/ - if ($this->role->getStructure()) { - if ('read' == $this->privilege) { - return true; // les composantes voient tout - } - - $roleStructure = $this->role->getStructure(); - if ($roleStructure == $serviceStructure) { - return true; // chacun peut gérer ses propres services - } - - if ($this->intervenant) { - if (!$serviceStructure && 'create' == $this->privilege) { - // si la composante d'enseignement n'est pas encore connue à ce stade, - // on veut sans doute créer un nouveau service, il faut laisser passer... - return true; - } - if ($this->inCxtPrevu){ - if ($this->intervenant->estPermanent()) { - if ($roleStructure === $intervenantStructure) { - /* la composante d'affectation doit pouvoir saisir et contrôler les heures effectuées par ses permanents dans quelque composante que ce soit. */ - return true; - } - }else{ - if ($roleStructure === $serviceStructure) { - // un gestionnaire ne peut saisir des enseignements à un vacataire que sur sa propre composante - return true; - } - } - }elseif($this->inCxtRealise){ - if ($roleStructure === $serviceStructure) { - // un gestionnaire peut saisir réalisé des enseignements que sur sa propre composante - return true; - } - if ($this->intervenant->estPermanent() - && $roleStructure === $intervenantStructure - ){ - // un gestionnaire doit pouvoir saisir des services réalisés sur d'autres composantes (et même hors-UCBN) - return true; - } - } - } - elseif ('create' == $this->privilege) { - return true; - } - } - - /********************************************************* - * Rôle Superviseur - *********************************************************/ - if ($this->role instanceof EtablissementRole) { - if ('read' == $this->privilege) { - return true; // les superviseurs voient tout - } - } - - return false; - } - - /** - * Assertions concernant la clôture du service réalisé. - * - * @return boolean - */ - private function assertClotureRealise() - { - // la clôture de la saisie du réalisé n'a pas de sens pour du réalisé! - if (! $this->inCxtRealise) { - return true; - } - - // la clôture de la saisie du réalisé n'a pas de sens pour un vacataire - if (! $this->intervenant->estPermanent()) { - return true; - } - - // recherche de la clôture de service réalisé - $cloture = $this->getServiceValidation()->findValidationClotureServices($this->intervenant, null); - - /** - * Rôle Intervenant : - * - si le réalisé est clôturé, on bloque. - */ - if ($this->role instanceof IntervenantRole) { - switch ($this->privilege) { - case self::PRIVILEGE_CREATE: - case self::PRIVILEGE_UPDATE: - case self::PRIVILEGE_DELETE: - // si le réalisé est clôturé, on bloque - if ($cloture) { - return false; - } - break; - default: - break; - } - } - - return true; - } - - /** - * Assertions concernant les demandes de mise en paiement. - * - * @return boolean - */ - private function assertMiseEnPaiement() - { - // On ne s'intéresse ici qu'au réalisé. - if (! $this->inCxtRealise) { - return true; - } - // On ne s'intéresse ici qu'aux permanents. - if (! $this->intervenant->estPermanent()) { - return true; - } - - // recherche existence d'une demande de mise en paiement - $demandeMepExiste = $this->getRuleMiseEnPaiementExiste()->execute(); -// var_dump($demandeMepExiste); - - /** - * Aucune demande de mise en paiement ne doit exister. - */ - switch ($this->privilege) { - case self::PRIVILEGE_CREATE: - case self::PRIVILEGE_UPDATE: - case self::PRIVILEGE_DELETE: - // si le réalisé est clôturé, on bloque - if ($demandeMepExiste) { - return false; - } - break; - default: - break; - } - - return true; - } - - /** - * Teste si la date de fin de "privilège" du rôle courant est dépassée ou non. - * - * @return boolean - */ - protected function isDateFinPrivilegeDepassee() - { - $dateFin = null; - - /** - * Rôle Intervenant Permanent - */ - if ($this->role instanceof IntervenantPermanentRole) { - // il existe une date de fin de saisie (i.e. ajout, modif, suppression) de service par les intervenants permanents eux-mêmes - if (in_array($this->privilege, [self::PRIVILEGE_CREATE, self::PRIVILEGE_UPDATE, self::PRIVILEGE_DELETE])) { - $dateFin = $this->getServiceContext()->getDateFinSaisiePermanents(); - } - } - - if (null === $dateFin) { - return false; - } - - $now = new DateTime(); - - $now->setTime(0, 0, 0); - $dateFin->setTime(0, 0, 0); - - return $now > $dateFin; - } - - /** - * @return MiseEnPaiementExisteRule - */ - private function getRuleMiseEnPaiementExiste() - { - $rule = $this->getServiceLocator()->get('MiseEnPaiementExisteRule'); /* @var $rule MiseEnPaiementExisteRule */ - $rule->setIntervenant($this->intervenant)->setIsDemande(); - - return $rule; - - } -} \ No newline at end of file diff --git a/module/Application/src/Application/Assertion/ServiceReferentielAssertion.php b/module/Application/src/Application/Assertion/ServiceReferentielAssertion.php deleted file mode 100644 index 6f5626bb5a29780b8832ca2989bde8d42f1e98eb..0000000000000000000000000000000000000000 --- a/module/Application/src/Application/Assertion/ServiceReferentielAssertion.php +++ /dev/null @@ -1,347 +0,0 @@ -<?php - -namespace Application\Assertion; - -use Application\Acl\AdministrateurRole; -use Application\Acl\ComposanteRole; -use Application\Acl\EtablissementRole; -use Application\Acl\IntervenantPermanentRole; -use Application\Entity\Db\ServiceReferentiel; -use Application\Entity\Db\TypeVolumeHoraire; -use Application\Entity\Db\Structure; -use Zend\Permissions\Acl\Acl; -use Zend\Permissions\Acl\Resource\ResourceInterface; -use Zend\Permissions\Acl\Role\RoleInterface; -use DateTime; - -/** - * - * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> - */ -class ServiceReferentielAssertion extends OldAbstractAssertion -{ - use \Application\Service\Traits\ValidationAwareTrait; - - /** - * @var ServiceReferentiel - */ - protected $resource; - - /** - * @var Intervenant - */ - protected $intervenant; - - /** - * @var TypeVolumeHoraire - */ - protected $typeVolumeHoraire; - - /** - * @var boolean - */ - protected $inCxtPrevu; - - /** - * @var boolean - */ - protected $inCxtRealise; - - /** - * @var Structure - */ - protected $serviceStructure; - - /** - * @var Structure - */ - protected $intervenantStructure; - - /** - * Returns true if and only if the assertion conditions are met - * - * This method is passed the ACL, Role, Resource, and privilege to which the authorization query applies. If the - * $role, $resource, or $privilege parameters are null, it means that the query applies to all Roles, Resources, or - * privileges, respectively. - * - * @param Acl $acl - * @param RoleInterface $role - * @param ResourceInterface $resource - * @param string $privilege - * @return bool - */ - public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null) - { - parent::assert($acl, $role, $resource, $privilege); - - if ($this->resource instanceof ServiceReferentiel) { - $this->intervenant = $this->resource->getIntervenant(); - $this->typeVolumeHoraire = $this->resource->getTypeVolumeHoraire(); - $this->inCxtPrevu = $this->typeVolumeHoraire && $this->typeVolumeHoraire->getCode() === TypeVolumeHoraire::CODE_PREVU; - $this->inCxtRealise = $this->typeVolumeHoraire && $this->typeVolumeHoraire->getCode() === TypeVolumeHoraire::CODE_REALISE; - - $this->serviceStructure = $this->resource->getStructure(); - $this->intervenantStructure = $this->intervenant ? $this->intervenant->getStructure() : null; - - return $this->assertEntityOld(); - } - - return true; - } - - /** - * - * @todo gérer les autres types de rôles - * - * @return boolean - */ - protected function assertEntityOld() - { - if (! $this->assertClotureRealise()) { - return false; - } - if (! $this->assertMiseEnPaiement()) { - return false; - } - - if (! $this->intervenant->estPermanent()) { - return false; // pas de référentiel pour les intervenants extérieurs - } - - /********************************************************* - * Rôle administrateur - *********************************************************/ - if ($this->role instanceof AdministrateurRole) { - return true; - } - - /********************************************************* - * Rôle intervenant - *********************************************************/ - if ($this->role instanceof IntervenantPermanentRole) { - if ($this->intervenant && $this->intervenant !== $this->role->getIntervenant()) { - return false; // Un intervenant ne peut travailler qu'avec ses services ou avec un service non enregistré - } - - if ($this->isDateFinPrivilegeDepassee()) { - return false; - } - } - - /********************************************************* - * Rôle Composante - *********************************************************/ - if ($this->role instanceof ComposanteRole) { - if ('read' === $this->privilege) { - return true; // les composantes voient tout - } - - if (! $this->assertStructureComposanteRole()) { - return false; - } - - if ('create' === $this->privilege) { - return true; - } - } - - /********************************************************* - * Rôle Superviseur - *********************************************************/ - if ($this->role instanceof EtablissementRole) { - if ('read' == $this->privilege) { - return true; // les superviseurs voient tout - } - } - - return true; - } - - /** - * Assertions portant sur les structures mises en jeu, - * pour le rôle Composante. - * - * @return boolean - */ - private function assertStructureComposanteRole() - { - /** - * On ne s'intéresse ici qu'au rôle Composante. - */ - if (! $this->role instanceof ComposanteRole) { - return true; - } - - $roleStructure = $this->role->getStructure(); - - /** - * Le gestionnaire de la structure d'affectation de l'intervenant saisit - * le référentiel portant sur sa structure de responsabilité. - */ - if ($roleStructure === $this->serviceStructure) { - return true; - } - - /** - * - Si la composante d'intervention n'est pas encore connue à ce stade, - * on veut sans doute créer un nouveau service, il faut laisser passer... - * - Ou alors il s'agit d'un saisie de référentiel sans structure de rattachement... - */ - if ($this->intervenant && ! $this->serviceStructure /*&& 'create' == $this->privilege*/) { - return true; - } - - /** - * Référentiel Prévisionnel : - * La composante d'affectation de l'intervenant doit correspondre à la structure de responsabilité - * du gestionnaire. - */ - if ($this->inCxtPrevu) { - if ($this->intervenantStructure === $roleStructure) { - return true; - } - } - /** - * Référentiel Réalisé : - */ - elseif ($this->inCxtRealise) { - if ($this->serviceStructure === $roleStructure) { - // La composante d'intervention correspond à la structure de responsabilité du gestionnaire. - return true; - } - if ( - $this->intervenant->estPermanent() && - $this->intervenantStructure === $roleStructure - ) { - // Un gestionnaire peut agir sur les permanents de sa composante pour n'importe quelle composante d'intervention - return true; - } - } - - return false; - } - - /** - * Assertions concernant la clôture du service réalisé. - * - * @return boolean - */ - private function assertClotureRealise() - { - // la clôture de la saisie du réalisé n'a pas de sens pour du réalisé! - if (! $this->inCxtRealise) { - return true; - } - - // la clôture de la saisie du réalisé n'a pas de sens pour un vacataire - if (! $this->intervenant->estPermanent()) { - return true; - } - - // recherche de la clôture de service réalisé - $cloture = $this->getServiceValidation()->findValidationClotureServices($this->intervenant, null); - - /** - * Rôle Intervenant : - * - si le réalisé est clôturé, on bloque. - */ - if ($this->role->getIntervenant()) { - switch ($this->privilege) { - case self::PRIVILEGE_CREATE: - case self::PRIVILEGE_UPDATE: - case self::PRIVILEGE_DELETE: - // si le réalisé est clôturé, on bloque - if ($cloture) { - return false; - } - break; - default: - break; - } - } - - return true; - } - - /** - * Assertions concernant les demandes de mise en paiement. - * - * @return boolean - */ - private function assertMiseEnPaiement() - { - // On ne s'intéresse ici qu'au réalisé. - if (! $this->inCxtRealise) { - return true; - } - // On ne s'intéresse ici qu'aux permanents. - if (! $this->intervenant->estPermanent()) { - return true; - } - - // recherche existence d'une demande de mise en paiement - $demandeMepExiste = $this->getRuleMiseEnPaiementExiste()->execute(); -// var_dump($demandeMepExiste); - - /** - * Aucune demande de mise en paiement ne doit exister. - */ - switch ($this->privilege) { - case self::PRIVILEGE_CREATE: - case self::PRIVILEGE_UPDATE: - case self::PRIVILEGE_DELETE: - // si le réalisé est clôturé, on bloque - if ($demandeMepExiste) { - return false; - } - break; - default: - break; - } - - return true; - } - - /** - * Teste si la date de fin de "privilège" du rôle courant est dépassée ou non. - * - * @return boolean - */ - protected function isDateFinPrivilegeDepassee() - { - $dateFin = null; - - /** - * Rôle Intervenant Permanent - */ - if ($this->role instanceof IntervenantPermanentRole) { - // il existe une date de fin de saisie (i.e. ajout, modif, suppression) de service par les intervenants permanents eux-mêmes - if (in_array($this->privilege, [self::PRIVILEGE_CREATE, self::PRIVILEGE_UPDATE, self::PRIVILEGE_DELETE])) { - $dateFin = $this->getServiceContext()->getDateFinSaisiePermanents(); - } - } - - if (null === $dateFin) { - return false; - } - - $now = new DateTime(); - - $now->setTime(0, 0, 0); - $dateFin->setTime(0, 0, 0); - - return $now > $dateFin; - } - - /** - * @return MiseEnPaiementExisteRule - */ - private function getRuleMiseEnPaiementExiste() - { - $rule = $this->getServiceLocator()->get('MiseEnPaiementExisteRule'); /* @var $rule MiseEnPaiementExisteRule */ - $rule->setIntervenant($this->intervenant)->setIsDemande(); - - return $rule; - - } -} \ No newline at end of file diff --git a/module/Application/src/Application/Entity/Db/Intervenant.php b/module/Application/src/Application/Entity/Db/Intervenant.php index 5358a3015e58554ca675e7d47fc1add54f6cf56c..4d362f66209b17f4c6b9c5e5dec90986237151e4 100644 --- a/module/Application/src/Application/Entity/Db/Intervenant.php +++ b/module/Application/src/Application/Entity/Db/Intervenant.php @@ -29,6 +29,16 @@ class Intervenant implements IntervenantInterface, HistoriqueAwareInterface, Res use DossierAwareTrait; use ImportAwareTrait; + /** + * @var string + */ + protected $code; + + /** + * @var string + */ + protected $supannEmpId; + /** * @var \DateTime * @Annotation\Type("UnicaenApp\Form\Element\DateInfSup") @@ -298,6 +308,54 @@ class Intervenant implements IntervenantInterface, HistoriqueAwareInterface, Res + /** + * @return string + */ + public function getCode() + { + return $this->code; + } + + + + /** + * @param string $code + * + * @return Intervenant + */ + public function setCode($code) + { + $this->code = $code; + + return $this; + } + + + + /** + * @return string + */ + public function getSupannEmpId() + { + return $this->supannEmpId; + } + + + + /** + * @param string $supannEmpId + * + * @return Intervenant + */ + public function setSupannEmpId($supannEmpId) + { + $this->supannEmpId = $supannEmpId; + + return $this; + } + + + /** * Set dateNaissance * diff --git a/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Intervenant.dcm.xml b/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Intervenant.dcm.xml index 98829ceaa27c40310cbc3f3699d14137fe1d092e..dd08e40c5ba80963224de5b8cad1623a8aae309a 100644 --- a/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Intervenant.dcm.xml +++ b/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Intervenant.dcm.xml @@ -20,6 +20,8 @@ <id name="id" type="integer" column="ID"> <generator strategy="SEQUENCE"/> </id> + <field name="code" type="string" column="CODE" length="60" nullable="false"/> + <field name="supannEmpId" type="string" column="SUPANN_EMP_ID" length="60" nullable="false"/> <field name="dateNaissance" type="datetime" column="DATE_NAISSANCE" nullable="false"/> <field name="depNaissanceCodeInsee" type="string" column="DEP_NAISSANCE_CODE_INSEE" length="3" nullable="true"/> <field name="depNaissanceLibelle" type="string" column="DEP_NAISSANCE_LIBELLE" length="30" nullable="true"/> diff --git a/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Personnel.dcm.xml b/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Personnel.dcm.xml index 9f589d3d5385331c2775c748107e20f34cd32712..5a8f44f68a1e2b74d05f9c2a3ccf0726e2bd8194 100644 --- a/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Personnel.dcm.xml +++ b/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Personnel.dcm.xml @@ -15,6 +15,8 @@ <id name="id" type="integer" column="ID"> <generator strategy="SEQUENCE"/> </id> + <field name="code" type="string" column="CODE" length="60" nullable="false"/> + <field name="supannEmpId" type="string" column="SUPANN_EMP_ID" length="60" nullable="false"/> <field name="email" type="string" column="EMAIL" length="255" nullable="false"/> <field name="histoCreation" type="datetime" column="HISTO_CREATION" nullable="false"/> <field name="histoDestruction" type="datetime" column="HISTO_DESTRUCTION" nullable="true"/> diff --git a/module/Application/src/Application/Entity/Db/Personnel.php b/module/Application/src/Application/Entity/Db/Personnel.php index 213736a9441ed95c9d259dfe447137b099f84041..ebde0f0255df70278e100456dc1825b94c374e54 100644 --- a/module/Application/src/Application/Entity/Db/Personnel.php +++ b/module/Application/src/Application/Entity/Db/Personnel.php @@ -15,6 +15,16 @@ class Personnel implements HistoriqueAwareInterface, ImportAwareInterface use HistoriqueAwareTrait; use ImportAwareTrait; + /** + * @var string + */ + protected $code; + + /** + * @var string + */ + protected $supannEmpId; + /** * @var string */ @@ -67,6 +77,54 @@ class Personnel implements HistoriqueAwareInterface, ImportAwareInterface + /** + * @return string + */ + public function getCode() + { + return $this->code; + } + + + + /** + * @param string $code + * + * @return Personnel + */ + public function setCode($code) + { + $this->code = $code; + + return $this; + } + + + + /** + * @return string + */ + public function getSupannEmpId() + { + return $this->supannEmpId; + } + + + + /** + * @param string $supannEmpId + * + * @return Personnel + */ + public function setSupannEmpId($supannEmpId) + { + $this->supannEmpId = $supannEmpId; + + return $this; + } + + + /** * Set email * diff --git a/module/Application/src/Application/Provider/Role/RoleProvider.php b/module/Application/src/Application/Provider/Role/RoleProvider.php index 6bafb442ddfbba1ea8f1a93aab40657e5a4ff0b6..9360a4a919981066d70bbbaf9f99332456acdde5 100644 --- a/module/Application/src/Application/Provider/Role/RoleProvider.php +++ b/module/Application/src/Application/Provider/Role/RoleProvider.php @@ -103,25 +103,15 @@ class RoleProvider implements ProviderInterface, EntityManagerAwareInterface $roles = []; $r = new Role(); $roles[$r->getRoleId()] = $r; - $r = new \Application\Acl\ComposanteRole(); - $roles[$r->getRoleId()] = $r; - $r = new \Application\Acl\EtablissementRole(); - $roles[$r->getRoleId()] = $r; - $r = new \Application\Acl\IntervenantRole(); - $roles[$r->getRoleId()] = $r; - $r = new \Application\Acl\IntervenantExterieurRole(); - $roles[$r->getRoleId()] = $r; - $r = new \Application\Acl\IntervenantPermanentRole(); - $roles[$r->getRoleId()] = $r; $serviceAuthUserContext = $this->getServiceLocator()->get('AuthUserContext'); /* @var $serviceAuthUserContext \UnicaenAuth\Service\UserContext */ if ($ldapUser = $serviceAuthUserContext->getLdapUser()) { - $numeroPersonnel = (integer)$ldapUser->getSupannEmpId(); - $intervenant = $this->getServiceIntervenant()->getBySourceCode($numeroPersonnel); - $personnel = $this->getServicePersonnel()->getBySourceCode($numeroPersonnel); + $supannEmpId = (integer)$ldapUser->getSupannEmpId(); + $intervenant = $this->getServiceIntervenant()->getBySourceCode($supannEmpId); + $personnel = $this->getServicePersonnel()->getBySourceCode($supannEmpId); } else { $intervenant = null; $personnel = null; @@ -148,31 +138,7 @@ class RoleProvider implements ProviderInterface, EntityManagerAwareInterface /* @var $dbRole \Application\Entity\Db\Role */ $roleId = $dbRole->getRoleId(); - $roleClass = \Application\Acl\Role::class; - $parent = 'user'; - /** @deprecated */ - if ($roleId == 'gestionnaire-composante') { - $roleClass = \Application\Acl\GestionnaireComposanteRole::class; - $parent = 'composante'; - } - if ($roleId == 'directeur-composante') { - $roleClass = \Application\Acl\DirecteurComposanteRole::class; - $parent = 'composante'; - } - if ($roleId == 'administrateur') { - $roleClass = \Application\Acl\AdministrateurRole::class; - } - if ($roleId == 'responsable-composante') { - $roleClass = \Application\Acl\ResponsableComposanteRole::class; - $parent = 'composante'; - } - if ($roleId == 'superviseur-etablissement') { - $roleClass = \Application\Acl\EtablissementRole::class; - $parent = 'etablissement'; - } - /* FIN de deprecated */ - - $role = new $roleClass($roleId, $parent, $dbRole->getLibelle()); + $role = new Role($roleId, 'user', $dbRole->getLibelle()); if (isset($rolesPrivileges[$roleId])){ $role->initPrivileges($rolesPrivileges[$roleId]); } @@ -198,7 +164,7 @@ class RoleProvider implements ProviderInterface, EntityManagerAwareInterface $affRoleId = $roleId . '-' . $structure->getSourceCode(); if (!isset($roles[$affRoleId])) { $affRoleLibelle = $dbRole->getLibelle() . ' (' . $structure->getLibelleCourt() . ')'; - $affRole = new $roleClass($affRoleId, $roleId, $affRoleLibelle); + $affRole = new \Application\Acl\Role($affRoleId, $roleId, $affRoleLibelle); $affRole->setPersonnel($personnel); $affRole->setStructure($structure); $roles[$affRoleId] = $affRole; @@ -207,17 +173,15 @@ class RoleProvider implements ProviderInterface, EntityManagerAwareInterface } } - // Chargement des rôles par statut d'intervenant $si = $this->getStatutsInfo(); foreach ($si as $statut) { - $roleClass = $statut['role-class']; - $role = new $roleClass($statut['role-id'], $statut['parent'], $roles[$statut['parent']]->getRoleName()); + $role = new Role($statut['role-id'], 'user', $statut['role-name']); if ($intervenant) { if ($intervenant->getStatut()->getId() == $statut['statut-id']) { $role->setIntervenant($intervenant); - $role->initPrivileges($rolesPrivileges['statut/'.$intervenant->getStatut()->getSourceCode()]); + $role->initPrivileges($rolesPrivileges[$intervenant->getStatut()->getRoleId()]); } } $roles[$statut['role-id']] = $role; @@ -235,19 +199,10 @@ class RoleProvider implements ProviderInterface, EntityManagerAwareInterface $si = []; $statuts = $this->getServiceStatutIntervenant()->getList(); foreach ($statuts as $statut) { - /** @deprecated */ - if ($statut->getTypeIntervenant()->getCode() === \Application\Entity\Db\TypeIntervenant::CODE_PERMANENT) { - $parent = \Application\Acl\IntervenantPermanentRole::ROLE_ID; - $roleClass = \Application\Acl\IntervenantPermanentRole::class; - } else { - $parent = \Application\Acl\IntervenantExterieurRole::ROLE_ID; - $roleClass = \Application\Acl\IntervenantExterieurRole::class; - } $si[] = [ 'statut-id' => $statut->getId(), 'role-id' => $statut->getRoleId(), - 'parent' => $parent, - 'role-class' => $roleClass, + 'role-name' => $statut->getTypeIntervenant()->getLibelle(), ]; } $session->statutsInfo = $si;