mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge remote-tracking branch 'origin/dune-risky' into dune-risky
This commit is contained in:
commit
915a2e7284
@ -96,29 +96,6 @@ final class ActivityACLAwareRepository
|
||||
$where = '';
|
||||
$parameters = [];
|
||||
|
||||
// condition will be:
|
||||
// FROM activity JOIN person -- not set by us
|
||||
// ON activity.person_id = person.id -- not set by us
|
||||
// WHERE -- not set by us
|
||||
// activity.person_id = ? AND -- only if $context = person
|
||||
// ( -- begin loop through centers, center#0
|
||||
// person.center_id = ?
|
||||
// AND ( -- begin loop for scopes within centers
|
||||
// activity.scope_id = ? -- scope#0
|
||||
// OR -- if scope#i where i > 0
|
||||
// activity.scope_id = ? -- scope#1
|
||||
// )
|
||||
// )
|
||||
// OR -- if center#i where i > 0
|
||||
// ( -- begin loop through centers, center#1
|
||||
// person.center_id = ?
|
||||
// AND ( -- begin loop for scopes within centers
|
||||
// activity.scope_id = ? -- scope#0
|
||||
// OR -- if scope#i where i > 0
|
||||
// activity.scope_id = ? -- scope#1
|
||||
// )
|
||||
// )
|
||||
|
||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
||||
$activityToPerson = $metadataActivity->getAssociationMapping('person')['joinColumns'][0]['name'];
|
||||
@ -190,58 +167,3 @@ final class ActivityACLAwareRepository
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
$qb = $this->repository->createQueryBuilder('a');
|
||||
$qb->select(['a.id', "'activity'", 'a.date']);
|
||||
$qb->join('a.person', 'p');
|
||||
|
||||
switch($context) {
|
||||
case 'center':
|
||||
$qb->where($this->queryTimelineIndexerWhereForCenter($qb, $args['centers']));
|
||||
break;
|
||||
default:
|
||||
throw new \LogicException('context not supported');
|
||||
}
|
||||
|
||||
if ($from) {
|
||||
$qb->andWhere($qb->gt('a.date', ':from'));
|
||||
$qb->setParameter('from', $from);
|
||||
}
|
||||
|
||||
if ($to) {
|
||||
$qb->andWhere($qb->gt('a.date', ':to'));
|
||||
$qb->setParameter('to', $to);
|
||||
}
|
||||
|
||||
return $qb->getQuery();
|
||||
}
|
||||
|
||||
private function queryTimelineIndexerWhereForCenter(QueryBuilder $qb, array $centers): Orx
|
||||
{
|
||||
$i = 0;
|
||||
$orx = $qb->expr()->orX();
|
||||
|
||||
foreach ($centers as $center) {
|
||||
$andx = $qb->expr()->andX();
|
||||
$andx->add($qb->expr()->eq('p.center', ":center_$i"));
|
||||
$qb->setParameter("center_$i", $center);
|
||||
$i++;
|
||||
|
||||
$scopes = $this->authorizationHelper->getReachableCircles(
|
||||
$this->tokenStorage->getToken()->getUser(),
|
||||
new Role(ActivityVoter::SEE_DETAILS),
|
||||
$center,
|
||||
);
|
||||
|
||||
foreach ($scopes as $scope) {
|
||||
$andx->add($qb->expr()->eq('a.scope', ":scope_$i"));
|
||||
$qb->setParameter("scope_$i", $scope);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$orx->add($andx);
|
||||
}
|
||||
|
||||
return $orx;
|
||||
}
|
||||
} */
|
||||
|
@ -117,7 +117,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
||||
private function getWhereClauseForPerson(Person $person)
|
||||
{
|
||||
$parameters = [];
|
||||
$metadataActivity = $this->em->getClassMetadata('ChillActivityBundle:Activity');
|
||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
||||
$role = new Role('CHILL_ACTIVITY_SEE');
|
||||
$reachableScopes = $this->helper->getReachableScopes($this->user,
|
||||
@ -154,8 +154,8 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
||||
|
||||
private function getFromClausePerson()
|
||||
{
|
||||
$metadataActivity = $this->em->getClassMetadata('ChillActivityBundle:Activity');
|
||||
$metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person');
|
||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
||||
|
||||
return $metadataActivity->getTableName().' JOIN '
|
||||
@ -173,7 +173,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
||||
*/
|
||||
public function getEntities(array $ids)
|
||||
{
|
||||
$activities = $this->em->getRepository('ChillActivityBundle:Activity')
|
||||
$activities = $this->em->getRepository(Activity::class)
|
||||
->findBy(array('id' => $ids));
|
||||
|
||||
$result = array();
|
||||
|
Loading…
x
Reference in New Issue
Block a user