createQueryBuilder(); $criteria = Criteria::create(); if (!api_is_platform_admin()) { $criteria->where(Criteria::expr()->in('user', $userList)); } if ($showPrivate == false) { $criteria->andWhere(Criteria::expr()->eq('private', false)); } $qb ->select('p') ->distinct() ->from('ChamiloPluginBundle:StudentFollowUp\CarePost', 'p') ->join('p.user', 'u') ->addCriteria($criteria) ->setFirstResult($firstResults) ->setMaxResults($pageSize) ->groupBy('p.user') ->orderBy('p.createdAt', 'desc') ; if (!empty($keyword)) { $keyword = explode(' ', $keyword); if (is_array($keyword)) { foreach ($keyword as $key) { $key = trim($key); //$key = api_replace_dangerous_char($key); if (empty($key)) { continue; } $qb ->andWhere('u.firstname LIKE :keyword OR u.lastname LIKE :keyword OR u.username LIKE :keyword') ->setParameter('keyword', "%$key%") ; } } else { $qb ->andWhere('u.firstname LIKE :keyword OR u.lastname LIKE :keyword OR u.username LIKE :keyword') ->setParameter('keyword', "%$keyword%") ; } } $query = $qb->getQuery(); $items = new Paginator($query, $fetchJoinCollection = true); $totalItems = count($items); $pagesCount = ceil($totalItems / $pageSize); } $pagination = ''; $url = api_get_self().'?'; if ($totalItems > 1) { $pagination .= '