Fixing query for counties and ordering by alpha
authorLaury GvR <laury@gaslightmedia.com>
Wed, 18 Jan 2017 14:14:44 +0000 (09:14 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 18 Jan 2017 14:14:44 +0000 (09:14 -0500)
The array for counties was retaining empty values and using them
as options on the contact list county dropdown. The query for
counties has been changed to order the result alphabetically.

models/front/contacts/list.php

index 0d563e0..063a42d 100644 (file)
@@ -108,22 +108,17 @@ class GlmMembersFront_contacts_list extends GlmDataContacts
         $memberData     = false;
         $memberName     = false;
         $membersList    = false;
-        $contactsList   = false;
-        $haveContacts   = false;
         $contactID      = false;
         $contactInfo    = false;
         $filterArchived = false;
         $filterText     = false;
         $countySearch   = false;
-        $countyList     = array();
         $haveCounties  = false;
         $haveFilter     = false;
         $contactMembers = array();
-        $order          = false;
         
         $textSearch     = '';
         $blankStart     = false;
-        $membersFound   = false;
 
         // Paging Parameters
         $paging = true;
@@ -133,18 +128,8 @@ class GlmMembersFront_contacts_list extends GlmDataContacts
         $nextStart = false;
         $start = 1;
         $limit = 20;        // Set to the number of listings per page
-        $namesList = false;
 
         $where = '';
-
-        $validOptions = array(
-            'create',
-            'addNew',
-            'edit',
-            'submit',
-            'delete',
-            'list'
-        );
         
         
         if (isset($_REQUEST['textSearch'])) {
@@ -193,9 +178,6 @@ class GlmMembersFront_contacts_list extends GlmDataContacts
             $memberName = $memberData['name'];
         }
 
-        // Make sure option is set to list
-        $option = 'list';
-
         $where = ' TRUE ';
         
         // Only list member contacts for the selected member
@@ -240,8 +222,6 @@ class GlmMembersFront_contacts_list extends GlmDataContacts
         // Get full list of names matching this where clause for search box
         $namesList = $this->getIdName($where);
 
-
-        
         // If doing alpha list
         $alphaList = false;
         $alphaWhere = '';
@@ -352,8 +332,9 @@ class GlmMembersFront_contacts_list extends GlmDataContacts
         }
 
         // Get a list of counties
-        $countyList = $this->wpdb->get_col("SELECT DISTINCT county FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts WHERE active = true ORDER BY county ASC;");
-        if ($countyList[0]) {
+        $countyList = array_filter($this->wpdb->get_col("SELECT DISTINCT county FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts WHERE active = true ORDER BY county ASC;"));
+
+        if ($countyList) {
             $haveCounties = true;
         }