*
* @param integer $categoryId Id of the category for filtering events (optional)
* @param integer $limit Number of events to return (optional)
- * @param integer $memberID Member ID if filtering by member
+ * @param integer $memberId Member ID if filtering by member
+ * @param integer $amenityId Amenity id for filter
*
* @access public
* @return array events
{
$this->postAddTimes = true;
+ $whereParts = array();
$where = '';
if ($memberId = filter_var( $memberId, FILTER_VALIDATE_INT )) {
- $where .= "T.ref_type = ".$this->config['ref_type_numb']['Member']." and T.ref_dest = $memberId AND ";
+ $whereParts[] = "T.ref_type = ".$this->config['ref_type_numb']['Member']." and T.ref_dest = $memberId ";
}
if ( $amenityId = filter_var( $amenityId, FILTER_VALIDATE_INT ) ) {
- $where = "
+ $whereParts[] = "
T.id IN (
SELECT event
FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "amenity_event
// If a category ID is supplied
if ( $catId = filter_var( $categoryId, FILTER_VALIDATE_INT ) ) {
//$events = $this->getEventsByCategory( $catId, $limit );
- $where = "
+ $whereParts[] = "
T.id IN (
SELECT event
FROM " .GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories
// Else if a event name is supplied
} else if ( $term = filter_var( $categoryId, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES ) ) {
$searchTerm = $this->wpdb->esc_like( stripslashes( $term ) );
- $where .= "T.name like '%" . $term . "%'
+ $whereParts[] .= "T.name like '%" . $term . "%'
AND T.status = " . $this->config['status_numb']['Active'] . "
AND T.id IN (
SELECT event
$order .= " LIMIT 2 OFFSET 0";
} else if ( $limit = filter_var( $limit, FILTER_VALIDATE_INT ) ) {
// Need to get the event id's for the next $limit number of events.
- $where .= "T.id
+ $whereParts[] .= "T.id
AND T.status = " . $this->config['status_numb']['Active'] . "
AND T.id IN (
SELECT distinct event
$order = "T.id";
// Otherwise get all categories
} else {
- $where .= "T.status = " . $this->config['status_numb']['Active'] . "
+ $whereParts[] .= "T.status = " . $this->config['status_numb']['Active'] . "
AND T.id IN (
SELECT event
FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times AS ET
";
}
+ if ( isset( $whereParts ) && !empty( $whereParts ) ) {
+ $where = implode( ' AND ', $whereParts);
+ }
+ //echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
+
$events = $this->getList( $where, $order );
if ( !empty( $events ) ) {
}
if ( isset( $_REQUEST['event_name'] )
- && $eventNameSearch = filter_var($_REQUEST['event_name'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)) {
+ && $eventNameSearch = filter_var( $_REQUEST['event_name'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES ) ) {
$search = true;
$action = 'event-list-name';
} else {
switch ( $action ) {
case 'front-page':
- $events = $this->getModelEventsData( $categoryId, $limit );
+ $events = $this->getModelEventsData( $categoryId, $limit, $memberId, $amenityId );
break;
case 'event-list-name':
$events = $this->getModelEventsData( $eventNameSearch, null, $memberId, $amenityId );
if ( !$view ) {
$view = 'agenda.html';
}
- $events = $this->getModelEventsData( $categoryId, null, $memberId );
+ $events = $this->getModelEventsData( $categoryId, null, $memberId, $amenityId );
$this->postAddRecurrences = false;
break;
}