* @access public
*/
- public function getListSortedParentChild($forEdit = true, $forActiveMembers = false) {
+ public function getListSortedParentChild($forEdit = true, $forActiveMembers = false, $regionList = false) {
- $where = '';
+ $regionWhere = '';
+ if ($regionList !== false && trim($regionList) != '') {
+ $regionWhere = " AND MI.region in ($regionList)";
+ }
- // If we only want categories for active and visible members
+ // If we only want categories for active and visible members - and we want any of their parents (i know it's messy)
if ($forActiveMembers) {
- $where = "T.id in (
- SELECT DISTINCT(CMI.category)
- FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info CMI,
- ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info MI,
- ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members M
- WHERE MI.id = CMI.member_info
- AND MI.status = ".$this->config['status_numb']['Active']."
- AND M.id = MI.member
- AND M.access IN (
- ".$this->config['access_numb']['NoAccess'].",
- ".$this->config['access_numb']['Moderated'].",
- ".$this->config['access_numb']['Full']."
- )
+ $where = "
+ (
+ T.id in (
+ SELECT DISTINCT(C.parent)
+ from glm_glm_members_categories C
+ WHERE C.id in (
+ SELECT DISTINCT(CMI.category)
+ FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info CMI,
+ ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info MI,
+ ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members M
+ WHERE MI.id = CMI.member_info
+ AND MI.status = 10
+ AND M.id = MI.member
+ $regionWhere
+ AND M.access IN (
+ ".$this->config['access_numb']['NoAccess'].",
+ ".$this->config['access_numb']['Moderated'].",
+ ".$this->config['access_numb']['Full']."
+ )
+ )
+ )
+ OR
+ T.id in (
+ SELECT DISTINCT(CMI.category)
+ FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info CMI,
+ ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info MI,
+ ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members M
+ WHERE MI.id = CMI.member_info
+ AND MI.status = 10
+ AND M.id = MI.member
+ $regionWhere
+ AND M.access IN (
+ ".$this->config['access_numb']['NoAccess'].",
+ ".$this->config['access_numb']['Moderated'].",
+ ".$this->config['access_numb']['Full']."
+ )
+ )
+
)
";
}
- // Get a list of all categories
+ // Get a list of all categories (optionally for active members only)
$categories = $this->getList($where);
$categoriesSorted = $this->sortParentChild($categories);
$blankStart = false;
$membersFound = false;
$catSearchSelected = false;
+ $regionSearchSelected = false;
// Check for URL parameter override of shortcode parameters
if (isset($_REQUEST['categorySearch'])) {
if (isset($_REQUEST['amenitySearch'])) {
$actionData['request']['amenity-search'] = $_REQUEST['amenitySearch'];
}
- if (isset($_REQUEST['regionSearch'])) {
+/* if (isset($_REQUEST['regionSearch'])) {
$actionData['request']['region-search'] = $_REQUEST['regionSearch'];
}
+*/
// Check for "show" shortcode parameter (what elements to show on the page)
$settings = array();
$textSearch = stripslashes($textSearch);
}
- // Get all category data for possible use in search pick list
+ // Get regions for possible use in search pick list for regions used in active member info records.
+ require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataRegions.php';
+ $Regions = new GlmDataRegions($this->wpdb, $this->config);
+ $regionData = $Regions->getListForSearch(true); // Get only categories that are used in active member data
+
+ // If we have a region set in shortcode or via URL.
+ $regions = array();
+ if ($actionData['request']['region-search']) {
+
+ // Convert comma separated list to an array
+ $regionsRequested = explode( ',', $actionData['request']['region-search'] );
+
+ // Check for numeric ID's only
+ while ( list( $k, $v ) = each( $regionsRequested ) ) {
+ if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) {
+ $regions[] = ( $v - 0 );
+ }
+ }
+
+ if ( isset( $regions ) && !empty( $regions ) ) {
+ $where .= $whereSep." T.region IN (" . implode( ',', $regions ) . ")";
+ $whereSep = ' AND ';
+ }
+ }
+
+ // If there's regions shortcode or url options to restrict this page to certain regions
+ if (count($regions) > 0) {
+
+ while ( list($k,$v) = each ($regionData) ) {
+ if (!in_array($v['id'], $regions)) {
+ unset ($regionData[$k]);
+ }
+ }
+
+ }
+
+ // Check for user region selection
+ $categoryRegionList = '';
+ $categoryRegionSep = '';
+ if (isset($_REQUEST) && (isset($_REQUEST['regionUserSearch']) && count($_REQUEST['regionUserSearch']) > 0) || (isset($_REQUEST['regionSearch']) && $_REQUEST['regionSearch'] != "")) {
+ foreach ($regionData as $r) {
+ $id = $r['id'];
+ $regionData[$id]['default'] = false;
+ if ( (isset($_REQUEST['regionUserSearch']) && in_array($id, $_REQUEST['regionUserSearch'])) || (isset($_REQUEST['regionSearch']) && $id == $_REQUEST['regionSearch']) ) {
+ $regionData[$id]['default'] = true;
+ $regionSearchSelected = $id;
+ $where .= $whereSep." T.region = $id";
+ $whereSep = ' AND ';
+ $categoryRegionList .= $categoryRegionSep."$id";
+ $categoryRegionSep = ', ';
+ }
+ }
+ } else {
+ reset($regionData);
+ foreach ($regionData as $r) {
+ $id = $r['id'];
+ $regionData[$id]['default'] = false;
+ if (in_array($id, $regions)) {
+ $categoryRegionList .= $categoryRegionSep."$id";
+ $categoryRegionSep = ', ';
+ }
+ }
+ }
+
+ // 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); // Get only categories that are used in active member data
+ $categoryData = $Categories->getListSortedParentChild(false, true, $categoryRegionList); // 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
}
- // If we have a region
- if ($actionData['request']['region-search']) {
- $regions = array();
- // Convert comma separated list to an array
- $regionsRequested = explode( ',', $actionData['request']['region-search'] );
-
- // Check for numeric ID's only
- while ( list( $k, $v ) = each( $regionsRequested ) ) {
- if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) {
- $regions[] = ( $v - 0 );
- }
- }
-
- if ( isset( $regions ) && !empty( $regions ) ) {
- $where .= $whereSep." T.region IN (" . implode( ',', $regions ) . ")";
- $whereSep = ' AND ';
- }
- }
-
// Get amenity filter data
$amenityData = false;
$amenSelected = '';
} // If we have a sane amenity ID
} // If an amenity search has been selected
- } // it doing amenity search
+ } // if doing amenity search
$amenityData = ( is_array( $amenityData ) ) ? array_filter( $amenityData ) : array();
// Only look at active member information where the member is displayable (access = 20, 30, 40)
'singleCategory' => $singleCategory,
'catSelected' => $catSelected,
'catSearchSelected' => $catSearchSelected,
+ 'regions' => $regionData,
+ 'regionSearchSelected' => $regionSearchSelected,
'amenities' => $amenityData,
'amenSelected' => $amenSelected,
'alphaList' => $alphaList,
</div>
{/if}
{/if}
+ {if $settings.list_show_search_region}
+ {if $regions|@count gt 0}
+ <div>
+ By Regions:
+ <select name="regionUserSearch[]">
+ {if $regions|@count gt 1}
+ <option value"">(all)</option>
+ {/if}
+ {foreach from=$regions item=v}
+ <option value="{$v.id}" {if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ </div>
+ {/if}
+ {/if}
{if $settings.list_show_search_text}
<div>
<div class="glm-member-list-listing-container">
{if $settings.list_show_search_alpha}
<div class="glm-alpha-links">
- <a href="{$thisUrl}?glm_action=list&textSearch={$textSearch}&categorySearch={$catSearchSelected}" class="glm-alpha-link{if !$alphaSelected} glm-alpha-link-selected{/if}">All</a>
+ <a href="{$thisUrl}?glm_action=list&textSearch={$textSearch}&categorySearch={$catSearchSelected}®ionSearch={$regionSearchSelected}" class="glm-alpha-link{if !$alphaSelected} glm-alpha-link-selected{/if}">All</a>
{foreach $alphaList as $a}
- <a href="{$thisUrl}?glm_action=list&alpha={$a.alpha}&textSearch={$textSearch}&categorySearch={$catSearchSelected}" class="glm-alpha-link{if $a.default} glm-alpha-link-selected{/if}">{$a.alpha}</a>
+ <a href="{$thisUrl}?glm_action=list&alpha={$a.alpha}&textSearch={$textSearch}&categorySearch={$catSearchSelected}®ionSearch={$regionSearchSelected}" class="glm-alpha-link{if $a.default} glm-alpha-link-selected{/if}">{$a.alpha}</a>
{/foreach}
</div>
{/if}