mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
listByPerson, display only events for current circle
This commit is contained in:
parent
d07cbb15da
commit
42c9a24472
@ -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())
|
||||
|
@ -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']
|
||||
|
Loading…
x
Reference in New Issue
Block a user