From: Steve Sutton Date: Wed, 13 Feb 2019 16:55:14 +0000 (-0500) Subject: Updating member list model (again) X-Git-Tag: v2.12.0^2~47 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=d6c1febdf4f023d22b8a0664347c46766370215d;p=WP-Plugins%2Fglm-member-db.git Updating member list model (again) Redoing code that was somehow removed from the merge of the ajaxSearch branch. Also adding one for city drop down so it will check for the county-search in shorcode also. --- diff --git a/classes/data/dataCities.php b/classes/data/dataCities.php index 53d4c183..6ab8057a 100644 --- a/classes/data/dataCities.php +++ b/classes/data/dataCities.php @@ -223,6 +223,13 @@ class GlmDataCities extends GlmDataAbstract WHERE category IN (" . $actionData['request']['category'] .") ) "; } + if ( isset( $actionData['request']['county-search'] ) && $actionData['request']['county-search'] ) { + $where .= " AND MI.id IN ( + SELECT member_info + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "category_member_info + WHERE county IN (" . $actionData['request']['county-search'] .") + ) "; + } } $where .= ") "; diff --git a/models/front/members/list.php b/models/front/members/list.php index 57f01ac7..99370405 100755 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -425,7 +425,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo // Get cities for possible use in search pick list for cities used in active member info records. require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php'; $cities = new GlmDataCities($this->wpdb, $this->config); - $cityData = $cities->getListForSearch(true, $actionData); // Get only categories that are used in active member data + $cityData = $cities->getListForSearch( true, $actionData ); // Get only categories that are used in active member data // If we have a region set in shortcode or via URL. $regions = array(); @@ -447,7 +447,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo } } - $counties = array(); + $counties = array(); + $countyList = ''; // If we have a county set in shortcode or via URL. if ( isset( $actionData['request']['county-search'] ) && $actionData['request']['county-search']) { @@ -465,6 +466,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo if ( isset( $counties ) && !empty( $counties ) ) { $where .= $whereSep." T.county IN (" . implode( ',', $counties ) . ")"; $whereSep = ' AND '; + $countyList = implode( ',', $counties ); } } @@ -595,19 +597,19 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo } } - $typeSelected = implode(',', $types); + $typeSelected = implode( ',', $types ); $typeSelectedForQuery = $typeSelected; // 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 + require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataCategories.php'; + $Categories = new GlmDataCategories( $this->wpdb, $this->config ); + $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 $catSelected = ''; $cats = array(); - if (isset($actionData['request']['category'])) { + if ( isset( $actionData['request']['category'] ) ) { // Convert comma separated list to an array $catsRequested = explode(',', $actionData['request']['category']); @@ -616,7 +618,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo foreach ( $catsRequested as $k => $v ) { // If it's just numeric - note Explode returns an array element with value = 0 if no string. - if (preg_match('/^[0-9]*$/', trim($v)) && $v > 0) { + if ( preg_match( '/^[0-9]*$/', trim( $v ) ) && $v > 0 ) { // Clean up the category number and add to cats array $cats[] = ($v-0); @@ -629,7 +631,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo // Get any text categories selected in the submitted shortcode and add to $cats array // This sets categories that are available for selection by the user. - if (isset($actionData['request']['category-name'])) { + if ( isset($actionData['request']['category-name'] ) ) { // Break up shortcode categories into an array to make searching easy $catsRequested = explode('|', $actionData['request']['category-name']); @@ -637,16 +639,16 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo // Check for numeric or text selection of categories foreach ( $catsRequested as $k => $v ) { - $vStripped = html_entity_decode(stripslashes(trim($v))); + $vStripped = html_entity_decode( stripslashes( trim( $v ) ) ); if ( isset( $categoryData ) && is_array( $categoryData ) ) { - reset($categoryData); + reset( $categoryData ); foreach ($categoryData as $c) { - $x = html_entity_decode(stripslashes(trim($c['name']))); + $x = html_entity_decode( stripslashes( trim( $c['name'] ) ) ); // If this entry matches - apply html entity decode in case string is encoded - if ($x == $vStripped) { + if ( $x == $vStripped ) { // Update the $cats array with the ID rather than the name and mark as found $cats[] = $c['id'];