diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index e16ee6af7..fa09380ff 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -118,8 +118,6 @@ final readonly class ListActivity implements ListInterface, GroupedExportInterfa public function initiateQuery(array $requiredModifiers, array $acl, array $data, ExportGenerationContext $context): \Doctrine\ORM\QueryBuilder { - $centers = array_map(static fn ($el) => $el['center'], $acl); - $qb = $this->entityManager->createQueryBuilder(); $qb diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php index 50cc00092..87426b16a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Export\Helper; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Repository\CenterRepositoryInterface; use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; +use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; @@ -30,7 +31,7 @@ final readonly class FilterListAccompanyingPeriodHelper implements FilterListAcc public function __construct( private CenterRepositoryInterface $centerRepository, - private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, + private AuthorizationHelperInterface $authorizationHelper, ParameterBagInterface $parameterBag, ) { $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; @@ -53,9 +54,9 @@ final readonly class FilterListAccompanyingPeriodHelper implements FilterListAcc $i = 0; foreach ($centers as $center) { - $scopes = $this->authorizationHelperForCurrentUser->getReachableScopes(AccompanyingPeriodVoter::SEE_DETAILS, $center); + $scopes = $this->authorizationHelper->getReachableScopes($user, AccompanyingPeriodVoter::SEE_DETAILS, $center); $scopesConfidential = - $this->authorizationHelperForCurrentUser->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center); + $this->authorizationHelper->getReachableScopes($user, AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center); $orScopes = $qb->expr()->orX(); foreach ($scopes as $scope) { diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Export/ListAccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Export/ListAccompanyingPeriodTest.php index 769bd886f..b8818ba9d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Export/ListAccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Export/ListAccompanyingPeriodTest.php @@ -12,9 +12,11 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Export; use Chill\MainBundle\Entity\Center; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Repository\CenterRepositoryInterface; use Chill\MainBundle\Repository\ScopeRepositoryInterface; use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; +use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\MainBundle\Test\Export\AbstractExportTest; @@ -58,10 +60,10 @@ class ListAccompanyingPeriodTest extends AbstractExportTest // mock authorization helper $scopes = $scopeRepository->findAll(); $scopesConfidentials = [] !== $scopes ? [$scopes[0]] : []; - $authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class); - $authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_DETAILS, Argument::type(Center::class)) + $authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class); + $authorizationHelper->getReachableScopes(Argument::type(User::class), AccompanyingPeriodVoter::SEE_DETAILS, Argument::type(Center::class)) ->willReturn($scopes); - $authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, Argument::type(Center::class)) + $authorizationHelper->getReachableScopes(Argument::type(User::class), AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, Argument::type(Center::class)) ->willReturn($scopesConfidentials); yield new ListAccompanyingPeriod(