/**
  * @param $params
  * @param \Doctrine\ODM\MongoDB\Query\Builder $queryBuilder
  *
  * @return mixed
  */
 public function createQuery($params, $queryBuilder)
 {
     if (!empty($params['text'])) {
         $queryBuilder->text($params['text']);
     }
     $queryBuilder->field('isDraft')->equals(false);
     if (isset($params['sort'])) {
         foreach (explode(",", $params['sort']) as $sort) {
             $queryBuilder->sort($this->filterSort($sort));
         }
     }
     return $queryBuilder;
 }
Esempio n. 2
0
 /**
  * Creates a query for filtering organizations
  *
  * @see \Core\Repository\Filter\AbstractPaginationQuery::createQuery()
  * @param $params
  * @param \Doctrine\ODM\MongoDB\Query\Builder $queryBuilder
  * @return mixed
  */
 public function createQuery($params, $queryBuilder)
 {
     $userID = $this->auth->getUser()->getId();
     if ($params instanceof Parameters) {
         $value = $params->toArray();
     } else {
         $value = $params;
     }
     if (isset($params['text']) && $params['text']) {
         $queryBuilder->text($params['text']);
     }
     /*
      * We only show organizations to which the user has view permissions.
      */
     $queryBuilder->field('permissions.view')->equals($userID);
     if (!isset($value['sort'])) {
         $value['sort'] = '-date';
     }
     $queryBuilder->sort($this->filterSort($value['sort']));
     return $queryBuilder;
 }