Fixed alpha selection
authorLaury GvR <laury@gaslightmedia.com>
Mon, 16 Jan 2017 14:18:47 +0000 (09:18 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Mon, 16 Jan 2017 14:18:47 +0000 (09:18 -0500)
Alpha selection wasn't filtering the results. Moved some code
around into the right place.

models/front/contacts/list.php
views/front/contacts/list.html

index 5995b6c..4445b80 100644 (file)
@@ -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,
index 8ce8792..6904503 100644 (file)
@@ -27,6 +27,7 @@ and open the template in the editor.
                 <div id="glmContactsCountySearchContainer" class="small-12 large-5">
                     <b>County Search: </b>
                     <select  id="glmContactsCountySearch" name="countySearch" type="text" value="{$countySearch}">
+                        <option value=""></option>
                         {foreach $countyList as $county}
                             <option value="{$county}">{$county} County</option>
                         {/foreach}
@@ -64,7 +65,7 @@ and open the template in the editor.
         {/if}
         
         {if $haveContacts}
-            {foreach $contactsList as $contact}
+            {foreach $contacts as $contact}
             <div class="glm-member-list-container glm-member-container small-12 columns">
                 <div class="glm-member-list-data small-12 columns">
                     <div class="glm-member-list-active-info small-12 columns">