Fixed incorrect check to see if the hook that permits other add-ons to add an action button to the event list returned any data.
return $timesData;
}
+
+ /**
+ * Get recurances along with all times entries for a particular event ID
+ *
+ * @param integer $eventID Event ID
+ *
+ * @return object Class object
+ *
+ */
+ public function getRecurWithTimes($eventID)
+ {
+
+ // Check for positive integer event ID
+ $eventID = ($eventID-0);
+ if ($eventID == 0) {
+ return false;
+ }
+
+ // Get all recurrences
+ $recurrences = $this->getList("T.event = $eventID", 'start_time');
+
+ // If we have recurrences, try to get times for each
+ if ($recurrences) {
+ 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']);
+ }
+ }
+
+ return $recurrences;
+
+ }
}
}
+ /**
+ * Get event times simplified by Recurrence
+ * This returns less data than the function above because it's already
+ * known what the event and recurrence is.
+ *
+ * @param integer $recurrenceID ID of recurrence
+ * @param string $startDate Date formatted to be used in MySQL - optional
+ * @param string $endDate Date formatted to be used in MySQL - optional
+ *
+ * @return object Class object
+ */
+ public function getEventTimesByRecurrenceSimplified($recurrenceID = false, $startDate = false, $endDate = false)
+ {
+
+ $savedFields = $this->fields;
+
+ $this->fields = array(
+ 'id' => $savedFields['id'],
+ 'start_time' => $savedFields['start_time'],
+ 'end_time' => $savedFields['end_time'],
+ 'all_day' => $savedFields['all_day']
+ );
+
+ $where = " T.recur_id = $recurrenceID ";
+
+ // Only display times from startDate to endDate
+ if (!$startDate) {
+ $startDate = date('Y-m-d H:i:s');
+ }
+ $where .= " AND T.start_time >= '$startDate' ";
+ if ($endDate) {
+ $where .= " AND T.start_time <= '$endDate' ";
+ }
+
+ $timesSimplified = $this->getList($where, 'start_time');
+
+ $this->fields = $savedFields;
+
+ return $timesSimplified;
+
+ }
+
+
}
?>
return $eventId;
} );
+
if (isset($this->config['loggedInUser']) && isset($this->config['loggedInUser']['contactUser']) && $this->config['loggedInUser']['contactUser']) {
// check the settings to see if members are allow to manage events
$memberEventsAllowed = isset( $this->config['settings']['member_events_allowed'] )
);
}
+// Add hook to return event recurrences and times data for a specific event ID
+add_filter( 'glm-member-db-events-get-event-times', function( $eventID ){
+
+ // Check for positive integer event ID
+ $eventId = ($eventID-0);
+ if ($eventId == 0) {
+ return $eventID;
+ }
+
+ // Call dedicated model to get event base data
+ require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php';
+ $EventData = new GlmDataEvents($this->wpdb, $this->config);
+ $eventData = $EventData->getEntry($eventId);
+
+ // If we didn't get a good event, just pass on supplied data
+ if (!$eventData) {
+ return $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);
+
+ return $recurrences;
+
+} );
+
+
/*
<td class="glm-nowrap">
{$e.status.name}
</td>
- <td>
+ <td>
{$e.firstDate}
</td>
<td>
- {$e.lastDate}
+ {$e.lastDate}
</td>
<td>
<a class="button button-secondary glm-button-small" href="{$thisUrl}?page=glm-members-admin-menu-events-list&glm_action=list&member={$memberID}&option=clone&event={$e.id}">Clone</a>
</td>
<td>
<a class="button button-secondary glm-button-small" href="{$siteBaseUrl}event-detail/{$e.name_slug}/" target="_blank">View Event</a>
- <!-- Filter to pick up buttons from other add-ons - $e_link expects array( 'title' => 'some title', 'url' => 'some url' ) -->
- {$e_link = apply_filters('glm_members_add_link_to_event_list_entry', $e.id)}
- {if $e_link}
- <a class="button button-secondary glm-button-small" href="{$e_link.url|escape:'string'}">{$e_link.title}</a>
- {/if}
+ {$e_link = apply_filters('glm_members_add_link_to_event_list_entry', $e.id)}
+ {if is_array($e_link)}
+ <a class="button button-secondary glm-button-small" href="{$e_link.url|escape:'string'}">{$e_link.title}</a>
+ {/if}
</td>
</tr>
{/foreach}
});
</script>
-
+
{include file='admin/footer.html'}