mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
FEATURE [user filter] implement query. Selecting multiple users doesn't work
This commit is contained in:
@@ -51,7 +51,8 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
|
||||
|
||||
public function buildBaseQuery(
|
||||
?string $pattern = null,
|
||||
?array $flags = []
|
||||
?array $flags = [],
|
||||
?array $users = []
|
||||
): QueryBuilder {
|
||||
$qb = $this->em->createQueryBuilder();
|
||||
$qb
|
||||
@@ -62,6 +63,24 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
|
||||
->setParameter('pattern', '%' . $pattern . '%');
|
||||
}
|
||||
|
||||
if (count($users) > 0) {
|
||||
$orXUser = $qb->expr()->orX();
|
||||
|
||||
foreach ($users as $key => $user) {
|
||||
$orXUser->add(
|
||||
$qb->expr()->eq('t.assignee', ':user')
|
||||
);
|
||||
|
||||
$qb->setParameter('user', $user);
|
||||
}
|
||||
|
||||
if ($orXUser->count() > 0) {
|
||||
$qb->andWhere($orXUser);
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
if (count($flags) > 0) {
|
||||
$orXDate = $qb->expr()->orX();
|
||||
$orXState = $qb->expr()->orX();
|
||||
@@ -183,9 +202,10 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
|
||||
|
||||
public function countByAllViewable(
|
||||
?string $pattern = null,
|
||||
?array $flags = []
|
||||
?array $flags = [],
|
||||
?array $users = []
|
||||
): int {
|
||||
$qb = $this->buildBaseQuery($pattern, $flags);
|
||||
$qb = $this->buildBaseQuery($pattern, $flags, $users);
|
||||
|
||||
return $this
|
||||
->addACLGlobal($qb)
|
||||
@@ -231,11 +251,12 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
|
||||
public function findByAllViewable(
|
||||
?string $pattern = null,
|
||||
?array $flags = [],
|
||||
?array $users = [],
|
||||
?int $start = 0,
|
||||
?int $limit = 50,
|
||||
?array $orderBy = []
|
||||
): array {
|
||||
$qb = $this->buildBaseQuery($pattern, $flags);
|
||||
$qb = $this->buildBaseQuery($pattern, $flags, $users);
|
||||
$qb = $this->addACLGlobal($qb);
|
||||
|
||||
return $this->getResult($qb, $start, $limit, $orderBy);
|
||||
|
Reference in New Issue
Block a user