mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
update some queries in the interface to take into account history of user's scope and user's job
This commit is contained in:
@@ -122,9 +122,30 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
->leftJoin('a.user', 'activity_u')
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
'creator.userJob IN (:jobs)',
|
||||
'activity_u.userJob IN (:jobs)',
|
||||
'EXISTS (SELECT 1 FROM ' . User::class . ' activity_user WHERE activity_user MEMBER OF a.users AND activity_user.userJob IN (:jobs))'
|
||||
$qb->expr()->exists(
|
||||
sprintf(
|
||||
"SELECT 1 FROM %s ujh_creator WHERE ujh_creator.user = a.createdBy "
|
||||
. "AND ujh_creator.job IN (:jobs) AND a.createdAt > ujh_creator.startDate "
|
||||
. "AND (ujh_creator.endDate IS NULL or ujh_creator.endDate > a.date)",
|
||||
User\UserJobHistory::class
|
||||
)
|
||||
),
|
||||
$qb->expr()->exists(
|
||||
sprintf(
|
||||
"SELECT 1 FROM %s ujh_u WHERE ujh_u.user = a.user "
|
||||
. "AND ujh_u.job IN (:jobs) AND a.createdAt > ujh_u.startDate "
|
||||
. "AND (ujh_u.endDate IS NULL or ujh_u.endDate > a.date)",
|
||||
User\UserJobHistory::class
|
||||
)
|
||||
),
|
||||
$qb->expr()->exists(
|
||||
sprintf(
|
||||
"SELECT 1 FROM %s ujh_users WHERE ujh_users.user MEMBER OF a.users "
|
||||
. "AND ujh_users.job IN (:jobs) AND a.createdAt > ujh_users.startDate "
|
||||
. "AND (ujh_users.endDate IS NULL or ujh_users.endDate > a.date)",
|
||||
User\UserJobHistory::class
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
->setParameter('jobs', $jobs);
|
||||
@@ -175,13 +196,14 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
||||
public function findUserJobByAssociated(Person|AccompanyingPeriod $associated): array
|
||||
{
|
||||
$in = $this->em->createQueryBuilder();
|
||||
$in->select('IDENTITY(u.userJob)')
|
||||
->from(User::class, 'u')
|
||||
$in->select('IDENTITY(u.job)')
|
||||
->distinct()
|
||||
->from(User\UserJobHistory::class, 'u')
|
||||
->join(
|
||||
Activity::class,
|
||||
'a',
|
||||
Join::WITH,
|
||||
'a.createdBy = u OR a.user = u OR u MEMBER OF a.users'
|
||||
'a.createdBy = u.user OR a.user = u.user OR u.user MEMBER OF a.users AND a.date >= u.startDate ANd (u.endDate IS NULL or u.endDate > a.date)'
|
||||
);
|
||||
|
||||
if ($associated instanceof Person) {
|
||||
|
Reference in New Issue
Block a user