require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataEvents.php';
require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataCategories.php';
require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataEventCategories.php';
+require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataAmenities.php';
/**
* GlmMembersFront_events_list
/**
* getCategories
*
- * Grab all of the categories for the events
+ * Grab all of the categories for the events (current)
*
* @access public
* @return array categories
return $categoryData->getCategoriesWithCurrentEvents();
}
+ /**
+ * getAmenities
+ *
+ * Grab all of the amenities for the events (current)
+ *
+ * @access public
+ * @return void
+ */
+ public function getAmenities()
+ {
+ $amenityData = new GlmDataEventsAmenities( $this->wpdb, $this->config );
+ return $amenityData->getAmenitiesWithCurrentEvents();
+ }
+
+ /**
+ * getMembers
+ *
+ * Generate a list of members that have events (current)
+ *
+ * @access public
+ * @return void
+ */
+ public function getMembers()
+ {
+ $members = array();
+ $memberData = apply_filters('member_names_and_ids', '');
+ if ( isset( $memberData ) && is_array( $memberData) && !empty( $memberData) ) {
+ foreach ( $memberData as $member ) {
+ // check to see if this member has an event (current)
+ $sql = "
+ SELECT count(id)
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
+ WHERE ref_dest = %d
+ AND id IN (
+ SELECT event
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+ WHERE active
+ AND start_time >= NOW())";
+ $result = $this->wpdb->get_var( $this->wpdb->prepare( $sql, $member['id'] ) );
+
+ if ( $result > 0 ) {
+ $members[$member['id']] = array(
+ 'id' => $member['id'],
+ 'name' => $member['name']
+ );
+ }
+ }
+ }
+ return $members;
+ }
+
/**
* getModelEventsData
*
$where .= "T.ref_type = ".$this->config['ref_type_numb']['Member']." and T.ref_dest = $memberId AND ";
}
- // If a catgegory ID is supplied
+ // If a category ID is supplied
if ($catId = filter_var( $categoryId, FILTER_VALIDATE_INT )) {
$events = $this->getEventsByCategory( $catId, $limit );
// Else if a event name is supplied
*/
public function modelAction( $actionData = false )
{
- $limit = null;
- $status = null;
- $categoryId = null;
- $action = '';
- $settings = array();
- $events = array();
- $event = array();
- $calDates = false;
- $memberId = null;
- $view = null;
- $featured = null;
- $current = null;
- $eventsByDate = null;
+ $limit = null;
+ $status = null;
+ $action = '';
+ $settings = array();
+ $events = array();
+ $event = array();
+ $calDates = false;
+ $view = null;
+ $featured = null;
+ $current = null;
+ $eventsByDate = null;
+ $categoryId = null;
+ $categories = array();
+ $amenityId = null;
+ $amenities = array();
+ $memberId = null;
+ $members = array();
// If a memberID has been specified, limit to that member
if ( isset( $actionData['request']['member'] ) ) {
$search = true;
$action = 'event-detail';
}
- if (isset($_REQUEST['category']) && $categoryId = filter_var($_REQUEST['category'], FILTER_VALIDATE_INT)) {
+ if ( isset( $_REQUEST['category'] ) && $categoryId = filter_var( $_REQUEST['category'], FILTER_VALIDATE_INT ) ) {
+ $search = true;
+ $action = 'event-list';
+ }
+ if ( isset( $_REQUEST['amenity'] ) && $amenityId = filter_var( $_REQUEST['amenity'], FILTER_VALIDATE_INT ) ) {
+ $search = true;
+ $action = 'event-list';
+ }
+ if ( isset( $_REQUEST['member'] ) && $memberId = filter_var( $_REQUEST['member'], FILTER_VALIDATE_INT ) ) {
$search = true;
$action = 'event-list';
}
$search = true;
$action = 'nameSearch';
}
- if ( isset($_REQUEST['glm_event_from']) ) {
+ if ( isset( $_REQUEST['glm_event_from'] ) ) {
$fromDate = filter_var(
$_REQUEST['glm_event_from'],
FILTER_VALIDATE_REGEXP,
}
} else {
// This is the default date range for this agenda view
- $total_current_events = $this->checkHaveAnyEvents();
+ $total_current_events = $this->checkHaveAnyEvents();
+ $total_events_wanted = 5;
+ if ( $total_events_wanted > $total_current_events ) {
+ $total_events_wanted = ( $total_current_events > 1 ) ? $total_current_events - 1: 1;
+ }
$weeks_to_check = 1;
$event_count = 0;
do {
$event_count = $this->getEventCountForWeekRange( ++$weeks_to_check );
- } while ( $event_count <= 5 && $total_current_events > 5 );
+ } while ( $event_count <= $total_events_wanted && $total_current_events >= $total_events_wanted );
$week_string = ( $weeks_to_check === 1 ) ? 'weeks': 'week';
$toDate = date('m/d/Y', strtotime( '+ ' . $weeks_to_check . ' ' . $week_string ));
}
$categories = $this->getCategories();
+ $amenities = $this->getAmenities();
+ $members = $this->getMembers();
wp_register_script(
'event-dashboard-js',
GLM_MEMBERS_EVENTS_PLUGIN_BASE_URL . '/js/dashboard.js',
switch ( $action ) {
case 'front-page':
- $events = $this->getModelEventsData($categoryId, $limit);
+ $events = $this->getModelEventsData( $categoryId, $limit );
break;
case 'event-list-name':
$events = $this->getModelEventsData( $eventNameSearch );
break;
case 'event-list':
$this->postAddRecurrences = true;
- $events = $this->getModelEventsData($categoryId);
+ $events = $this->getModelEventsData( $categoryId, null, $memberId );
if ( !$view ) {
$view = 'agenda.html';
}
include_once GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/SetaPDF/Autoload.php';
$this->postAddLocations = true;
$this->postAddRecurrences = true;
- $events = $this->getModelEventsData($categoryId);
+ $events = $this->getModelEventsData( $categoryId );
$this->postAddLocations = false;
$this->postAddRecurrences = false;
if ( !$view ) {
$view = 'agenda.html';
}
- $events = $this->getModelEventsData($categoryId, null, $memberId);
+ $events = $this->getModelEventsData( $categoryId, null, $memberId );
$this->postAddRecurrences = false;
-
-
- // Also get event times for calendar display
-// require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataTimes.php';
-// $Times = new GlmDataEventsTimes($this->wpdb, $this->config);
-// $calDates = $Times->getEventTimesSimplified($categoryId);
-
-
break;
}
// check if event search was performed and if it is override the view to agenda
$override_default_view = ( isset( $_REQUEST['override_default'] ) ) ? $_REQUEST['override_default'] : '';
- if ( $override_default_view === 'yes' ){
+ if ( $override_default_view === 'yes' ) {
$calendar_view = "agenda";
- }else if ( $calendar_view[0]['calendar_view'] === "" || empty($calendar_view[0]['calendar_view'] ) ){
+ } else if ( $calendar_view[0]['calendar_view'] === "" || empty($calendar_view[0]['calendar_view'] ) ) {
$calendar_view = "agenda";
} else {
$calendar_view = $calendar_view[0]['calendar_view'];
'eventId' => false,
'categoryId' => $categoryId,
'categories' => $categories,
+ 'amenityId' => $amenityId,
+ 'amenities' => $amenities,
+ 'memberId' => $memberId,
+ 'members' => $members,
'events' => $events,
'eventsByDate' => $eventsByDate,
'fromDate' => $fromDate,
public function checkHaveAnyEvents()
{
$from = date( 'Y-m-d' );
- return $this->wpdb->get_var(
- $this->wpdb->prepare(
- "SELECT count(id)
- FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
- WHERE DATE(start_time) >= %s ",
- $from
- )
- );
+ $sql = "SELECT count(id)
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
+ WHERE status = 10
+ AND id IN (
+ SELECT event
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+ WHERE DATE(start_time) >= %s)";
+ return $this->wpdb->get_var( $this->wpdb->prepare( $sql, $from, $to ) );
}
/**
* getEventCountForWeekRange