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
Tags 4.3.4
No related merge requests found
......@@ -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;
}
......
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