$this->postAddTimes = true;
$where = '';
-
$where .= "T.active = 1
AND T.event IN (
SELECT ET.id
)
AND $this->dateRangeTimes
";
+ if ( isset( $_REQUEST['category'] ) && $catId = filter_var( $_REQUEST['category'], FILTER_VALIDATE_INT ) ) {
+ $where .= "
+ AND T.event IN (
+ SELECT event
+ FROM " .GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories
+ WHERE category = {$catId}
+ )
+ ";
+ }
$events = $this->getList( $where );
if ( $limit = filter_var( $limit, FILTER_VALIDATE_INT ) ) {
$order .= " LIMIT {$limit} OFFSET 0";
}
+ // Else if the $categoryId is an array
+ } else if ( $cats = filter_var( $categoryId, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FORCE_ARRAY ) ) && !empty( $cats ) ) {
+ $whereParts[] = "
+ T.id IN (
+ SELECT event
+ FROM " .GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories
+ WHERE category IN (" . implode( ',', $categoryId ) . ")
+ AND event IN (
+ SELECT event
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times AS ET
+ WHERE status = " . $this->config['status_numb']['Active'] . "
+ AND " . $this->dateRange . "
+ )
+ )
+ ";
+ $order = "T.id";
+ if ( $limit = filter_var( $limit, FILTER_VALIDATE_INT ) ) {
+ $order .= " LIMIT {$limit} OFFSET 0";
+ }
// 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 ) );
if ( isset( $whereParts ) && !empty( $whereParts ) ) {
$where = implode( ' AND ', $whereParts);
}
-
$events = $this->getList( $where, $order );
if ( !empty( $events ) ) {
$search = true;
$action = 'event-detail';
}
- if ( isset( $_REQUEST['category'] ) && $categoryId = filter_var( $_REQUEST['category'], FILTER_VALIDATE_INT ) ) {
- $search = true;
- $action = 'event-list';
+ if ( isset( $_REQUEST['category'] ) ) {
+ $categoryId = filter_var( $_REQUEST['category'], FILTER_VALIDATE_INT );
+ if ( $categoryId ) {
+ $search = true;
+ $action = 'event-list';
+ } else {
+ $categoryId = null;
+ }
+ }
+ // Get any numeric categories selected in the submitted shortcode and add to $cats array.
+ // This sets categories that are available for selection by the user
+ if ( !isset( $_REQUEST['category'] ) && isset( $actionData['request']['category'] ) && $categoryId = filter_var( $actionData['request']['category'], FILTER_SANITIZE_STRING ) ) {
+ $categoryId = array();
+
+ // Convert comma separated list to an array
+ $catsRequested = explode(',', $actionData['request']['category']);
+
+ // Check for numeric IDs only
+ while (list($k, $v) = each($catsRequested)) {
+
+ // If it's just numeric - note Explode returns an array element with value = 0 if no string.
+ if (preg_match('/^[0-9]*$/', trim($v)) && $v > 0) {
+
+ // Clean up the category number and add to cats array
+ $categoryId[] = ($v-0);
+
+ }
+
+ }
+
}
if ( isset( $_REQUEST['amenity'] ) && $amenityId = filter_var( $_REQUEST['amenity'], FILTER_VALIDATE_INT ) ) {
$search = true;
}
$categories = $this->getCategories();
+ if ( isset( $categories ) ) {
+ foreach( $categories as &$category ) {
+ if ( $categoryId && is_array( $categoryId ) && in_array( $category['id'], $categoryId ) ) {
+ $category['default'] = 1;
+ } else if ( $categoryId && $categoryId == $category['id'] ) {
+ $category['default'] = 1;
+ }
+ }
+ }
if ( $this->config['settings']['use_event_amenities'] ) {
$amenities = $this->getAmenities();
}
'limit' => null,
'featured' => null,
'current' => null,
+ 'category' => null,
)
),
'glm-members-event-detail' => array(
Displays a list of events.
</td>
</tr>
+ <tr>
+ <td> </td>
+ <th>
+ category="{ category ID(s) }"
+ </th>
+ <td>
+ The "category" attribute is used to set the default display of events
+ to only those events in a specific category or categories by specifying
+ the category IDs. To select multiple categories, separate the categories with a ",".
+ Categories are specified by ID number. The ID for each category is
+ shown in the Events Categories list. The selection of which events
+ to display may be overridden by the "category-search" parameter.
+ </td>
+ </tr>
<tr>
<td> </td>
<th>
Displays a detail events.
</td>
</tr>
+ <tr>
+ <td> </td>
+ <th>
+ template="{ template }"
+ </th>
+ <td>
+ The "template" attribute is used to set the template that will be
+ used for smarty. Defaults to false.
+ </td>
+ </tr>
<tr>
<th>[glm-members-event-front-add]</th>
<th>member_only="{ True/False }"</th>
Adds an event submission form to the page. The member_only attribute will allow the add event form in the member only section.
</td>
</tr>
+
';
var event_search = $(".glm-search-icon");
var main_content = $("#main-content");
var view = '{$cal_view}';
+ var category = $('#glm-event-category').val();
// console.log(sessionStorage.view + " : " + sessionStorage.override);
event_search.on('click', function(){
action: 'glm_members_admin_ajax',
glm_action: 'eventsCalMonthAJAX',
- month: month
+ month: month,
+ category: category
};
$('.fc-event').remove();
<div class="small-8 medium-4 column">
<input class="glm-search-icon right" type="image" alt="Search" src="{$assetsUrl}search-icon-24x24.png">
<select id="glm-event-category" name="category">
- <option value="">-- All Categories --</option>
+ <option value="0">-- All Categories --</option>
{foreach $categories as $cat}
- <option value="{$cat.id}"{if $categoryId == $cat.id} selected{/if}>{$cat.name}</option>
+ <option value="{$cat.id}"{if $cat.default == 1} selected{/if}>{$cat.name}</option>
{/foreach}
</select>
</div>