diff --git a/CHANGELOG.md b/CHANGELOG.md index b5eff6a7f59bfb5a30a2a92fc980a7a507ac1454..67c72519053c591d6c7a702d74e493709165e95a 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 0e871da7b3629bc92af8650d94932fbcd6d87162..48117cd41e5d997030cf5e1c58db2149851cda97 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; }