Fixing problem with primary_contact being cleared for all contacts for all members...
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 13 Feb 2017 19:03:11 +0000 (14:03 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 13 Feb 2017 19:03:11 +0000 (14:03 -0500)
Updated query in entryPostProcessing() to fix this.
Updated version to 1.0.20 in index

classes/data/dataContacts.php
index.php

index fcac99f..83c3703 100644 (file)
@@ -471,7 +471,7 @@ class GlmDataContacts extends GlmDataAbstract
         // Only run these tests for insert and update
         if ($this->postProcess && isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') {
             if ($r['primary_contact']) {
-                $this->wpdb->query("UPDATE ".$this->table." SET primary_contact = false where id != ".$r['id'].";");
+                $this->wpdb->query("UPDATE ".$this->table." SET primary_contact = false where primary_contact = true AND ref_type = ".$r['ref_type']['value']." AND ref_dest = ".$r['ref_dest']." AND id != ".$r['id'].";");
             }
 
         }
@@ -479,7 +479,7 @@ class GlmDataContacts extends GlmDataAbstract
         return $r;
     }
 
-    
+
 
     /*
      * Get Alpha list of first characters in member name
@@ -495,7 +495,7 @@ class GlmDataContacts extends GlmDataAbstract
     public function getAlphaList($where = '', $selected = '')
     {
 
-        
+
         $sql = "
            SELECT DISTINCT LEFT(T.lname, 1) AS alpha
              FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX. "contacts T
@@ -503,9 +503,9 @@ class GlmDataContacts extends GlmDataAbstract
                   $where
             ORDER BY alpha
         ;";
-        
+
         $alphaData = $this->wpdb->get_results($sql, ARRAY_A);
-        
+
         // Set selected
         foreach ($alphaData as $k=>$v) {
             $alphaData[$k]['default'] = ($v['alpha'] == $selected);
@@ -514,8 +514,8 @@ class GlmDataContacts extends GlmDataAbstract
         return $alphaData;
 
     }
-    
-    
+
+
     /*
      * Get the contact's "Permissions" (contact_role)
      *
index e5a88db..993e6aa 100644 (file)
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
  * Plugin Name: GLM Members Database Contacts
  * Plugin URI: http://www.gaslightmedia.com/
  * Description: Gaslight Media Members Database.
- * Version: 1.0.19
+ * Version: 1.0.20
  * Author: Gaslight Media
  * Author URI: http://www.gaslightmedia.com/
  * License: GPL2
@@ -19,7 +19,7 @@
  * @package glmMembersDatabaseContacts
  * @author Gaslight Media <cscott@gaslightmedia.com>
  * @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.0.19
+ * @version 1.0.20
  */
 
 /*
@@ -33,7 +33,7 @@
  *  version when there's a change in the database!! Use the
  *  version nunmber of that release for the DB version.
  */
-define('GLM_MEMBERS_CONTACTS_PLUGIN_VERSION', '1.0.19');
+define('GLM_MEMBERS_CONTACTS_PLUGIN_VERSION', '1.0.20');
 define('GLM_MEMBERS_CONTACTS_PLUGIN_DB_VERSION', '0.0.3');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.