From c27544417466f9201bd48e4767adcf7d67155369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20L=C3=A9cluse?= <laurent.lecluse@unicaen.fr> Date: Thu, 5 Sep 2019 11:46:49 +0200 Subject: [PATCH] =?UTF-8?q?Bug=20r=C3=A9solu=20:=20on=20ne=20pouvait=20pas?= =?UTF-8?q?=20r=C3=A9cup=C3=A9rer=20son=20affectaion=20si=20on=20=C3=A9tai?= =?UTF-8?q?t=20avec=20un=20r=C3=B4le=20=C3=A9tablissement=20r=C3=A9duit=20?= =?UTF-8?q?=C3=A0=20une=20composante=20donn=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 +++ .../Service/AffectationService.php | 38 ++++++++++++------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5eff6a7f5..67c7251905 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ title: "Changements intervenus sur OSE" author: Laurent Lécluse - DSI - Unicaen --- +# OSE alpha + +## Correction de bugs + +* On peut maintenant s'abonner à un indicateur même avec un rôle de périmètre établissement réduit à une composante. + # OSE 8.2.2 ## Correction de bugs diff --git a/module/Application/src/Application/Service/AffectationService.php b/module/Application/src/Application/Service/AffectationService.php index 0e871da7b3..48117cd41e 100755 --- a/module/Application/src/Application/Service/AffectationService.php +++ b/module/Application/src/Application/Service/AffectationService.php @@ -20,6 +20,8 @@ class AffectationService extends AbstractEntityService { use SourceServiceAwareTrait; + + /** * retourne la classe des entités * @@ -31,6 +33,8 @@ class AffectationService extends AbstractEntityService return Affectation::class; } + + /** * Retourne l'alias d'entité courante * @@ -41,22 +45,26 @@ class AffectationService extends AbstractEntityService return 'aff'; } + + /** * Sauvegarde une entité * * @param Affectation $entity + * * @throws \RuntimeException * @return mixed */ public function save($entity) { $structure = $this->getServiceContext()->getSelectedIdentityRole()->getStructure(); - if ($structure && $entity->getStructure() != $structure){ + if ($structure && $entity->getStructure() != $structure) { throw new \LogicException('Vous n\'avez pas le droit de modifier une affectation d\'une structure autre que la vôtre.'); } - if (! $entity->getSource()){ - $entity->setSource( $this->getServiceSource()->getOse() ); + if (!$entity->getSource()) { + $entity->setSource($this->getServiceSource()->getOse()); } + return parent::save($entity); } @@ -67,11 +75,11 @@ class AffectationService extends AbstractEntityService * * @return null|Affectation */ - public function getByRole( RoleAcl $role = null ) + public function getByRole(RoleAcl $role = null) { $context = $this->getServiceContext(); - if (!$role){ + if (!$role) { $role = $this->getServiceContext()->getSelectedIdentityRole(); } @@ -81,11 +89,14 @@ class AffectationService extends AbstractEntityService Affectation::class, ]); - return $this->getRepo()->findOneBy([ + $params = [ 'utilisateur' => $context->getUtilisateur(), - 'role' => $role->getDbRole(), - 'structure' => $context->getStructure(), - ]); + 'role' => $role->getDbRole(), + 'structure' => $role->getPerimetre()->isComposante() ? $context->getStructure() : null, + ]; + $affectation = $this->getRepo()->findOneBy($params); + + return $affectation; } @@ -93,8 +104,9 @@ class AffectationService extends AbstractEntityService /** * * @param \Application\Entity\Db\Role|string $role - * @param QueryBuilder $qb - * @param string $alias + * @param QueryBuilder $qb + * @param string $alias + * * @return QueryBuilder * @todo A REVOIR! ! ! ! */ @@ -107,8 +119,8 @@ class AffectationService extends AbstractEntityService } $qb - ->innerJoin($alias.'.role', $ralias = uniqid('r')) - ->andWhere("$ralias.code = :code")->setParameter('code', $role); + ->innerJoin($alias . '.role', $ralias = uniqid('r')) + ->andWhere("$ralias.code = :code")->setParameter('code', $role); return $qb; } -- GitLab