Skip to content
Snippets Groups Projects
Commit f80bd268 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #437 from kurund/updateCMSEmail

worked on CRM-12285, udpate CMS email if primary email of contact is upd...
parents 185b4e21 cac01cdc
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
*/ */
class CRM_Core_BAO_Email extends CRM_Core_DAO_Email { class CRM_Core_BAO_Email extends CRM_Core_DAO_Email {
/* /**
* Create email address - note that the create function calls 'add' but * Create email address - note that the create function calls 'add' but
* has more business logic * has more business logic
* *
...@@ -46,19 +46,12 @@ class CRM_Core_BAO_Email extends CRM_Core_DAO_Email { ...@@ -46,19 +46,12 @@ class CRM_Core_BAO_Email extends CRM_Core_DAO_Email {
*/ */
static function create($params) { static function create($params) {
// if id is set & is_primary isn't we can assume no change // 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 (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) {
if ($alterPrimary) {
CRM_Core_BAO_Block::handlePrimary($params, get_class()); CRM_Core_BAO_Block::handlePrimary($params, get_class());
} }
$email = CRM_Core_BAO_Email::add($params); $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; return $email;
} }
...@@ -98,6 +91,11 @@ WHERE contact_id = {$params['contact_id']} ...@@ -98,6 +91,11 @@ WHERE contact_id = {$params['contact_id']}
$email->save(); $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); CRM_Utils_Hook::post($hook, 'Email', $email->id, $email);
return $email; return $email;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment