}
- /*
+ /**
* Entry Post Processing Call-Back Method
*
* Perform post-processing for all result entries.
}
- /*
+ /**
+ * getCategoriesWithCurrentEvents
+ *
+ * Returns a list of categories ordered by name that have an event with
+ * current event times.
+ *
+ * @access public
+ * @return void
+ */
+ public function getCategoriesWithCurrentEvents()
+ {
+ $where = " T.id IN (
+ SELECT category
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories
+ WHERE event IN (
+ SELECT event
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+ WHERE active
+ AND start_time >= now()
+ )
+ ) ";
+ $order = "T.name";
+ return $this->getList($where, $order);
+ }
+
+ /**
* Check other requirements
*
* When deleteing categories, check for references in sub-categories and set them to no parent.
return $r;
}
- /*
+ /**
* Sort a database result array (from DataAbstract.php) by parent, child relationships
*
* @param array $array Array to be sorted
* @access public
*/
public $MemberInfo;
+ /**
+ * postAddTimes
+ *
+ * @var bool
+ * @access public
+ */
+ public $postAddTimes = false;
/**
* Constructor
}
- /*
+ /**
* Entry Post Processing Call-Back Method
*
* Perform post-processing for all result entries.
;";
$r['categories'] = $this->wpdb->get_results($sql, ARRAY_A);
+ if ($this->postAddTimes) {
+ $sql = "
+ SELECT ET.*
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times AS ET
+ WHERE ET.start_time >= now()
+ AND ET.active
+ AND ET.event = {$r['id']}
+ ORDER BY ET.start_time";
+ $times = $this->wpdb->get_results($sql, ARRAY_A);
+ $r['times'] = $times;
+ // get the first element of times array
+ if ( !empty( $times ) ) {
+ $r['starting_date'] = $times[0]['start_time'];
+ $r['ending_date'] = $times[count($times) - 1]['end_time'];
+ }
+ }
+
+
return $r;
}
- /*
+ /**
* Update event slug - should be called after an event record is added or updated
*
* @param integer id ID of event that needs the slug updated
}
- /*
+ /**
* Update timestamps for created, updated, approved
*
* @param string $field Field to update
}
- /*
+ /**
* Delete an event and all data associated with it.
*
* @param integer $id ID of event
}
+ /**
+ * getEventsByCategory
+ *
+ * Return array with a list of events by the category
+ * Option parameter to limit the results
+ *
+ * @param mixed $category Category to filter by
+ * @param bool $limit The limit of records to return
+ *
+ * @access public
+ * @return void
+ */
+ public function getEventsByCategory( $category, $limit = null )
+ {
+ $this->postAddTimes = true;
+ var_dump('hello there');
+ $where = "
+ T.id IN (
+ SELECT event
+ FROM " .GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories
+ WHERE category = {$category}
+ AND event IN (
+ SELECT event
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times AS ET
+ WHERE active
+ AND start_time >= now()
+ )
+ )
+ ";
+ $order = "T.id";
+ if ($limit = filter_var($limit, FILTER_VALIDATE_INT)) {
+ $order .= " LIMIT {$limit} OFFSET 0";
+ }
+ $events = $this->getList($where, $order);
+
+ $this->postAddTimes = false;
+ return $events;
+ }
}
?>
*/
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';
/**
* GlmMembersFront_events_list
public function getCategories()
{
- include GLM_MEMBERS_EVENTS_PLUGIN_PATH. '/models/front/events/testCategoryData.php';
- return $categories;
+ $categoryData = new GlmDataEventsCategories( $this->wpdb, $this->config );
+ return $categoryData->getCategoriesWithCurrentEvents();
}
- public function getModelEventsData($categoryId = null)
+ public function getModelEventsData($categoryId = null, $limit = null)
{
- include GLM_MEMBERS_EVENTS_PLUGIN_PATH. '/models/front/events/testEventsData.php';
+ //echo '<pre>categoryId: ' . print_r( $categoryId, true ) . '</pre>';
+ //echo '<pre>limit: ' . print_r( $limit, true ) . '</pre>';
if ($categoryId) {
- return array_filter($events, function($data) use($categoryId) {
- return ($data['category'] == $categoryId) ? 1 : 0;
- });
+ return $this->getEventsByCategory( $categoryId, $limit );
+ } else {
+ return $this->getList();
}
- return $events;
}
public function getModelEventData($eventId)
}
$categories = $this->getCategories();
+ //echo '<pre>' . print_r( $categories, true ) . '</pre>';
wp_register_script(
'event-dashboard-js',
GLM_MEMBERS_EVENTS_PLUGIN_BASE_URL . '/js/dashboard.js',
$view = 'list.html';
break;
default:
- // for the dashboard need to get list of event categories and
- // filter out the events
- $events = $this->getModelEventsData();
$view = 'dashboard.html';
- foreach ( $categories as $cat ) {
- $catEvents = array_filter( $events, function($data) use($cat) {
- return ($data['category'] == $cat['id']) ? 1 : 0;
- } );
+ foreach ( $categories as $catid => $catData ) {
+ $catEvents = $this->getModelEventsData( $catid, 3 );
+ //echo '<pre>' . print_r( $catEvents, true ) . '</pre>';
if ( !empty($catEvents) ) {
- $categoryEvents[$cat['id']] = $catEvents;
+ $categoryEvents[$catid] = $catEvents;
}
}
break;
return $newrules + $rules;
});
-// Add memberslug query var
+// Add eventId query var
add_filter('query_vars', function($vars) {
array_push($vars, 'eventId');
return $vars;
{break}
{/if}
<li class="description text-left">
+ {$event.starting_date|date_format}<br>
<a href="{$siteBaseUrl}event-detail/{$event.slug}">
- {$event.title}
+ {$event.name}
</a>
</li>
{/foreach}