diff --git a/Controller/EventController.php b/Controller/EventController.php index e98486ef7..fb5ea0052 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -3,6 +3,8 @@ namespace Chill\EventBundle\Controller; use Chill\EventBundle\Entity\Participation; +use Chill\EventBundle\Security\Authorization\EventVoter; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Privacy\PrivacyEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; @@ -27,14 +29,20 @@ class EventController extends Controller */ protected $eventDispatcher; + /** + * @var AuthorizationHelper + */ + protected $authorizationHelper; + /** * EventController constructor. * * @param EventDispatcherInterface $eventDispatcher */ - public function __construct(EventDispatcherInterface $eventDispatcher) + public function __construct(EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper) { $this->eventDispatcher = $eventDispatcher; + $this->authorizationHelper = $authorizationHelper; } @@ -259,6 +267,11 @@ class EventController extends Controller $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + $reachablesCircles = $this->authorizationHelper + ->getReachableCircles( + $this->getUser(), + new Role(EventVoter::SEE), + $person->getCenter() ); $total = $em @@ -278,10 +291,13 @@ class EventController extends Controller ->createQuery(" SELECT participation FROM ChillEventBundle:Participation participation + JOIN participation.event event WHERE participation.person = :person_id + AND event.circle IN (:reachable_circles) ") ->setParameters(array( ':person_id' => $person_id, + ':reachable_circles' => $reachablesCircles )) ->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber()) ->setMaxResults($paginator->getItemsPerPage()) diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index 341bc9dcb..ed37ca7a6 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -2,4 +2,5 @@ services: Chill\EventBundle\Controller\EventController: arguments: $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' tags: ['controller.service_arguments']