Fetch today's event sessions from the database.

@param string $strDate Date of event sessions to fetch.
@return array
330059
public function fetch(string $strDate)
    {
        // Filter input
        $this->validateDate($strDate);
        $strDateStart = $strDate . ' 00:00:00';
        if ($this->iTimezoneOffset) {
            $strDateStart = date(
                'Y-m-d H:i:s',
                strtotime(
                    $strDateStart . ($this->iTimezoneOffset < 0 ? ' +' : ' ')
                        . -$this->iTimezoneOffset . ' hours'
                )
            );
        }
        $strDateEnd = date('Y-m-d H:i:s', strtotime($strDateStart . ' + 1 day - 1 second'));

        // Get results and sort by time
        $aResults = $this->queryDay($strDateStart, $strDateEnd);
        usort($aResults, function($aResult1, $aResult2) {
            return $aResult1['session_at'] <=> $aResult2['session_at']
                ?: $aResult1['starts_at'] <=> $aResult2['starts_at'];
        });
        return $aResults;
    }
561341
protected function getTimestampedTraitHooks(): array
	{
		return
		[
			'beforeInsert' =>
			[
				function(array $values, $query): array
				{
					$dateTime = new DateTime;

					$createdAtColumn = $this->getCreatedAtColumn();

					$updatedAtColumn = $this->getUpdatedAtColumn();

					$this->columns[$createdAtColumn] = $dateTime;

					$this->columns[$updatedAtColumn] = $dateTime;

					return [$createdAtColumn => $dateTime, $updatedAtColumn => $dateTime] + $values;
				},
			],
			'afterInsert' =>
			[
				function($inserted): void
				{
					if($this->shouldTouchOnInsert() && $inserted && $this->isPersisted)
					{
						$this->touchRelated();
					}
				},
			],
			'beforeUpdate' =>
			[
				function(array $values, $query): array
				{
					$dateTime = new DateTime;

					$updatedAtColumn = $this->getUpdatedAtColumn();

					$this->columns[$updatedAtColumn] = $dateTime;

					return [$updatedAtColumn => $dateTime] + $values;
				},
			],
			'afterUpdate' =>
			[
				function($updated): void
				{
					if($this->shouldTouchOnUpdate() && $updated > 0 && $this->isPersisted)
					{
						$this->touchRelated();
					}
				},
			],
			'afterDelete' =>
			[
				function($deleted): void
				{
					if($this->shouldTouchOnDelete() && $deleted > 0 && $this->isPersisted)
					{
						$this->touchRelated();
					}
				},
			],
		];
	}
516329
public function get_recently_active_sessions($seconds=600) {
		if(is_null($seconds) || !is_numeric($seconds)) {
			$seconds = 10;
		}
		$sql = "SELECT session_id, uid, date_created, last_updated, num_checkins
			FROM cswal_session_table WHERE last_updated > NOW() - interval '". $seconds
				." seconds'";
		try {
			$retval = $this->db->run_query($sql);
		}
		catch(Exception $ex) {
			throw new Exception($ex);
		}
		
		return($retval);
	}
36169
public function generateOccurrences(Array $events, \DateTime $fromDate, \DateTime $toDate, $limit = null)
	{
		$return = array();
		$object = $this;

		$weeklyEvents = array_filter($events, function ($event) use ($object) {
			return $event->getRecurrenceType() === $object->getLabel();
		});

		foreach ($weeklyEvents as $weeklyEvent) {
			$weeklyEventTime = $weeklyEvent->getStartDate()->format('H:i:s');

			// Retrieve the day of the week that the event takes place on
			$day = $weeklyEvent->getStartDate()->format('w');

			$startMarker = $fromDate > $weeklyEvent->getStartDate()
				? clone($fromDate)
				: clone($weeklyEvent->getStartDate());

			while ($startMarker->format('w') != $day) {
				$startMarker->modify('+1 day');
			}

			$maxEndMarker = clone($startMarker);
			$maxEndMarker->modify($this->limit);

			$endMarker = $weeklyEvent->getRecurrenceUntil()
				? min($weeklyEvent->getRecurrenceUntil(), clone($toDate), $maxEndMarker)
				: min(clone($toDate), $maxEndMarker);

			$actualEndMarker = clone($endMarker);

			// The DatePeriod class does not actually include the end date so you have to increment it first
			$endMarker->modify('+1 day');

			$dateInterval = new \DateInterval('P1W');
			$datePeriod = new \DatePeriod($startMarker, $dateInterval, $endMarker);

			$limitMarker = 0;

			foreach ($datePeriod as $date) {
				if (($limit and ($limit === $limitMarker)) or ($date > $actualEndMarker)) {
					break;
				}

				$newWeeklyEvent = clone($weeklyEvent);
				$newStartDate = new \DateTime($date->format('Y-m-d').' '.$weeklyEventTime);

				if ($newStartDate < $startMarker) {
					continue;
				}

				$duration = $newWeeklyEvent->getDuration();

				$newWeeklyEvent->setStartDate($newStartDate);
				
				$newEndDate = clone($newStartDate);
				$newEndDate->add($duration);

				$newWeeklyEvent->setEndDate($newEndDate);
				$newWeeklyEvent->setRecurrenceType();

				$return[] = $newWeeklyEvent;

				$limit and $limitMarker++;
			}
		}

		return $return;
	}
1231004
public function Events()
    {
        $action = $this->request->param('Action');
        //Debug::dump($this->request->params());

        //Normal & Registerable events
        $s = CalendarConfig::subpackage_settings('pagetypes');
        $indexSetting = $s['calendarpage']['index'];
        if ($action == 'eventregistration'
            || $action == 'eventlist'
            || ($action == '' && $indexSetting == 'eventlist')

        ) {
            $events = CalendarHelper::events_for_month($this->CurrentMonth());

            if ($action == 'eventregistration') {
                $events = $events
                    ->filter('Registerable', 1);
            }

            return $events;
        }


        //Search
        if ($action == 'search') {
            $query = $this->SearchQuery();
            $query = strtolower(addslashes($query));
            //Debug::dump($query);
            $qarr = preg_split('/[ +]/', $query);

            $filter = '';
            $first = true;
            foreach ($qarr as $qitem) {
                if (!$first) {
                    $filter .= " AND ";
                }

                $filter .= " (
					Title LIKE '%$qitem%'
					OR Details LIKE '%$qitem%'
				)";
                $first = false;
            }

            //Debug::dump($filter);
            $events = CalendarHelper::all_events()
                ->where($filter);
            return $events;
        }




        //TODO below doesn't need to be that complicated...
//		$events = null;
//		if ($action == 'past') {
//			$events = CalendarHelper::past_events();
//		} else {
//			if ($this->CurrentCategoryID()) {
//				$events = PublicEventCategory::get()
//					->ByID($this->CurrentCategoryID())
//					->ComingEvents($this->CurrentDisplayDate());
//			} else {
//				$events = CalendarHelper::coming_events($this->CurrentDisplayDate());
//			}
//		}
//
//		if ($this->CurrentCalendarID()) {
//			$events = $events->filter(array(
//				'CalendarID' => $this->CurrentCalendarID()
//			));
//		}
//
//		$list = new PaginatedList($events, $this->request);
//		$list->setPageLength(10);
//
//		return $list;
    }
956253
public function findNotConfirmedAndNotRemindedParticipantsByExpireDate(\DateTime $expireDate)
    {
        $dql = '
            SELECT p, s
            FROM Phraseanet:ValidationParticipant p
            JOIN p.session s
            JOIN s.basket b
            WHERE p.is_confirmed = 0
            AND p.reminded IS NULL
            AND s.expires < :date AND s.expires > CURRENT_TIMESTAMP()';

        return $this->_em->createQuery($dql)
                ->setParameter('date', $expireDate, Type::DATETIME)
                ->getResult();
    }
832294
protected function get_legacy_eventdata() {
        return (object) array(
            'courseid' => $this->objectid,
            'userid' => $this->userid,
            'type' => $this->other['type'],
            'target' => $this->other['target'],
            'mode' => $this->other['mode'],
            'operation' => $this->other['operation'],
            'samesite' => $this->other['samesite'],
        );
    }
1188251
protected function get_legacy_eventdata() {
        $attempt = $this->get_record_snapshot('quiz_attempts', $this->objectid);

        $legacyeventdata = new \stdClass();
        $legacyeventdata->component = 'mod_quiz';
        $legacyeventdata->attemptid = $attempt->id;
        $legacyeventdata->timestart = $attempt->timestart;
        $legacyeventdata->timestamp = $attempt->timestart;
        $legacyeventdata->userid = $this->relateduserid;
        $legacyeventdata->quizid = $attempt->quiz;
        $legacyeventdata->cmid = $this->contextinstanceid;
        $legacyeventdata->courseid = $this->courseid;

        return $legacyeventdata;
    }
1126470
public function getInspectionData()
    {
        return [
            static::PARAM_TIME                   => $this->time,
            static::PARAM_MEMORY                 => $this->memory,
            static::PARAM_EVENT_ID               => $this->eventId,
            static::PARAM_IS_START               => $this->isStart,
            static::PARAM_EVENT                  => $this->event->getObject(),
            static::PARAM_NAME                   => $this->name,
            static::PARAM_TARGET                 => $this->target->getValue(),
            static::PARAM_PARAMS                 => $this->params->getValue(),
            static::PARAM_PROPAGATION_IS_STOPPED => $this->propagationIsStopped,
            static::PARAM_TRACE                  => $this->trace->getValue(),
        ];
    }
79901
private function download($fromDate = null, $toDate = null) {
        //use test data if running as test
        if ($this->runastest) {
            $response = file_get_contents(dirname(__FILE__). '/../../tests/currencyLayerTestData.json');
        }
        else {
            $base = 'USD';

            if ($this->settings['use-ssl']) {
                $url = 'https';
            } else {
                $url = 'http';
            }

            if (!empty($fromDate) and !empty($toDate)) {
                $url .= '://apilayer.net/api/timeframe?access_key='.$this->settings['currencylayer-access-key'].'&source='.$base.'&start_date='.$fromDate.'&end_date='.$toDate;
                }
            else if (!empty($fromDate)) {
                $url .= '://apilayer.net/api/historical?access_key=' . $this->settings['currencylayer-access-key'] . '&date=' . $fromDate . '&source=' . $base;

            } else {
                $url .= '://apilayer.net/api/live?access_key=' . $this->settings['currencylayer-access-key'] . '&source=' . $base;
            }
            $this->url = $url;
            $response = $this->connect($url);
        }

        return $response;
    }
825628
public function fetchAs($stmt, $type = null)
    {
        $data = [];

        if ((is_null($type) || $type == '') && static::$dataSource) {
            $type = 'class';
            static::$dataSource = false;
        }

        switch (strtolower($type)) {
            case 'group':
                $data = $stmt->fetchAll(\PDO::FETCH_GROUP | \PDO::FETCH_ASSOC);
                break;
            case 'both':
                $data = $stmt->fetchAll(\PDO::FETCH_BOTH);
                break;
            case 'object':
                $data = $stmt->fetchAll(\PDO::FETCH_OBJ);
                break;
            case 'assoc':
                $data = $stmt->fetchAll(\PDO::FETCH_ASSOC);
                break;
            case 'column':
                $data = $stmt->fetchAll(\PDO::FETCH_COLUMN);
                break;
            case 'class':
                $data = $stmt->fetchAll(\PDO::FETCH_CLASS, '\\Cygnite\\Database\\ResultSet');
                break;
            default:
                $data = $stmt->fetchAll(\PDO::FETCH_CLASS, '\\'.self::cyrus()->getModelClassNs());
                break;
        }

        return $data;
    }
817941
public static Date strToDateWithFormat(String strDate, Format format) {
        SimpleDateFormat localFormat = (SimpleDateFormat) format;
        ParsePosition pos = new ParsePosition(0);
        Date strtodate = localFormat.parse(strDate, pos);
        return strtodate;
    }
613067
public function getData($strKey = null)
    {
        $varReturn = false;
        $arrData = $this->getMeta("data", null);

        if (! is_null($arrData)) {
            if ($strKey == null) {
                $varReturn = $arrData;
            } else {
                if (isset($arrData[$strKey])) {
                    $varReturn = $arrData[$strKey];
                }
            }
        }

        return $varReturn;
    }
32762
public function getData(GetDataEvent $event)
    {
        $options = $event->getOptions() ? $event->getOptions() : [];
        $options['hiddenFilters']['moderation'] = false;

        if (DataSource::CONTEXT_WORKSPACE === $event->getContext()) {
            $options['hiddenFilters']['workspace'] = $event->getWorkspace()->getUuid();
        } elseif (DataSource::CONTEXT_HOME === $event->getContext()) {
            $options['hiddenFilters']['anonymous'] = true;
        }
        $event->setData(
            $this->finder->search(Message::class, $options)
        );

        $event->stopPropagation();
    }
329019
function getEvents (date) {
  date = this.toDate(date);
  if (!date) {
    return null;
  }
  var info = getDayInfo(this.dayInfo, date);
  return info ? info.events : [];
}
587678
public function getEvents()
    {
        $buffer = '';
        $body = $this->response->getBody();
        while (true) {
            // if server close connection - try to reconnect
            if ($body->eof()) {
                // wait retry period before reconnection
                sleep($this->retry / 1000);
                $this->connect();
                // clear buffer since there is no sense in partial message
                $buffer = '';
            }

            $buffer .= $body->read(1);
            if (preg_match(self::END_OF_MESSAGE, $buffer)) {
                $parts = preg_split(self::END_OF_MESSAGE, $buffer, 2);

                $rawMessage = $parts[0];
                $remaining = $parts[1];

                $buffer = $remaining;

                $event = Event::parse($rawMessage);

                // if message contains id set it to last received message id
                if ($event->getId()) {
                    $this->lastId = $event->getId();
                }

                // take into account server request for reconnection delay
                if ($event->getRetry()) {
                    $this->retry = $event->getRetry();
                }

                yield $event;
            }
        }
    }
1202231
public static function coming_events($from = false)
    {
        $time = ($from ? strtotime($from) : mktime(0, 0, 0, date('m'), date('d'), date('Y')));
        $sql = "(StartDateTime >= '".date('Y-m-d', $time)." 00:00:00')";
        $events = PublicEvent::get()->where($sql);
        return $events;
    }