Exemplo n.º 1
0
 /**
  * @param \BoilerAppAccessControl\Entity\AuthAccessEntity $oAuthAccess
  * @return \Doctrine\Common\Collections\ArrayCollection
  */
 public function getLatestActivityLogs(\BoilerAppAccessControl\Entity\AuthAccessEntity $oAuthAccess)
 {
     $oLatestsActivityLogs = new \Doctrine\Common\Collections\ArrayCollection();
     while ($oLatestsActivityLogs->count() < 5) {
         $oCriteria = new \Doctrine\Common\Collections\Criteria(null, array('entity_create' => 'DESC'), null, 1);
         $aCriteria = array();
         if ($oLatestsActivityLogs->count()) {
             $oLastLog = $oLatestsActivityLogs->last();
             $oCriteria->andWhere(\Doctrine\Common\Collections\Criteria::expr()->neq('log_session_id', $oLastLog->getLogSessionId()))->andWhere(\Doctrine\Common\Collections\Criteria::expr()->lt('entity_create', $oLastLog->getEntityCreate()));
         }
         if (!($oLogs = $this->matching($oCriteria)) || !$oLogs->count()) {
             break;
         }
         $oLatestsActivityLogs->add($oLogs->current());
     }
     return $oLatestsActivityLogs;
 }
Exemplo n.º 2
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function searchVenueAction(Request $request)
 {
     $venueName = $request->get('name');
     $venueLocation = $request->get('location');
     $venueTypeBar = $request->get('bar');
     $venueTypeClub = $request->get('club');
     $venueTypeOther = $request->get('other');
     $page = $request->get('page');
     if ($request->get('type') == 'filter') {
         $page = 0;
     }
     $venueTypes = array();
     $criteria = new \Doctrine\Common\Collections\Criteria();
     if ($venueLocation) {
         $criteria->where($criteria->expr()->contains('city', $venueLocation));
         $criteria->orWhere($criteria->expr()->contains('country', $venueLocation));
     }
     if ($venueName) {
         $criteria->andWhere($criteria->expr()->contains('name', $venueName));
     }
     if ($venueTypeBar == 'true') {
         $venueTypes[] = 'bar';
     }
     if ($venueTypeClub == 'true') {
         $venueTypes[] = 'club';
     }
     if ($venueTypeOther == 'true') {
         $venueTypes[] = 'other';
     }
     if (empty($venueTypes)) {
         $venueTypes = array('bar', 'club', 'other');
     }
     $criteria->andWhere($criteria->expr()->in('category', $venueTypes));
     #$criteria->setFirstResult(12 * $page);
     $criteria->setMaxResults(12 * ($page + 1));
     $venues = $this->getEntityManager()->getRepository('ApplicationJraisanenVnuezBundle:Venue')->matching($criteria);
     $allItems = false;
     if ($venues->count() < 12 * ($page + 1)) {
         $allItems = true;
     }
     return $this->render('JraisanenSearchBundle:Search:search_venue.html.twig', array('venues' => $venues, 'all_items' => $allItems));
 }
Exemplo n.º 3
0
 /**
  * Search sessions by searched term by session name
  * @param string $queryTerm Term for search
  * @param array $limit Limit info
  * @return array The sessions
  */
 public function browseSessionsBySearch($queryTerm, array $limit)
 {
     $sessionsToBrowse = [];
     $criteria = Doctrine\Common\Collections\Criteria::create()->where(Doctrine\Common\Collections\Criteria::expr()->contains('name', $queryTerm))->setFirstResult($limit['start'])->setMaxResults($limit['length']);
     $sessions = Database::getManager()->getRepository('ChamiloCoreBundle:Session')->matching($criteria);
     foreach ($sessions as $session) {
         if ($session->getNbrCourses() === 0) {
             continue;
         }
         $sessionsToBrowse[] = $session;
     }
     return $sessionsToBrowse;
 }
Exemplo n.º 4
0
 /**
  * Garbage Collection
  *
  * @param int $maxlifetime
  * @return true
  */
 public function gc($maxlifetime)
 {
     $repo = $this->getEntityManager()->getRepository("zDbSession\\Entity\\Session");
     $collection = $repo->findAll();
     $criteria = new \Doctrine\Common\Collections\Criteria();
     $criteria->andWhere($criteria->expr()->lt('modified', time() + $this->lifetime));
     $this->getEntityManager()->remove($collection->matching($criteria));
     $this->getEntityManager()->flush();
     return \TRUE;
 }