本文整理汇总了PHP中CRM_Core_DAO_Email::find方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO_Email::find方法的具体用法?PHP CRM_Core_DAO_Email::find怎么用?PHP CRM_Core_DAO_Email::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_DAO_Email
的用法示例。
在下文中一共展示了CRM_Core_DAO_Email::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Create a new forward event, create a new contact if necessary
*
* @param $job_id
* @param $queue_id
* @param $hash
* @param $forward_email
* @param null $fromEmail
* @param null $comment
*
* @return bool
*/
public static function &forward($job_id, $queue_id, $hash, $forward_email, $fromEmail = NULL, $comment = NULL)
{
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
$successfulForward = FALSE;
$contact_id = NULL;
if (!$q) {
return $successfulForward;
}
/* Find the email address/contact, if it exists */
$contact = CRM_Contact_BAO_Contact::getTableName();
$location = CRM_Core_BAO_Location::getTableName();
$email = CRM_Core_BAO_Email::getTableName();
$queueTable = CRM_Mailing_Event_BAO_Queue::getTableName();
$job = CRM_Mailing_BAO_MailingJob::getTableName();
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
$forward = self::getTableName();
$domain = CRM_Core_BAO_Domain::getDomain();
$dao = new CRM_Core_Dao();
$dao->query("\n SELECT {$contact}.id as contact_id,\n {$email}.id as email_id,\n {$contact}.do_not_email as do_not_email,\n {$queueTable}.id as queue_id\n FROM ({$email}, {$job} as temp_job)\n INNER JOIN {$contact}\n ON {$email}.contact_id = {$contact}.id\n LEFT JOIN {$queueTable}\n ON {$email}.id = {$queueTable}.email_id\n LEFT JOIN {$job}\n ON {$queueTable}.job_id = {$job}.id\n AND temp_job.mailing_id = {$job}.mailing_id\n WHERE {$queueTable}.job_id = {$job_id}\n AND {$email}.email = '" . CRM_Utils_Type::escape($forward_email, 'String') . "'");
$dao->fetch();
$transaction = new CRM_Core_Transaction();
if (isset($dao->queue_id) || isset($dao->do_not_email) && $dao->do_not_email == 1) {
/* We already sent this mailing to $forward_email, or we should
* never email this contact. Give up. */
return $successfulForward;
}
require_once 'api/api.php';
$contactParams = array('email' => $forward_email, 'version' => 3);
$contactValues = civicrm_api('contact', 'get', $contactParams);
$count = $contactValues['count'];
if ($count == 0) {
/* If the contact does not exist, create one. */
$formatted = array('contact_type' => 'Individual', 'version' => 3);
$locationType = CRM_Core_BAO_LocationType::getDefault();
$value = array('email' => $forward_email, 'location_type_id' => $locationType->id);
require_once 'CRM/Utils/DeprecatedUtils.php';
_civicrm_api3_deprecated_add_formatted_param($value, $formatted);
$formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP;
$formatted['fixAddress'] = TRUE;
$contact = civicrm_api('contact', 'create', $formatted);
if (civicrm_error($contact)) {
return $successfulForward;
}
$contact_id = $contact['id'];
}
$email = new CRM_Core_DAO_Email();
$email->email = $forward_email;
$email->find(TRUE);
$email_id = $email->id;
if (!$contact_id) {
$contact_id = $email->contact_id;
}
/* Create a new queue event */
$queue_params = array('email_id' => $email_id, 'contact_id' => $contact_id, 'job_id' => $job_id);
$queue = CRM_Mailing_Event_BAO_Queue::create($queue_params);
$forward = new CRM_Mailing_Event_BAO_Forward();
$forward->time_stamp = date('YmdHis');
$forward->event_queue_id = $queue_id;
$forward->dest_queue_id = $queue->id;
$forward->save();
$dao->reset();
$dao->query(" SELECT {$job}.mailing_id as mailing_id\n FROM {$job}\n WHERE {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer'));
$dao->fetch();
$mailing_obj = new CRM_Mailing_BAO_Mailing();
$mailing_obj->id = $dao->mailing_id;
$mailing_obj->find(TRUE);
$config = CRM_Core_Config::singleton();
$mailer = $config->getMailer();
$recipient = NULL;
$attachments = NULL;
$message = $mailing_obj->compose($job_id, $queue->id, $queue->hash, $queue->contact_id, $forward_email, $recipient, FALSE, NULL, $attachments, TRUE, $fromEmail);
//append comment if added while forwarding.
if (count($comment)) {
$message->_txtbody = CRM_Utils_Array::value('body_text', $comment) . $message->_txtbody;
if (!empty($comment['body_html'])) {
$message->_htmlbody = $comment['body_html'] . '<br />---------------Original message---------------------<br />' . $message->_htmlbody;
}
}
$body = $message->get();
$headers = $message->headers();
$result = NULL;
if (is_object($mailer)) {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$result = $mailer->send($recipient, $headers, $body);
unset($errorScope);
}
$params = array('event_queue_id' => $queue->id, 'job_id' => $job_id, 'hash' => $queue->hash);
if (is_a($result, 'PEAR_Error')) {
//.........这里部分代码省略.........