classes/Events/API/Calendar.php
public function getRecurringEvents($starttime = null, $endtime = null) {

		if (is_null($starttime)) {
			$starttime = time();
		}
		if (is_null($endtime)) {
			$endtime = strtotime('+1 year', $starttime);
		}

		$starttime = sanitize_int($starttime);
		$endtime = sanitize_int($endtime);
		$relationship_name = sanitize_string(self::EVENT_CALENDAR_RELATIONSHIP);

		$dbprefix = elgg_get_config('dbprefix');

		// for performance we'll denormalize metastrings first
		$mdr_name = elgg_get_metastring_id('repeat');
		$mdr_val = elgg_get_metastring_id(1);
		$mds_name = elgg_get_metastring_id('start_timestamp');
		$mdre_name = elgg_get_metastring_id('repeat_end_timestamp');
		$options = array(
			'type' => 'object',
			'subtype' => Event::SUBTYPE,
			'joins' => array(
				"JOIN {$dbprefix}entity_relationships er ON er.guid_one = e.guid", // calendar relationship
				"JOIN {$dbprefix}metadata mdr ON mdr.entity_guid = e.guid", // repeating metadata
				"JOIN {$dbprefix}metadata mds ON mds.entity_guid = e.guid", // start time metadata
				"JOIN {$dbprefix}metastrings mss ON mss.id = mds.value_id", // start time metastring
				"JOIN {$dbprefix}metadata mdre ON mdre.entity_guid = e.guid", // repeat end time metadata
				"JOIN {$dbprefix}metastrings msre ON msre.id = mdre.value_id" // repeat end time metastring
			),
			'wheres' => array(
				"er.guid_two = {$this->guid} AND er.relationship = '{$relationship_name}'",
				"mdr.name_id = {$mdr_name} AND mdr.value_id = {$mdr_val}",
				"mds.name_id = {$mds_name}",
				"mdre.name_id = {$mdre_name}",
				// event start is before our endtime AND (repeat end is after starttime, or there is no repeat end)
				"((CAST(mss.string AS SIGNED) < {$endtime}) AND (CAST(msre.string AS SIGNED) > {$starttime} OR CAST(msre.string AS SIGNED) = 0))"
			),
			'limit' => false
		);

		$events = new ElggBatch('elgg_get_entities', $options);

		// these entities may not actually show up in our range yet, need to filter
		$recurring_events = array();
		foreach ($events as $event) {
			/* @var Event $event */
			if ($event->getStartTimes($starttime, $endtime)) {
				// hey, we have a hit!
				$recurring_events[] = $event;
			}
		}

		return $recurring_events;
	}
public function getRecurringEvents($starttime = null, $endtime = null) {

		if (is_null($starttime)) {
			$starttime = time();
		}
		if (is_null($endtime)) {
			$endtime = strtotime('+1 year', $starttime);
		}

		$starttime = sanitize_int($starttime);
		$endtime = sanitize_int($endtime);
		$relationship_name = sanitize_string(self::EVENT_CALENDAR_RELATIONSHIP);

		$dbprefix = elgg_get_config('dbprefix');

		// for performance we'll denormalize metastrings first
		$mdr_name = elgg_get_metastring_id('repeat');
		$mdr_val = elgg_get_metastring_id(1);
		$mds_name = elgg_get_metastring_id('start_timestamp');
		$mdre_name = elgg_get_metastring_id('repeat_end_timestamp');
		$options = array(
			'type' => 'object',
			'subtype' => Event::SUBTYPE,
			'joins' => array(
				"JOIN {$dbprefix}entity_relationships er ON er.guid_one = e.guid", // calendar relationship
				"JOIN {$dbprefix}metadata mdr ON mdr.entity_guid = e.guid", // repeating metadata
				"JOIN {$dbprefix}metadata mds ON mds.entity_guid = e.guid", // start time metadata
				"JOIN {$dbprefix}metastrings mss ON mss.id = mds.value_id", // start time metastring
				"JOIN {$dbprefix}metadata mdre ON mdre.entity_guid = e.guid", // repeat end time metadata
				"JOIN {$dbprefix}metastrings msre ON msre.id = mdre.value_id" // repeat end time metastring
			),
			'wheres' => array(
				"er.guid_two = {$this->guid} AND er.relationship = '{$relationship_name}'",
				"mdr.name_id = {$mdr_name} AND mdr.value_id = {$mdr_val}",
				"mds.name_id = {$mds_name}",
				"mdre.name_id = {$mdre_name}",
				// event start is before our endtime AND (repeat end is after starttime, or there is no repeat end)
				"((CAST(mss.string AS SIGNED) < {$endtime}) AND (CAST(msre.string AS SIGNED) > {$starttime} OR CAST(msre.string AS SIGNED) = 0))"
			),
			'limit' => false
		);

		$events = new ElggBatch('elgg_get_entities', $options);

		// these entities may not actually show up in our range yet, need to filter
		$recurring_events = array();
		foreach ($events as $event) {
			/* @var Event $event */
			if ($event->getStartTimes($starttime, $endtime)) {
				// hey, we have a hit!
				$recurring_events[] = $event;
			}
		}

		return $recurring_events;
	}
public function getRecurringEvents ( $ starttime = null , $ endtime = null ) { if ( is_null ( $ starttime ) ) { $ starttime = time ( ) ; } if ( is_null ( $ endtime ) ) { $ endtime = strtotime ( '+1 year' , $ starttime ) ; } $ starttime = sanitize_int ( $ starttime ) ; $ endtime = sanitize_int ( $ endtime ) ; $ relationship_name = sanitize_string ( self :: EVENT_CALENDAR_RELATIONSHIP ) ; $ dbprefix = elgg_get_config ( 'dbprefix' ) ; // for performance we'll denormalize metastrings first $ mdr_name = elgg_get_metastring_id ( 'repeat' ) ; $ mdr_val = elgg_get_metastring_id ( 1 ) ; $ mds_name = elgg_get_metastring_id ( 'start_timestamp' ) ; $ mdre_name = elgg_get_metastring_id ( 'repeat_end_timestamp' ) ; $ options = array ( 'type' => 'object' , 'subtype' => Event :: SUBTYPE , 'joins' => array ( "JOIN {$dbprefix}entity_relationships er ON er.guid_one = e.guid" , // calendar relationship "JOIN {$dbprefix}metadata mdr ON mdr.entity_guid = e.guid" , // repeating metadata "JOIN {$dbprefix}metadata mds ON mds.entity_guid = e.guid" , // start time metadata "JOIN {$dbprefix}metastrings mss ON mss.id = mds.value_id" , // start time metastring "JOIN {$dbprefix}metadata mdre ON mdre.entity_guid = e.guid" , // repeat end time metadata "JOIN {$dbprefix}metastrings msre ON msre.id = mdre.value_id" // repeat end time metastring ) , 'wheres' => array ( "er.guid_two = {$this->guid} AND er.relationship = '{$relationship_name}'" , "mdr.name_id = {$mdr_name} AND mdr.value_id = {$mdr_val}" , "mds.name_id = {$mds_name}" , "mdre.name_id = {$mdre_name}" , // event start is before our endtime AND (repeat end is after starttime, or there is no repeat end) "((CAST(mss.string AS SIGNED) < {$endtime}) AND (CAST(msre.string AS SIGNED) > {$starttime} OR CAST(msre.string AS SIGNED) = 0))" ) , 'limit' => false ) ; $ events = new ElggBatch ( 'elgg_get_entities' , $ options ) ; // these entities may not actually show up in our range yet, need to filter $ recurring_events = array ( ) ; foreach ( $ events as $ event ) { /* @var Event $event */ if ( $ event -> getStartTimes ( $ starttime , $ endtime ) ) { // hey, we have a hit! $ recurring_events [ ] = $ event ; } } return $ recurring_events ; }
Returns a batch of recurring events in a given time range

@param int $starttime Time range start, default: now
@param int $endtime   Time range end, default: 1 year from start time
@return array
Returns a batch of recurring events in a given time range