本文整理汇总了PHP中CRM_Mailing_Event_BAO_Queue::free方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Mailing_Event_BAO_Queue::free方法的具体用法?PHP CRM_Mailing_Event_BAO_Queue::free怎么用?PHP CRM_Mailing_Event_BAO_Queue::free使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Mailing_Event_BAO_Queue
的用法示例。
在下文中一共展示了CRM_Mailing_Event_BAO_Queue::free方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deliver
/**
* Send the mailing.
*
* @param object $mailer
* A Mail object to send the messages.
*
* @param array $testParams
*
* @return void
*/
public function deliver(&$mailer, $testParams = NULL)
{
$mailing = new CRM_Mailing_BAO_Mailing();
$mailing->id = $this->mailing_id;
$mailing->find(TRUE);
$mailing->free();
$eq = new CRM_Mailing_Event_BAO_Queue();
$eqTable = CRM_Mailing_Event_BAO_Queue::getTableName();
$emailTable = CRM_Core_BAO_Email::getTableName();
$phoneTable = CRM_Core_DAO_Phone::getTableName();
$contactTable = CRM_Contact_BAO_Contact::getTableName();
$edTable = CRM_Mailing_Event_BAO_Delivered::getTableName();
$ebTable = CRM_Mailing_Event_BAO_Bounce::getTableName();
$query = " SELECT {$eqTable}.id,\n {$emailTable}.email as email,\n {$eqTable}.contact_id,\n {$eqTable}.hash,\n NULL as phone\n FROM {$eqTable}\n INNER JOIN {$emailTable}\n ON {$eqTable}.email_id = {$emailTable}.id\n INNER JOIN {$contactTable}\n ON {$contactTable}.id = {$emailTable}.contact_id\n LEFT JOIN {$edTable}\n ON {$eqTable}.id = {$edTable}.event_queue_id\n LEFT JOIN {$ebTable}\n ON {$eqTable}.id = {$ebTable}.event_queue_id\n WHERE {$eqTable}.job_id = " . $this->id . "\n AND {$edTable}.id IS null\n AND {$ebTable}.id IS null\n AND {$contactTable}.is_opt_out = 0";
if ($mailing->sms_provider_id) {
$query = "\n SELECT {$eqTable}.id,\n {$phoneTable}.phone as phone,\n {$eqTable}.contact_id,\n {$eqTable}.hash,\n NULL as email\n FROM {$eqTable}\n INNER JOIN {$phoneTable}\n ON {$eqTable}.phone_id = {$phoneTable}.id\n INNER JOIN {$contactTable}\n ON {$contactTable}.id = {$phoneTable}.contact_id\n LEFT JOIN {$edTable}\n ON {$eqTable}.id = {$edTable}.event_queue_id\n LEFT JOIN {$ebTable}\n ON {$eqTable}.id = {$ebTable}.event_queue_id\n WHERE {$eqTable}.job_id = " . $this->id . "\n AND {$edTable}.id IS null\n AND {$ebTable}.id IS null\n AND ( {$contactTable}.is_opt_out = 0\n OR {$contactTable}.do_not_sms = 0 )";
}
$eq->query($query);
$config = NULL;
if ($config == NULL) {
$config = CRM_Core_Config::singleton();
}
$job_date = CRM_Utils_Date::isoToMysql($this->scheduled_date);
$fields = array();
if (!empty($testParams)) {
$mailing->subject = ts('[CiviMail Draft]') . ' ' . $mailing->subject;
}
CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
// get and format attachments
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
if (defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY) {
CRM_Core_Smarty::registerStringResource();
}
// CRM-12376
// This handles the edge case scenario where all the mails
// have been delivered in prior jobs
$isDelivered = TRUE;
// make sure that there's no more than $config->mailerBatchLimit mails processed in a run
while ($eq->fetch()) {
// if ( ( $mailsProcessed % 100 ) == 0 ) {
// CRM_Utils_System::xMemory( "$mailsProcessed: " );
// }
if ($config->mailerBatchLimit > 0 && self::$mailsProcessed >= $config->mailerBatchLimit) {
if (!empty($fields)) {
$this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
}
$eq->free();
return FALSE;
}
self::$mailsProcessed++;
$fields[] = array('id' => $eq->id, 'hash' => $eq->hash, 'contact_id' => $eq->contact_id, 'email' => $eq->email, 'phone' => $eq->phone);
if (count($fields) == self::MAX_CONTACTS_TO_PROCESS) {
$isDelivered = $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
if (!$isDelivered) {
$eq->free();
return $isDelivered;
}
$fields = array();
}
}
$eq->free();
if (!empty($fields)) {
$isDelivered = $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
}
return $isDelivered;
}