mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
[task] Feature: use the resolution of center with person's center
history
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Chill\TaskBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\TaskBundle\Entity\SingleTask;
|
||||
@@ -31,14 +32,14 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
|
||||
{
|
||||
private AuthorizationHelperInterface $authorizationHelper;
|
||||
|
||||
private CenterResolverDispatcherInterface $centerResolverDispatcher;
|
||||
private CenterResolverManagerInterface $centerResolverDispatcher;
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(
|
||||
CenterResolverDispatcherInterface $centerResolverDispatcher,
|
||||
CenterResolverManagerInterface $centerResolverDispatcher,
|
||||
EntityManagerInterface $em,
|
||||
Security $security,
|
||||
AuthorizationHelperInterface $authorizationHelper
|
||||
@@ -304,14 +305,18 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
|
||||
QueryBuilder $qb,
|
||||
$entity
|
||||
): QueryBuilder {
|
||||
$scopes = $this->authorizationHelper->getReachableScopes(
|
||||
$this->security->getUser(),
|
||||
TaskVoter::SHOW,
|
||||
$this->centerResolverDispatcher->resolveCenter($entity)
|
||||
);
|
||||
foreach ($this->centerResolverDispatcher->resolveCenters($entity) as $center) {
|
||||
$scopes = $this->authorizationHelper->getReachableScopes(
|
||||
$this->security->getUser(),
|
||||
TaskVoter::SHOW,
|
||||
$center
|
||||
);
|
||||
|
||||
return $qb->andWhere($qb->expr()->in('t.circle', ':scopes'))
|
||||
->setParameter('scopes', $scopes);
|
||||
$qb->andWhere($qb->expr()->in('t.circle', ':scopes'))
|
||||
->setParameter('scopes', $scopes);
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
private function addACLGlobal(
|
||||
@@ -329,7 +334,10 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
|
||||
$qb->leftJoin('t.person', 'person')
|
||||
->leftJoin('t.course', 'course')
|
||||
->leftJoin('course.participations', 'participation')
|
||||
->leftJoin('participation.person', 'person_p');
|
||||
->leftJoin('participation.person', 'person_p')
|
||||
->leftJoin('person.centerCurrent', 'center_current_person')
|
||||
->leftJoin('person_p.centerCurrent', 'center_current_participation')
|
||||
;
|
||||
$qb->distinct(true);
|
||||
|
||||
$k = 0;
|
||||
@@ -344,8 +352,8 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
|
||||
|
||||
$and = $qb->expr()->andX(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->eq('person.center', ':center_' . $k),
|
||||
$qb->expr()->eq('person_p.center', ':center_' . $k)
|
||||
$qb->expr()->eq('center_current_person.center', ':center_' . $k),
|
||||
$qb->expr()->eq('center_current_participation.center', ':center_' . $k)
|
||||
),
|
||||
$qb->expr()->in('t.circle', ':scopes_' . $k)
|
||||
);
|
||||
|
Reference in New Issue
Block a user