Update name search.
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 4 Jun 2018 15:25:56 +0000 (11:25 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 4 Jun 2018 15:26:30 +0000 (11:26 -0400)
Category and the name search parts were conflicting.
Setup a isNameSearch Parameter to end the confusion.

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

index a5acf84..d1e4bc8 100644 (file)
--- a/index.php
+++ b/index.php
@@ -4,7 +4,7 @@
  * Plugin URI: http://www.gaslightmedia.com/
  * Description: Gaslight Media Members Database.
 
- * Version: 1.6.85
+ * Version: 1.6.86
 
  * Author: Chuck Scott
  * Author URI: http://www.gaslightmedia.com/
@@ -22,7 +22,7 @@
  * @author Chuck Scott <cscott@gaslightmedia.com>
  * @license http://www.gaslightmedia.com Gaslightmedia
 
- * @version 1.6.85
+ * @version 1.6.86
 
  */
 
@@ -47,7 +47,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.85');
+define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.86');
 define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.1.5');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
index 6e2412c..f284c6b 100644 (file)
@@ -199,7 +199,7 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
      * @access public
      * @return array events
      */
-    public function getModelEventsData( $categoryId = null, $limit = null, $memberId = null, $amenityId = null, $venueId = null, $cityId = null )
+    public function getModelEventsData( $categoryId = null, $limit = null, $memberId = null, $amenityId = null, $venueId = null, $cityId = null, $isNameSearch = false )
     {
 
         $this->postAddTimes = true;
@@ -226,7 +226,7 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
         }
 
         // check for city id in event list search
-        if ( $cityId = filter_var( $cityId, FILTER_VALIDATE_INT ) ) {
+        if ( $cityId = filter_var( $cityId, FILTER_VALIDATE_INT ) && !$isNameSearch ) {
             $whereParts[] = "
             T.id IN (
                 SELECT event
@@ -257,7 +257,7 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
         $cats  = array_filter( filter_var( $categoryId, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FORCE_ARRAY ) ) );
         $catId = filter_var( $categoryId, FILTER_VALIDATE_INT );
         // If a category ID is supplied
-        if ( $catId ) {
+        if ( $catId  && !$isNameSearch ) {
             //$events = $this->getEventsByCategory( $catId, $limit );
             $whereParts[] = "
                 T.id IN (
@@ -276,7 +276,7 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
             if ( $limit = filter_var( $limit, FILTER_VALIDATE_INT ) ) {
                 $order .= " LIMIT {$limit} OFFSET 0";
             }
-        } else if ( $this->notInCat && !empty( $this->notInCat ) ) {
+        } else if ( $this->notInCat && !empty( $this->notInCat ) && !$isNameSearch ) {
             $whereParts[] = "
                 T.id NOT IN (
                     SELECT event
@@ -295,7 +295,7 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
             }
 
             // Else if the $categoryId is an array
-        } else if ( $cats && !empty( $cats ) ) {
+        } else if ( $cats && !empty( $cats ) && !$isNameSearch ) {
             $whereParts[] = "
                 T.id IN (
                     SELECT event
@@ -351,6 +351,7 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
                 ";
         }
 
+        // echo '<pre>$whereParts: ' . print_r( $whereParts, true ) . '</pre>';
         if ( isset( $whereParts ) && !empty( $whereParts ) ) {
             $where = implode( ' AND ', $whereParts);
         }
index 704079d..4fec55f 100644 (file)
@@ -379,7 +379,7 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
             break;
         case 'event-list-name':
             $this->postAddRecurrences = true;
-            $events = $this->getModelEventsData( $eventNameSearch, null, $memberId, $amenityId, $venueId );
+            $events = $this->getModelEventsData( $eventNameSearch, null, $memberId, $amenityId, $venueId, null, true );
             $this->postAddRecurrences = false;
             if ( !$view ) {
                 $view = 'agenda.html';