Updating city search for events.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 14 Aug 2018 20:17:06 +0000 (16:17 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 14 Aug 2018 20:17:06 +0000 (16:17 -0400)
When searching city id need to check if the use_member_location is set.
Else need to check for the member info city.

index.php
models/front/events/baseAction.php

index 8d842bf..c96393d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
  * Plugin Name: GLM Members Database Events
  * Plugin URI: http://www.gaslightmedia.com/
  * Description: Gaslight Media Members Database.
- * Version: 1.6.92
+ * Version: 1.6.93
  * Author: Chuck Scott
  * Author URI: http://www.gaslightmedia.com/
  * License: GPL2
@@ -19,7 +19,7 @@
  * @package glmMembersDatabaseEventsAddOn
  * @author Chuck Scott <cscott@gaslightmedia.com>
  * @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.6.92
+ * @version 1.6.93
  */
 
 // Check that we're being called by WordPress.
@@ -43,7 +43,7 @@ if (!defined('ABSPATH')) {
  *  so that we're sure the other add-ons see an up to date
  *  version from this plugin.
  */
-define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.92');
+define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.93');
 define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.1.6');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
index f07795a..4cb5d4a 100644 (file)
@@ -202,6 +202,7 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
     public function getModelEventsData( $categoryId = null, $limit = null, $memberId = null, $amenityId = null, $venueId = null, $cityId = null, $isNameSearch = false )
     {
 
+        // echo '<pre>$cityId: ' . print_r( $cityId, true ) . '</pre>';
         $this->postAddTimes = true;
         $whereParts = array();
         $where = $order = '';
@@ -226,18 +227,26 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
         }
 
         // check for city id in event list search
-        if ( $cityId = filter_var( $cityId, FILTER_VALIDATE_INT ) && !$isNameSearch ) {
-            $whereParts[] = "
+        if ( ( $cityId = filter_var( $cityId, FILTER_VALIDATE_INT ) ) && !$isNameSearch ) {
+            // echo '<pre>$cityId: ' . print_r( $cityId, true ) . '</pre>';
+            $whereParts[] = "(
+            (T.use_member_location <> true
+            AND
             T.id IN (
                 SELECT event
                   FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "locations
                  WHERE city = {$cityId}
-                   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 . "
-                        )
+            ))
+        OR (
+            T.use_member_location = true
+            AND
+            T.ref_dest IN (
+                SELECT member
+                  FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info
+                 WHERE status = 10
+                   AND city = {$cityId}
+            )
+            )
             )";
         }