本文整理汇总了PHP中CRM_Core_DAO_Email::save方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO_Email::save方法的具体用法?PHP CRM_Core_DAO_Email::save怎么用?PHP CRM_Core_DAO_Email::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_DAO_Email
的用法示例。
在下文中一共展示了CRM_Core_DAO_Email::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateContactEmail
/**
* Update the email value for the contact and user profile.
*
* @param int $contactId
* Contact ID of the user.
* @param string $emailAddress
* Email to be modified for the user.
*/
public static function updateContactEmail($contactId, $emailAddress)
{
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
$emailAddress = $strtolower($emailAddress);
$ufmatch = new CRM_Core_DAO_UFMatch();
$ufmatch->contact_id = $contactId;
$ufmatch->domain_id = CRM_Core_Config::domainID();
if ($ufmatch->find(TRUE)) {
// Save the email in UF Match table
$ufmatch->uf_name = $emailAddress;
CRM_Core_BAO_UFMatch::create((array) $ufmatch);
//check if the primary email for the contact exists
//$contactDetails[1] - email
//$contactDetails[3] - email id
$contactDetails = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactId);
if (trim($contactDetails[1])) {
$emailID = $contactDetails[3];
//update if record is found
$query = "UPDATE civicrm_email\n SET email = %1\n WHERE id = %2";
$p = array(1 => array($emailAddress, 'String'), 2 => array($emailID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $p);
} else {
//else insert a new email record
$email = new CRM_Core_DAO_Email();
$email->contact_id = $contactId;
$email->is_primary = 1;
$email->email = $emailAddress;
$email->save();
$emailID = $email->id;
}
CRM_Core_BAO_Log::register($contactId, 'civicrm_email', $emailID);
}
}