From bf8ba2e46d000c35a4e59c0fb7e929b8191a2b46 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 29 Aug 2016 09:09:25 -0400 Subject: [PATCH] Update the amenity groups If there's no groups assigned to the member short code then don't display them in the form. --- models/front/members/list.php | 157 ++++++++++++++++++---------------- 1 file changed, 83 insertions(+), 74 deletions(-) diff --git a/models/front/members/list.php b/models/front/members/list.php index 55a88c50..4dfad1a3 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -15,52 +15,52 @@ // Translation table for [glm-members-list] "show" options to configuration parameters $GLOBALS['showOpts'] = array( - 'map' => 'list_show_map', - 'map-opened' => 'list_map_show_opened', - 'map-name-link' => 'list_map_show_detaillink', - 'map-logo' => 'list_map_show_logo', - 'map-description' => 'list_map_show_descr', - 'map-short-description' => 'list_map_show_short_descr', - 'map-address' => 'list_map_show_address', - 'map-street' => 'list_map_show_street', - 'map-city-state-zip' => 'list_map_show_citystatezip', - 'map-country' => 'list_map_show_country', - 'map-region' => 'list_map_show_region', - 'map-phone' => 'list_map_show_phone', - 'map-toll-free' => 'list_map_show_tollfree', - 'map-url' => 'list_map_show_url', - 'map-url-new-target' => 'list_map_show_url_newtarget', - 'map-email' => 'list_map_show_email', - 'map-categories' => 'list_map_show_categories', - 'map-credit-cards' => 'list_map_show_creditcards', - 'map-amenities' => 'list_map_show_amenities', - 'search' => 'list_show_search', - 'search-filters-opened' => 'list_show_search_filters_opened', - 'search-text' => 'list_show_search_text', - 'search-categories' => 'list_show_search_category', - 'search-amenities' => 'list_show_search_amenities', - 'search-alpha' => 'list_show_search_alpha', - 'list' => 'list_show_list', - 'name-link' => 'list_show_detail_link', - 'logo' => 'list_show_logo', - 'logo-filler' => 'list_show_logo_filler', - 'address' => 'list_show_address', - 'street' => 'list_show_street', - 'city-state-zip' => 'list_show_citystatezip', - 'country' => 'list_show_country', - 'region' => 'list_show_region', - 'description' => 'list_show_descr', - 'short-description' => 'list_show_short_descr', - 'phone' => 'list_show_phone', - 'toll-free' => 'list_show_tollfree', - 'url' => 'list_show_url', - 'url-new-target' => 'list_show_url_newtarget', - 'email' => 'list_show_email', - 'categories' => 'list_show_categroies', - 'credit-cards' => 'list_show_creditcards', - 'amenities' => 'list_show_amenities', - 'packages' => 'list_show_packages', - 'packages-link' => 'list_show_packages_link' + 'map' => 'list_show_map', + 'map-opened' => 'list_map_show_opened', + 'map-name-link' => 'list_map_show_detaillink', + 'map-logo' => 'list_map_show_logo', + 'map-description' => 'list_map_show_descr', + 'map-short-description' => 'list_map_show_short_descr', + 'map-address' => 'list_map_show_address', + 'map-street' => 'list_map_show_street', + 'map-city-state-zip' => 'list_map_show_citystatezip', + 'map-country' => 'list_map_show_country', + 'map-region' => 'list_map_show_region', + 'map-phone' => 'list_map_show_phone', + 'map-toll-free' => 'list_map_show_tollfree', + 'map-url' => 'list_map_show_url', + 'map-url-new-target' => 'list_map_show_url_newtarget', + 'map-email' => 'list_map_show_email', + 'map-categories' => 'list_map_show_categories', + 'map-credit-cards' => 'list_map_show_creditcards', + 'map-amenities' => 'list_map_show_amenities', + 'search' => 'list_show_search', + 'search-filters-opened' => 'list_show_search_filters_opened', + 'search-text' => 'list_show_search_text', + 'search-categories' => 'list_show_search_category', + 'search-amenities' => 'list_show_search_amenities', + 'search-alpha' => 'list_show_search_alpha', + 'list' => 'list_show_list', + 'name-link' => 'list_show_detail_link', + 'logo' => 'list_show_logo', + 'logo-filler' => 'list_show_logo_filler', + 'address' => 'list_show_address', + 'street' => 'list_show_street', + 'city-state-zip' => 'list_show_citystatezip', + 'country' => 'list_show_country', + 'region' => 'list_show_region', + 'description' => 'list_show_descr', + 'short-description' => 'list_show_short_descr', + 'phone' => 'list_show_phone', + 'toll-free' => 'list_show_tollfree', + 'url' => 'list_show_url', + 'url-new-target' => 'list_show_url_newtarget', + 'email' => 'list_show_email', + 'categories' => 'list_show_categroies', + 'credit-cards' => 'list_show_creditcards', + 'amenities' => 'list_show_amenities', + 'packages' => 'list_show_packages', + 'packages-link' => 'list_show_packages_link' ); // Load Members data abstract @@ -416,20 +416,29 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo // Get amenity filter data $amenityData = false; $amenSelected = ''; - if ( $this->config['settings']['list_show_search_amenities'] ) { + $amenityGroups = false; + if ( isset( $actionData['request']['amenity-groups'] ) + && $actionData['request']['amenity-groups'] + && $actionData['request']['amenity-groups'] != 'amenity-groups' + ) { + $amenityGroups = $actionData['request']['amenity-groups']; + + } + if ( $this->config['settings']['list_show_search_amenities'] && + ( isset( $amenityGroups ) && $amenityGroups ) ) { // Get amenity data for search pick list require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataAmenities.php'; - $Amenities = new GlmDataAmenities($this->wpdb, $this->config); - $amenity_sql = - "T.ref_type = {$this->config['ref_type_numb']['MemberInfo']} + $Amenities = new GlmDataAmenities( $this->wpdb, $this->config ); + $amenity_sql = + "T.ref_type = {$this->config['ref_type_numb']['MemberInfo']} AND T.id IN ( SELECT amenity_id FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "grouped_amenities WHERE searchable <> false"; // check to see if there are groups in shortcode - if ( $actionData['request']['amenity-groups'] ) { - $groups = explode( ',', $actionData['request']['amenity-groups'] ); + if ( $amenityGroups ) { + $groups = explode( ',', $amenityGroups ); $f_groups = array_filter( $groups, 'is_numeric' ); if ( !empty( $f_groups ) ) { $amenity_sql .= " AND group_id IN ( " . implode( ',', $f_groups ) ." ) "; @@ -457,10 +466,10 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo // Build query to get the member ID's that have the selected amenity $where .= $whereSep." T.id in ( - SELECT DISTINCT(ref_dest) - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."amenity_ref - WHERE amenity IN ( " . implode( ',', $amenSelected ) . " ) - AND ref_type = ".$this->config['ref_type_numb']['MemberInfo']." + SELECT DISTINCT(ref_dest) + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."amenity_ref + WHERE amenity IN ( " . implode( ',', $amenSelected ) . " ) + AND ref_type = ".$this->config['ref_type_numb']['MemberInfo']." )"; $whereSep = ' AND '; @@ -563,25 +572,25 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo // Compile template data $templateData = array( - 'haveMembers' => $haveMembers, - 'members' => $list, - 'membersFound' => $membersFound, - 'haveFilter' => $haveFilter, - 'filterArchived' => $filterArchived, - 'filterFeatured' => $filterFeatured, - 'filterPending' => $filterPending, - 'filterName' => stripslashes($filterName), - 'textSearch' => $textSearch, - 'categories' => $categoryData, - 'singleCategory' => $singleCategory, - 'catSelected' => $catSelected, + 'haveMembers' => $haveMembers, + 'members' => $list, + 'membersFound' => $membersFound, + 'haveFilter' => $haveFilter, + 'filterArchived' => $filterArchived, + 'filterFeatured' => $filterFeatured, + 'filterPending' => $filterPending, + 'filterName' => stripslashes($filterName), + 'textSearch' => $textSearch, + 'categories' => $categoryData, + 'singleCategory' => $singleCategory, + 'catSelected' => $catSelected, 'catSearchSelected' => $catSearchSelected, - 'amenities' => $amenityData, - 'amenSelected' => $amenSelected, - 'alphaList' => $alphaList, - 'alphaSelected' => $alphaSelected, - 'blankStart' => $blankStart, - 'view' => $view, + 'amenities' => $amenityData, + 'amenSelected' => $amenSelected, + 'alphaList' => $alphaList, + 'alphaSelected' => $alphaSelected, + 'blankStart' => $blankStart, + 'view' => $view, ); // Return status, suggested view, and data to controller - also return any modified settings -- 2.17.1