From ae97282e7eeb90e617cecafb206379d589818306 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Wed, 18 Nov 2015 12:08:19 +0530 Subject: [PATCH] CRM-17534 fix - 'Preferred Communication Methods' don't get saved on Inline Edit https://issues.civicrm.org/jira/browse/CRM-17534 --- CRM/Contact/BAO/Contact.php | 13 ++++--------- .../WebTest/Contact/InlineFieldsEditTest.php | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 03f44cc3bf..0d7d7c8e66 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -157,7 +157,7 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { } // Fix for preferred communication method. - $prefComm = CRM_Utils_Array::value('preferred_communication_method', $params); + $prefComm = CRM_Utils_Array::value('preferred_communication_method', $params, ''); if ($prefComm && is_array($prefComm)) { unset($params['preferred_communication_method']); $newPref = array(); @@ -168,16 +168,11 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { } } - $prefComm = $newPref; - if (is_array($prefComm) && !empty($prefComm)) { - $prefComm = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($prefComm)) . CRM_Core_DAO::VALUE_SEPARATOR; - $contact->preferred_communication_method = $prefComm; - } - else { - $contact->preferred_communication_method = ''; - } + $prefComm = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($newPref)) . CRM_Core_DAO::VALUE_SEPARATOR; } + $contact->preferred_communication_method = $prefComm; + $allNull = $contact->copyValues($params); $contact->id = CRM_Utils_Array::value('contact_id', $params); diff --git a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php index eecb54b77b..746598d3bd 100644 --- a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php +++ b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php @@ -163,7 +163,7 @@ class WebTest_Contact_InlineFieldsEditTest extends CiviSeleniumTestCase { // Edit demographics $this->inlineEdit('crm-demographic-content', array( - 'civicrm_gender_Female_1' => 1, + "xpath=//div[@class='crm-clear']/div[1]/div[@class='crm-content']/label[text()='Female']" => true, 'is_deceased' => 1, 'birth_date' => 'date: Jan 1 1970', ), 'no_open'); -- 2.25.1