From e4c87e91fd285c7a40dc9c40741dee0ad03e2864 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 9 Oct 2017 11:33:35 -0400 Subject: [PATCH] Updated hook that provides a list of recurrences and times to other add-ons (registrations) to permit returing all times, not just future. --- classes/data/dataRecurrences.php | 13 +++++++++++-- classes/data/dataTimes.php | 3 +++ setup/commonHooks.php | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/classes/data/dataRecurrences.php b/classes/data/dataRecurrences.php index 74fa8f2..89e20c9 100644 --- a/classes/data/dataRecurrences.php +++ b/classes/data/dataRecurrences.php @@ -566,11 +566,12 @@ class GlmDataEventsRecurrences extends GlmDataAbstract * Get recurances along with all times entries for a particular event ID * * @param integer $eventID Event ID + * @param boolean $allTimes Flag to get all times entries for the event, not just current and future * * @return object Class object * */ - public function getRecurWithTimes($eventID) + public function getRecurWithTimes($eventID, $allTimes = false) { // Check for positive integer event ID @@ -579,6 +580,14 @@ class GlmDataEventsRecurrences extends GlmDataAbstract return false; } + // By setting fromDate to false by default we're telling getEventTimesByRecurrenceSimplified() to provide only future times. + $fromDate = false; + + // If all times are requested, set $fromTime to our time epoch. + if ($allTimes) { + $fromDate = date('Y-m-d H:i:s', 0); + } + // Get all recurrences $recurrences = $this->getList("T.event = $eventID", 'start_time'); @@ -587,7 +596,7 @@ class GlmDataEventsRecurrences extends GlmDataAbstract foreach ($recurrences as $k=>$v) { require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataTimes.php'; $Times = new GlmDataEventsTimes($this->wpdb, $this->config); - $recurrences[$k]['times'] = $Times->getEventTimesByRecurrenceSimplified($v['id']); + $recurrences[$k]['times'] = $Times->getEventTimesByRecurrenceSimplified($v['id'], $fromDate); } } diff --git a/classes/data/dataTimes.php b/classes/data/dataTimes.php index ed2fb97..cd6433d 100644 --- a/classes/data/dataTimes.php +++ b/classes/data/dataTimes.php @@ -310,7 +310,10 @@ class GlmDataEventsTimes extends GlmDataAbstract // Only display times from startDate to endDate if (!$startDate) { + + // With no start time supplied, only supply times from today forward. $startDate = date('Y-m-d H:i:s'); + } $where .= " AND T.start_time >= '$startDate' "; if ($endDate) { diff --git a/setup/commonHooks.php b/setup/commonHooks.php index 3d8b2b2..ade13d9 100644 --- a/setup/commonHooks.php +++ b/setup/commonHooks.php @@ -48,7 +48,7 @@ add_filter( 'glm-member-db-events-get-event-times', function( $eventID ){ // Get any schedules and times for this event require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php'; $RecurrenceData = new GlmDataEventsRecurrences($this->wpdb, $this->config); - $recurrences = $RecurrenceData->getRecurWithTimes($eventId); + $recurrences = $RecurrenceData->getRecurWithTimes($eventId, true); return $recurrences; -- 2.17.1