adapt UI and controller for Person without centers

This commit is contained in:
2021-09-03 12:41:41 +02:00
parent 2450655452
commit 5b70fb2ee5
14 changed files with 196 additions and 53 deletions

View File

@@ -153,7 +153,7 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface,
protected function search(array $terms, $start, $limit, array $options = array())
{
$qb = $this->createQuery($terms, 'search');
if ($options['simplify'] ?? false) {
$qb->select(
'p.id',
@@ -176,7 +176,7 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface,
$qb
->orderBy('p.firstName')
->addOrderBy('p.lastName');
if ($options['simplify'] ?? false) {
return $qb->getQuery()->getResult(Query::HYDRATE_ARRAY);
} else {
@@ -291,10 +291,15 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface,
//restraint center for security
$reachableCenters = $this->helper->getReachableCenters($this->user,
new Role('CHILL_PERSON_SEE'));
$qb->andWhere($qb->expr()
->in('p.center', ':centers'))
->setParameter('centers', $reachableCenters)
;
$qb->andWhere(
$qb->expr()->orX(
$qb->expr()
->in('p.center', ':centers'),
$qb->expr()
->isNull('p.center')
)
);
$qb->setParameter('centers', $reachableCenters);
$this->_cacheQuery[$cacheKey] = $qb;