Adding County list to the category list for drop down.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 23 Jan 2019 20:12:43 +0000 (15:12 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 23 Jan 2019 20:12:43 +0000 (15:12 -0500)
Passing in the county assignment from shortcode. So the search form
filter has the correct counties.

classes/data/dataCategories.php
models/front/members/list.php

index 7fb5074..ad506e1 100644 (file)
@@ -301,12 +301,16 @@ class GlmDataCategories extends GlmDataAbstract
      * @access public
      */
 
-    public function getListSortedParentChild($forEdit = true, $forActiveMembers = false, $regionList = false) {
+    public function getListSortedParentChild($forEdit = true, $forActiveMembers = false, $regionList = false, $countyList = false) {
 
         $regionWhere = '';
         if ($regionList !== false && trim($regionList) != '') {
             $regionWhere = " AND MI.region in ($regionList)";
         }
+        $countyWhere = '';
+        if ( $countyList !== false && trim( $countyList ) != '' ) {
+            $countyWhere = " AND MI.county in ($countyList) ";
+        }
         $where = '';
 
         // If we only want categories for active and visible members - and we want any of their parents (i know it's messy)
@@ -325,6 +329,7 @@ class GlmDataCategories extends GlmDataAbstract
                        AND MI.status = 10
                        AND M.id = MI.member
                        $regionWhere
+                       $countyWhere
                        AND M.access IN (
                         ".$this->config['access_numb']['NoAccess'].",
                         ".$this->config['access_numb']['Moderated'].",
@@ -342,6 +347,7 @@ class GlmDataCategories extends GlmDataAbstract
                   AND MI.status = 10
                   AND M.id = MI.member
                       $regionWhere
+                       $countyWhere
                   AND M.access IN (
                     ".$this->config['access_numb']['NoAccess'].",
                     ".$this->config['access_numb']['Moderated'].",
index 1226597..845f6b6 100755 (executable)
@@ -354,7 +354,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
             }
         }
 
-        $counties = array();
+        $counties   = array();
+        $countyList = '';
         if ($actionData['request']['county-search']) {
 
             // Convert comma separated list to an array
@@ -368,8 +369,9 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
             }
 
             if ( isset( $counties ) && !empty( $counties ) ) {
-                $where .= $whereSep." T.county IN (" . implode( ',', $counties ) . ")";
-                $whereSep = ' AND ';
+                $where     .= $whereSep." T.county IN (" . implode( ',', $counties ) . ")";
+                $whereSep   = ' AND ';
+                $countyList = implode( ',', $counties );
             }
         }
 
@@ -506,7 +508,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
         // Get category data for possible use in search pick list for categories used in active member info records.
         require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php';
         $Categories = new GlmDataCategories($this->wpdb, $this->config);
-        $categoryData = $Categories->getListSortedParentChild(false, true, $categoryRegionList);             // Get only categories that are used in active member data
+        $categoryData = $Categories->getListSortedParentChild(false, true, $categoryRegionList, $countyList);             // Get only categories that are used in active member data
 
         // Get any numeric categories selected in the submitted shortcode and add to $cats array.
         // This sets categories that are available for selection by the user