Fixed serious problems with member searching related to mixing URL and shortcode...
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 26 Jul 2016 15:07:09 +0000 (11:07 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 26 Jul 2016 15:07:09 +0000 (11:07 -0400)
index.php
models/front/members/list.php
setup/shortcodes.php

index dba8cae..37240eb 100644 (file)
--- 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 <cscott@gaslightmedia.com>
  * @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
index 17c116f..e161fc3 100644 (file)
@@ -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%'";
             }
 
index 681747e..a48ff40 100644 (file)
@@ -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) }"
         </th>
         <td>
-            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.
         </td>
     </tr>
     <tr>
@@ -195,10 +203,63 @@ $glmMembersShortcodesDescription = '
             category-name="{ category name(s) }"
         </th>
         <td>
-            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.
+        </td>
+    </tr>
+    <tr>
+        <td>&nbsp;</td>
+        <th>
+            category-search="{ a single category ID }"
+        </th>
+        <td>
+            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.
+        </td>
+    </tr>
+    <tr>
+        <td>&nbsp;</td>
+        <th>
+            text-search="{ text to search for }"
+        </th>
+        <td>
+            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.
+        </td>
+    </tr>
+    <tr>
+        <td>&nbsp;</td>
+        <th>
+            amenity-search="{ amenity ID }"
+        </th>
+        <td>
+            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.
+        </td>
+    </tr>
+    <tr>
+        <td>&nbsp;</td>
+        <th>
+            alpha="{ initial letter of members }"
+        </th>
+        <td>
+            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.
         </td>
     </tr>
     <tr>