From d39c253d83579cd566c115708ef76a5b8e17dc11 Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Mon, 16 Jan 2017 09:18:47 -0500 Subject: [PATCH] Fixed alpha selection Alpha selection wasn't filtering the results. Moved some code around into the right place. --- models/front/contacts/list.php | 83 +++++++++++++++++----------------- views/front/contacts/list.html | 3 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/models/front/contacts/list.php b/models/front/contacts/list.php index 5995b6c..4445b80 100644 --- a/models/front/contacts/list.php +++ b/models/front/contacts/list.php @@ -279,11 +279,6 @@ class GlmMembersFront_contacts_list extends GlmDataContacts $start = $newStart; } } - - - $contactsList = $this->getList($where, $order, true, 'id',$start, $limit); - - $list = $contactsList['list']; // If we're not paging, then force $start and $limit to false to data abstract returns everything. $resultParam = 'listResult'; @@ -292,38 +287,35 @@ class GlmMembersFront_contacts_list extends GlmDataContacts $limit = false; $resultParam = 'list'; } - - // Get stats for the current selection - $contactsFound = $this->getStats(str_replace('T.', '', $where)); - - // Get stats for number of members found matching current selection criteria (includes alpha selection) - $filteredContactsFound = $this->getStats(str_replace('T.', '', $where.$alphaWhere)); - // Get member list sorted as specified - switch ($this->config['settings']['list_order_list']) { + /* + * Get a current list of members - unless this is a blank start + */ + if (!$blankStart) { - // Pseudo-Random list order - case $this->config['sort_order_numb']['Pseudo-Random']: - ${$resultParam} = $this->getList($where.$alphaWhere, 'pseudo-random', true, 'id', $start, $limit); - break; + // Get stats for the current selection + $contactsFound = $this->getStats(str_replace('T.', '', $where)); - // Default is alpha-numeric list order - default: - case $this->config['sort_order_numb']['Alpha-Numeric']: - ${$resultParam} = $this->getList($where.$alphaWhere, $order, true, 'id', $start, $limit); - break; - - } + // Get stats for number of members found matching current selection criteria (includes alpha selection) + $filteredContactsFound = $this->getStats(str_replace('T.', '', $where.$alphaWhere)); + if (!$paging) { + $start = false; + $limit = false; + $resultParam = 'list'; + } else { + $resultParam = 'listResult'; + } + // Get member list sorted as specified + ${$resultParam} = $this->getList($where.$alphaWhere, 'lname', true, 'id', $start, $limit); - if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { - glmMembersFront::addNotice($list, 'DataBlock', 'Member Data'); } - if ($contactsList != false) { + + if ($paging) { //Get paging results - $numbDisplayed = $contactsList['returned']; - $lastDisplayed = $contactsList['last']; + $numbDisplayed = $listResult['returned']; + $lastDisplayed = $listResult['last']; if ($start == 1) { $prevStart = false; } else { @@ -332,12 +324,29 @@ class GlmMembersFront_contacts_list extends GlmDataContacts $start = 1; } } - if ($contactsList['returned'] == $limit) { + if ($listResult['returned'] == $limit) { $nextStart = $start + $limit; } + if (count($listResult) > 0) { + $haveContacts = true; + } + // since we're doing paging, we have to break out just the contact data + $list = $listResult['list']; + unset($listResult); + } - if (count($contactsList) > 0) { + + + // If we have list entries - even if it's an empty list + $success = true; + $haveContacts = false; + if (!$blankStart && $list !== false) { + + $success = true; + + // If we have any entries + if (count($list) > 0) { $haveContacts = true; } } @@ -348,16 +357,6 @@ class GlmMembersFront_contacts_list extends GlmDataContacts $haveCounties = true; } - // If the option is "edit" don't let lower-level users assign privileges above the user's pay grade - if (($option == 'edit' || $option == 'create') && $this->config['loggedInUser']['contactUser']) { - - // If this is an Entity Manager or lower user, then remove the "MembersManger" role selection - if ($this->config['loggedInUser']['contactUser']['role'] >= $this->config['contact_role_numb']['EntityManager']) { - unset($contactInfo['fieldData']['contact_role']['list'][$this->config['contact_role_numb']['MembersManager']]); - } - - } - // Compile template data $templateData = array( 'option' => $option, @@ -367,7 +366,7 @@ class GlmMembersFront_contacts_list extends GlmDataContacts 'memberName' => $memberName, 'membersList' => $membersList, 'haveContacts' => $haveContacts, - 'contactsList' => $list, + 'contacts' => $list, 'numbContacts' => $numbContacts, 'contactID' => $contactID, 'contactInfo' => $contactInfo, diff --git a/views/front/contacts/list.html b/views/front/contacts/list.html index 8ce8792..6904503 100644 --- a/views/front/contacts/list.html +++ b/views/front/contacts/list.html @@ -27,6 +27,7 @@ and open the template in the editor.
County Search: