From 8fad57e7f74657d8eb6e127f1895432d15b5e701 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 4 Jun 2018 11:25:56 -0400 Subject: [PATCH] Update name search. Category and the name search parts were conflicting. Setup a isNameSearch Parameter to end the confusion. --- index.php | 6 +++--- models/front/events/baseAction.php | 11 ++++++----- models/front/events/list.php | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/index.php b/index.php index a5acf84..d1e4bc8 100644 --- 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 * @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. diff --git a/models/front/events/baseAction.php b/models/front/events/baseAction.php index 6e2412c..f284c6b 100644 --- a/models/front/events/baseAction.php +++ b/models/front/events/baseAction.php @@ -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 '
$whereParts: ' . print_r( $whereParts, true ) . '
'; if ( isset( $whereParts ) && !empty( $whereParts ) ) { $where = implode( ' AND ', $whereParts); } diff --git a/models/front/events/list.php b/models/front/events/list.php index 704079d..4fec55f 100644 --- a/models/front/events/list.php +++ b/models/front/events/list.php @@ -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'; -- 2.17.1