From: kurund Date: Mon, 15 Apr 2013 18:21:49 +0000 (+0530) Subject: worked on CRM-12285, udpate CMS email if primary email of contact is updated. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cac01cdc1828cb7864d4e64fac9a4b63bbed2a99;p=civicrm-core.git worked on CRM-12285, udpate CMS email if primary email of contact is updated. ---------------------------------------- * CRM-12285: Editing an email using the 'inscreen' edit option does not update the drupal user email, where the email is used for the uf_match http://issues.civicrm.org/jira/browse/CRM-12285 --- diff --git a/CRM/Core/BAO/Email.php b/CRM/Core/BAO/Email.php index d2eeeaca4d..3643680896 100644 --- a/CRM/Core/BAO/Email.php +++ b/CRM/Core/BAO/Email.php @@ -38,7 +38,7 @@ */ class CRM_Core_BAO_Email extends CRM_Core_DAO_Email { - /* + /** * Create email address - note that the create function calls 'add' but * has more business logic * @@ -46,19 +46,12 @@ class CRM_Core_BAO_Email extends CRM_Core_DAO_Email { */ static function create($params) { // if id is set & is_primary isn't we can assume no change - $alterPrimary = is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id']); - - if ($alterPrimary) { + if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) { CRM_Core_BAO_Block::handlePrimary($params, get_class()); } $email = CRM_Core_BAO_Email::add($params); - if ($alterPrimary) { - // update the UF user email if that has changed - CRM_Core_BAO_UFMatch::updateUFName($email->contact_id); - } - return $email; } @@ -98,6 +91,11 @@ WHERE contact_id = {$params['contact_id']} $email->save(); + if ($email->is_primary) { + // update the UF user email if that has changed + CRM_Core_BAO_UFMatch::updateUFName($email->contact_id); + } + CRM_Utils_Hook::post($hook, 'Email', $email->id, $email); return $email; }