From 097c1d42d84517ddaeeb3bdf23a14a3a68ca32a4 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 23 Jan 2019 15:12:43 -0500 Subject: [PATCH] Adding County list to the category list for drop down. Passing in the county assignment from shortcode. So the search form filter has the correct counties. --- classes/data/dataCategories.php | 8 +++++++- models/front/members/list.php | 10 ++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/classes/data/dataCategories.php b/classes/data/dataCategories.php index 7fb5074b..ad506e11 100644 --- a/classes/data/dataCategories.php +++ b/classes/data/dataCategories.php @@ -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'].", diff --git a/models/front/members/list.php b/models/front/members/list.php index 1226597e..845f6b6c 100755 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -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 -- 2.17.1