From: Steve Sutton Date: Wed, 26 Sep 2018 12:22:23 +0000 (-0400) Subject: Fixing many things on the front end search. X-Git-Tag: v1.0.0^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=d18c9fe37a3d217ad53e78a34d7273480ad82c87;p=WP-Plugins%2Fglm-member-db-staff.git Fixing many things on the front end search. Getting rid of sql errors and some unneeded things from the member list model. --- diff --git a/models/front/staff/list.php b/models/front/staff/list.php index ebf6800..f2d805c 100644 --- a/models/front/staff/list.php +++ b/models/front/staff/list.php @@ -105,13 +105,13 @@ class GlmMembersFront_staff_list extends GlmDatastaff public function modelAction($actionData = false) { - $success_load = false; - $success_message = ""; - $option = false; - $view_file = 'list'; - $view = 'list'; - $where = ''; - $whereSep = ''; + $success_load = false; + $success_message = ""; + $option = false; + $view_file = 'list'; + $view = 'list'; + $where = ' true '; + $whereSep = ' AND '; $filterName = false; $haveFilter = false; $textSearch = ''; @@ -172,7 +172,6 @@ class GlmMembersFront_staff_list extends GlmDatastaff T.department LIKE '%$textSearch%' OR T.building LIKE '%$textSearch%' )"; - $whereSep = ' AND '; $textSearch = stripslashes($textSearch); } @@ -185,15 +184,15 @@ class GlmMembersFront_staff_list extends GlmDatastaff if ( isset( $_REQUEST['filter_name'] ) && trim( $_REQUEST['filter_name'] ) != '' ) { $name_search = addslashes(filter_var($_REQUEST['filter_name'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); - $where .= " (T.fname like '%$name_search%' OR T.lname like '%$name_search%' OR (T.fname like '%$name_search%' AND T.lname like '%$name_search%') ) AND "; + $where .= $whereSep." (T.fname like '%$name_search%' OR T.lname like '%$name_search%' OR (T.fname like '%$name_search%' AND T.lname like '%$name_search%') )"; } if ( isset( $_REQUEST['filter_departments'] ) && $filter_departments = filter_var( $_REQUEST['filter_departments'], FILTER_VALIDATE_INT ) ) { - $where .= " T.department = $filter_departments AND "; + $where .= $whereSep." T.department = $filter_departments"; } if ( isset( $_REQUEST['filter_buildings'] ) && $filter_building = filter_var( $_REQUEST['filter_buildings'], FILTER_VALIDATE_INT ) ) { - $where .= " T.building = $filter_building AND "; + $where .= $whereSep." T.building = $filter_building"; } // Check if we're doing paging @@ -213,30 +212,22 @@ class GlmMembersFront_staff_list extends GlmDatastaff } } - $whereParts = apply_filters('glm-member-db-front-search-query', array()); - if ( is_array( $whereParts ) && count( $whereParts ) > 0 ) { - $where .= $whereSep.implode(" AND ", $whereParts); - $whereSep = ' AND '; - } - // If doing alpha list $alphaList = false; $alphaWhere = ''; - if ($this->config['settings']['list_show_search_alpha']) { - $alphaSelected = false; + $alphaSelected = false; - // Check for alpha selected - if ($actionData['request']['alpha'] && strlen($actionData['request']['alpha']) == 1) { - $alphaSelected = strtoupper($actionData['request']['alpha']); - $alphaWhere .= " AND T.lname LIKE '$alphaSelected%'"; + // Check for alpha selected + if ($actionData['request']['alpha'] && strlen($actionData['request']['alpha']) == 1) { + $alphaSelected = strtoupper($actionData['request']['alpha']); + $alphaWhere .= " AND T.lname LIKE '$alphaSelected%'"; - } + } - // Get full list for all other filters, but not filtered by alpha (that would be silly) - $alphaList = $this->getAlphaList($where, $alphaSelected); + // Get full list for all other filters, but not filtered by alpha (that would be silly) + $alphaList = $this->getAlphaList( ' AND ' . $where, $alphaSelected); - } // If we're not paging, then force $start and $limit to false to data abstract returns everything. $resultParam = 'listResult'; @@ -245,7 +236,6 @@ class GlmMembersFront_staff_list extends GlmDatastaff $limit = false; $resultParam = 'list'; } - $where .= ' true '; // Get stats for the current selection $staffFound = $this->getStats(str_replace('T.', '', $where)); diff --git a/views/front/staff/list.html b/views/front/staff/list.html index 93c67d4..cdffff5 100644 --- a/views/front/staff/list.html +++ b/views/front/staff/list.html @@ -6,7 +6,7 @@ - +
@@ -18,7 +18,7 @@ {/foreach} {/if} - +
- +
{if $staffData} @@ -45,8 +45,8 @@ {if $prevStart || $nextStart}
- < Previous page - Next page > + < Previous page + Next page >

{/if} @@ -54,7 +54,7 @@ showing {$start} through {$lastDisplayed} of {$filteredStaffFound} {/if} - + {foreach $staffData as $staffKey => $staffVal}
@@ -72,7 +72,7 @@
- +
Ext: @@ -108,8 +108,8 @@ {if $prevStart || $nextStart}

{/if} @@ -122,4 +122,4 @@ {/if} -
\ No newline at end of file +