From 4b6bf55f6837ae802fb317e7fababcd841c41218 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 14 Apr 2013 20:43:38 -0700 Subject: [PATCH] Fix user email CRM-12285 --- CRM/Core/BAO/Email.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CRM/Core/BAO/Email.php b/CRM/Core/BAO/Email.php index bd99c13940..d2eeeaca4d 100644 --- a/CRM/Core/BAO/Email.php +++ b/CRM/Core/BAO/Email.php @@ -45,14 +45,20 @@ class CRM_Core_BAO_Email extends CRM_Core_DAO_Email { * @param array $params input parameters */ static function create($params) { - if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || - // if id is set & is_primary isn't we can assume no change - empty($params['id']) - ) { + // 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) { 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; } -- 2.25.1