From 580960671026979a5a2a1971448fdaf8ff3ae9d6 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 26 Jul 2016 11:07:09 -0400 Subject: [PATCH] Fixed serious problems with member searching related to mixing URL and shortcode parameters. --- index.php | 6 +-- models/front/members/list.php | 30 ++++++++++---- setup/shortcodes.php | 73 ++++++++++++++++++++++++++++++++--- 3 files changed, 92 insertions(+), 17 deletions(-) diff --git a/index.php b/index.php index dba8cae9..37240eb8 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Database * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 2.3.0 + * Version: 2.3.1 * Author: Gaslight Media * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -19,7 +19,7 @@ * @package glmMembersDatabase * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 2.3.0 + * @version 2.3.1 */ /* @@ -38,7 +38,7 @@ * */ -define('GLM_MEMBERS_PLUGIN_VERSION', '2.3.0'); +define('GLM_MEMBERS_PLUGIN_VERSION', '2.3.1'); define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.1.11'); // Check if plugin version is not current in WordPress option and if needed updated it diff --git a/models/front/members/list.php b/models/front/members/list.php index 17c116f8..e161fc3f 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -158,6 +158,20 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $blankStart = false; $membersFound = false; + // Check for URL parameter override of shortcode parameters + if (isset($_REQUEST['categorySearch'])) { + $actionData['request']['category-search'] = $_REQUEST['categorySearch']; + } + if (isset($_REQUEST['textSearch'])) { + $actionData['request']['text-search'] = $_REQUEST['textSearch']; + } + if (isset($_REQUEST['alpha'])) { + $actionData['request']['alpha'] = $_REQUEST['alpha']; + } + if (isset($_REQUEST['amenitySearch'])) { + $actionData['request']['amenity-search'] = $_REQUEST['amenitySearch']; + } + // Check for "show" shortcode parameter (what elements to show on the page) $settings = array(); $showList = $actionData['request']['show']; @@ -235,8 +249,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo ); // Apply any provided text search to name, description, short description, and street address - if (isset($_REQUEST['textSearch']) && $_REQUEST['textSearch'] != '') { - $textSearch = addslashes(filter_input(INPUT_POST, 'textSearch', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); + if (trim($actionData['request']['text-search']) != '') { + $textSearch = addslashes(filter_var($actionData['request']['text-search'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); $where .= $whereSep." ( ( SELECT true @@ -351,8 +365,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo } // Check if a category has been submitted - if (isset($_REQUEST['categorySearch'])) { - $c = $_REQUEST['categorySearch'] - 0; + if ($actionData['request']['category-search']) { + $c = $actionData['request']['category-search'] - 0; // Since we have one category selected by the user, make that default if ($c && isset($categoryData[$c])) { @@ -416,8 +430,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo } // Check if an amenity has been submitted - if (isset($_REQUEST['amenitySearch'])) { - $amenSelected = $_REQUEST['amenitySearch']; + if ($actionData['request']['amenity-search']) { + $amenSelected = $actionData['request']['amenity-search']; $amenSelected = array_filter( $amenSelected, function($var){ return is_numeric( $var ) && $var > 0; } ); @@ -467,8 +481,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $alphaSelected = false; // Check for alpha selected - if (isset($_REQUEST['alpha']) && strlen($_REQUEST['alpha']) == 1) { - $alphaSelected = $_REQUEST['alpha']; + if ($actionData['request']['alpha'] && strlen($actionData['request']['alpha']) == 1) { + $alphaSelected = strtoupper($actionData['request']['alpha']); $alphaWhere .= " AND T.member_name LIKE '$alphaSelected%'"; } diff --git a/setup/shortcodes.php b/setup/shortcodes.php index 681747ec..a48ff402 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -71,6 +71,10 @@ $glmMembersShortcodes = array( 'attributes' => array( 'category' => false, 'category-name' => false, + 'category-search' => false, + 'text-search' => false, + 'amenity-search' => false, + 'alpha' => false, 'blank-start' => false, 'show' => false, 'view' => false, @@ -183,10 +187,14 @@ $glmMembersShortcodesDescription = ' category="{ category ID(s) }" - The "category" attribute is used display only members in a specific category or - categories. To select multiple categories, separate the categories with a ",". + The "category" attribute is used to set the default display of members + to only those mnembers 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 Member Categories list. + shown in the Member Categories list. The selection of which members + to display may be overridded by the "category-search" parameter although + these categories will always show in the list of categories that may be + selected in the search filter form. @@ -195,10 +203,63 @@ $glmMembersShortcodesDescription = ' category-name="{ category name(s) }" - The "category-name" attribute is used display only members in a specific category or - categories by specifying the category names. To select multiple categories, - separate the category names with a ",". Category names must match the name of a + The "category-name" attribute is used to set the default display of members + to only those mnembers in a specific category or categories by specifying + the category names. To select multiple categories, separate the category + names with a ",". Category names must match the name of a category exactly to be selected. Category names must be enclosed in quotes. + The selection of which members to display may be overridded by the "category-search" + parameter although these categories will always show in the list of categories that may be + selected in the search filter form. + + + +   + + category-search="{ a single category ID }" + + + The "category-search" attribute is used display only members in a specific category. + The ID for each category is + shown in the Member Categories list. This may be overridden by a "categorySearch" + URL parameter. This parameter does not override the categories that show in the + category selection list of the search filter form set by either "category" or + "category-name" above. + + + +   + + text-search="{ text to search for }" + + + The "text-search" attribute is used to filter results by a specified text + string. If a string is provided, the results will only include members with + this text in their name, description, short description or street address. + This may be overridden by a "testSearch" URL parameter. + + + +   + + amenity-search="{ amenity ID }" + + + The "amenity-search" attribute selects members who have the specified amenity. + The amenity is specified by ID rather than name. This may be overridden by an + "amenitySearch" URL parameter. + + + +   + + alpha="{ initial letter of members }" + + + The "alpha" attribute selects members with names that start with that letter/number + to be listed. This only affects the selection of what is currently displayed, not + the overall results so the full list of all letters for which there are results are + still displayed. This may be overridden by an "alpha" URL parameter. -- 2.17.1