From: Chuck Scott Date: Mon, 13 Feb 2017 19:03:11 +0000 (-0500) Subject: Fixing problem with primary_contact being cleared for all contacts for all members... X-Git-Tag: v1.0.20^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=2a2da952c0ffe14ed16d8687e3f42008636a020f;p=WP-Plugins%2Fglm-member-db-contacts.git Fixing problem with primary_contact being cleared for all contacts for all members when setting primary_contact true for one member contact. Updated query in entryPostProcessing() to fix this. Updated version to 1.0.20 in index --- diff --git a/classes/data/dataContacts.php b/classes/data/dataContacts.php index fcac99f..83c3703 100644 --- a/classes/data/dataContacts.php +++ b/classes/data/dataContacts.php @@ -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) * diff --git a/index.php b/index.php index e5a88db..993e6aa 100644 --- 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 * @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.