Example #1
0
 /**
  * Get the next events
  *
  * @param string $table
  * @param int $uid
  * @param int $limit
  *
  * @return array|NULL
  */
 public function getNextEvents($table, $uid, $limit = 5)
 {
     $databaseConnection = HelperUtility::getDatabaseConnection();
     $now = DateTimeUtility::getNow();
     $now->setTime(0, 0, 0);
     return $databaseConnection->exec_SELECTgetRows('*', self::TABLE_NAME, 'start_date >= ' . $now->getTimestamp() . ' AND foreign_table=' . $databaseConnection->fullQuoteStr($table, self::TABLE_NAME) . ' AND foreign_uid=' . (int) $uid, '', 'start_date ASC, start_time ASC', $limit);
 }
Example #2
0
 /**
  * Find by traversing information
  *
  * @param Index      $index
  * @param bool|true  $future
  * @param bool|false $past
  * @param int        $limit
  * @param string     $sort
  *
  * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
  */
 public function findByTraversing(Index $index, $future = true, $past = false, $limit = 100, $sort = QueryInterface::ORDER_ASCENDING)
 {
     if (!$future && !$past) {
         return [];
     }
     $query = $this->createQuery();
     $now = DateTimeUtility::getNow()->getTimestamp();
     $constraints = [];
     $constraints[] = $query->logicalNot($query->equals('uid', $index->getUid()));
     $constraints[] = $query->equals('foreignTable', $index->getForeignTable());
     $constraints[] = $query->equals('foreignUid', $index->getForeignUid());
     if (!$future) {
         $constraints[] = $query->lessThanOrEqual('startDate', $now);
     }
     if (!$past) {
         $constraints[] = $query->greaterThanOrEqual('startDate', $now);
     }
     $query->setLimit($limit);
     $sort = $sort === QueryInterface::ORDER_ASCENDING ? QueryInterface::ORDER_ASCENDING : QueryInterface::ORDER_DESCENDING;
     $query->setOrderings($this->getSorting($sort));
     return $this->matchAndExecute($query, $constraints);
 }
 /**
  * Render the search view
  *
  * @param \DateTime $startDate
  * @param \DateTime $endDate
  * @param array     $customSearch
  *
  * @ignorevalidation $startDate
  * @ignorevalidation $endDate
  * @ignorevalidation $customSearch
  */
 public function searchAction(\DateTime $startDate = null, \DateTime $endDate = null, array $customSearch = [])
 {
     $baseDate = DateTimeUtility::getNow();
     if (!$startDate instanceof \DateTime) {
         $startDate = clone $baseDate;
     }
     if (!$endDate instanceof \DateTime) {
         $baseDate->modify('+1 month');
         $endDate = $baseDate;
     }
     $this->slotExtendedAssignMultiple(['startDate' => $startDate, 'endDate' => $endDate, 'customSearch' => $customSearch, 'configurations' => $this->getCurrentConfigurations()], __CLASS__, __FUNCTION__);
 }