本文整理汇总了PHP中CRM_Mailing_Event_BAO_Queue类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Mailing_Event_BAO_Queue类的具体用法?PHP CRM_Mailing_Event_BAO_Queue怎么用?PHP CRM_Mailing_Event_BAO_Queue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Mailing_Event_BAO_Queue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
public function preProcess()
{
$this->_type = 'unsubscribe';
$this->_job_id = $job_id = CRM_Utils_Request::retrieve('jid', 'Integer', $this);
$this->_queue_id = $queue_id = CRM_Utils_Request::retrieve('qid', 'Integer', $this);
$this->_hash = $hash = CRM_Utils_Request::retrieve('h', 'String', $this);
if (!$job_id || !$queue_id || !$hash) {
CRM_Core_Error::fatal(ts("Missing Parameters"));
}
// verify that the three numbers above match
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
if (!$q) {
CRM_Core_Error::fatal(ts("There was an error in your request"));
}
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
$this->assign('display_name', $displayName);
$emailMasked = CRM_Utils_String::maskEmail($email);
$this->assign('email_masked', $emailMasked);
$this->assign('email', $email);
$this->_email = $email;
$groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash, TRUE);
$this->assign('groups', $groups);
$groupExist = NULL;
foreach ($groups as $key => $value) {
if ($value) {
$groupExist = TRUE;
}
}
if (!$groupExist) {
$statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.', array(1 => $email));
CRM_Core_Session::setStatus($statusMsg, '', 'fail');
}
$this->assign('groupExist', $groupExist);
}
示例2: preProcess
function preProcess()
{
$job_id = CRM_Utils_Request::retrieve('jid', $this, null);
$queue_id = CRM_Utils_Request::retrieve('qid', $this, null);
$hash = CRM_Utils_Request::retrieve('h', $this, null);
$q =& CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
if ($q == null) {
/** ERROR **/
CRM_Utils_System::statusBounce(ts('Invalid form parameters.'));
}
$mailing =& $q->getMailing();
/* Show the subject instead of the name here, since it's being
* displayed to external contacts/users */
CRM_Utils_System::setTitle(ts('Forward Mailing: %1', array(1 => $mailing->subject)));
$this->set('queue_id', $queue_id);
$this->set('job_id', $job_id);
$this->set('hash', $hash);
}
示例3: recordBounce
static function recordBounce($params)
{
$isSpam = CRM_Utils_Array::value('is_spam', $params);
$mailingId = CRM_Utils_Array::value('mailing_id', $params);
//CiviCRM mailling ID
$contactId = CRM_Utils_Array::value('contact_id', $params);
$emailId = CRM_Utils_Array::value('email_id', $params);
$email = CRM_Utils_Array::value('email', $params);
$jobId = CRM_Utils_Array::value('job_id', $params);
$eqParams = array('job_id' => $jobId, 'contact_id' => $contactId, 'email_id' => $emailId);
$eventQueue = CRM_Mailing_Event_BAO_Queue::create($eqParams);
$time = date('YmdHis', CRM_Utils_Array::value('date_ts', $params));
$bounceType = array();
CRM_Core_PseudoConstant::populate($bounceType, 'CRM_Mailing_DAO_BounceType', TRUE, 'id', NULL, NULL, NULL, 'name');
$bounce = new CRM_Mailing_Event_BAO_Bounce();
$bounce->time_stamp = $time;
$bounce->event_queue_id = $eventQueue->id;
if ($isSpam) {
$bounce->bounce_type_id = $bounceType[CRM_Mailjet_Upgrader::SPAM];
$bounce->bounce_reason = CRM_Utils_Array::value('source', $params);
//bounce reason when spam occured
} else {
$hardBounce = CRM_Utils_Array::value('hard_bounce', $params);
$blocked = CRM_Utils_Array::value('blocked', $params);
// blocked : true if this bounce leads to recipient being blocked
if ($hardBounce && $blocked) {
$bounce->bounce_type_id = $bounceType[CRM_Mailjet_Upgrader::BLOCKED];
} elseif ($hardBounce && !$blocked) {
$bounce->bounce_type_id = $bounceType[CRM_Mailjet_Upgrader::HARD_BOUNCE];
} else {
$bounce->bounce_type_id = $bounceType[CRM_Mailjet_Upgrader::SOFT_BOUNCE];
}
$bounce->bounce_reason = $params['error_related_to'] . " - " . $params['error'];
}
$bounce->save();
if ($bounce->bounce_type_id != $bounceType[CRM_Mailjet_Upgrader::SOFT_BOUNCE]) {
$params = array('id' => $contactId, 'do_not_email' => 1);
civicrm_api3('Contact', 'create', $params);
}
return TRUE;
}
示例4: preProcess
public function preProcess()
{
$this->_type = 'optout';
$this->_job_id = $job_id = CRM_Utils_Request::retrieve('jid', 'Integer', $this);
$this->_queue_id = $queue_id = CRM_Utils_Request::retrieve('qid', 'Integer', $this);
$this->_hash = $hash = CRM_Utils_Request::retrieve('h', 'String', $this);
if (!$job_id || !$queue_id || !$hash) {
CRM_Core_Error::fatal(ts("Missing input parameters"));
}
// verify that the three numbers above match
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
if (!$q) {
CRM_Core_Error::fatal(ts("There was an error in your request"));
}
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
$this->assign('display_name', $displayName);
$emailMasked = CRM_Utils_String::maskEmail($email);
$this->assign('email_masked', $emailMasked);
$this->assign('email', $email);
$this->_email = $email;
}
示例5: preProcess
public function preProcess()
{
$job_id = CRM_Utils_Request::retrieve('jid', 'Positive', $this, NULL);
$queue_id = CRM_Utils_Request::retrieve('qid', 'Positive', $this, NULL);
$hash = CRM_Utils_Request::retrieve('h', 'String', $this, NULL);
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
if ($q == NULL) {
// ERROR.
CRM_Core_Error::fatal(ts('Invalid form parameters.'));
CRM_Core_Error::statusBounce(ts('Invalid form parameters.'));
}
$mailing =& $q->getMailing();
if ($hash) {
$emailId = CRM_Core_DAO::getfieldValue('CRM_Mailing_Event_DAO_Queue', $hash, 'email_id', 'hash');
$this->_fromEmail = $fromEmail = CRM_Core_DAO::getfieldValue('CRM_Core_DAO_Email', $emailId, 'email');
$this->assign('fromEmail', $fromEmail);
}
// Show the subject instead of the name here, since it's being
// displayed to external contacts/users.
CRM_Utils_System::setTitle(ts('Forward Mailing: %1', array(1 => $mailing->subject)));
$this->set('queue_id', $queue_id);
$this->set('job_id', $job_id);
$this->set('hash', $hash);
}
示例6: CRM_Mailing_BAO_Mailing
/**
* Get the mailing object for this queue event instance
*
* @param
* @return object Mailing BAO
* @access public
*/
function &getMailing()
{
$mailing =& new CRM_Mailing_BAO_Mailing();
$jobs = CRM_Mailing_BAO_Job::getTableName();
$mailings = CRM_Mailing_BAO_Mailing::getTableName();
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
$mailing->query("\n SELECT {$mailings}.*\n FROM {$mailings}\n INNER JOIN {$jobs}\n ON {$jobs}.mailing_id = {$mailings}.id\n INNER JOIN {$queue}\n ON {$queue}.job_id = {$jobs}.id\n WHERE {$queue}.id = {$this->id}");
$mailing->fetch();
return $mailing;
}
示例7: 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;
}
示例8: CRM_Core_Dao
/**
* Get rows for the event browser
*
* @param int $mailing_id ID of the mailing
* @param int $job_id optional ID of the job
* @param boolean $is_distinct Group by queue id?
* @param int $offset Offset
* @param int $rowCount Number of rows
* @param array $sort sort array
* @return array Result set
* @access public
* @static
*/
function &getRows($mailing_id, $job_id = null, $is_distinct = false, $offset = null, $rowCount = null, $sort = null)
{
$dao =& new CRM_Core_Dao();
$bounce = CRM_Mailing_Event_BAO_Bounce::getTableName();
$bounceType = CRM_Mailing_DAO_BounceType::getTableName();
$queue = CRM_Mailing_Event_BAO_Queue::getTableName();
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
$job = CRM_Mailing_BAO_Job::getTableName();
$contact = CRM_Contact_BAO_Contact::getTableName();
$email = CRM_Core_BAO_Email::getTableName();
$query = "\n SELECT {$contact}.display_name as display_name,\n {$contact}.id as contact_id,\n {$email}.email as email,\n {$bounce}.time_stamp as date,\n {$bounce}.bounce_reason as reason,\n {$bounceType}.name as bounce_type\n FROM {$contact}\n INNER JOIN {$queue}\n ON {$queue}.contact_id = {$contact}.id\n INNER JOIN {$email}\n ON {$queue}.email_id = {$email}.id\n INNER JOIN {$bounce}\n ON {$bounce}.event_queue_id = {$queue}.id\n LEFT JOIN {$bounceType}\n ON {$bounce}.bounce_type_id = {$bounceType}.id\n INNER JOIN {$job}\n ON {$queue}.job_id = {$job}.id\n INNER JOIN {$mailing}\n ON {$job}.mailing_id = {$mailing}.id\n WHERE {$mailing}.id = " . CRM_Utils_Type::escape($mailing_id, 'Integer');
if (!empty($job_id)) {
$query .= " AND {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer');
}
if ($is_distinct) {
$query .= " GROUP BY {$queue}.id ";
}
$query .= " ORDER BY {$contact}.sort_name, {$bounce}.time_stamp ";
if ($offset) {
$query .= ' LIMIT ' . CRM_Utils_Type::escape($offset, 'Integer') . ', ' . CRM_Utils_Type::escape($rowCount, 'Integer');
}
$dao->query($query);
$results = array();
while ($dao->fetch()) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}");
$results[] = array('name' => "<a href=\"{$url}\">{$dao->display_name}</a>", 'email' => $dao->email, 'type' => empty($dao->bounce_type) ? ts('Unknown') : $dao->bounce_type, 'reason' => $dao->reason, 'date' => CRM_Utils_Date::customFormat($dao->date));
}
return $results;
}
示例9: switch
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
switch ($this->_event_type) {
case 'queue':
return CRM_Mailing_Event_BAO_Queue::getRows($this->_mailing_id, $this->_job_id, $offset, $rowCount, $sort);
break;
case 'delivered':
return CRM_Mailing_Event_BAO_Delivered::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort);
break;
case 'opened':
return CRM_Mailing_Event_BAO_Opened::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort);
break;
case 'bounce':
return CRM_Mailing_Event_BAO_Bounce::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort);
break;
case 'forward':
return CRM_Mailing_Event_BAO_Forward::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort);
case 'reply':
return CRM_Mailing_Event_BAO_Reply::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort);
break;
case 'unsubscribe':
return CRM_Mailing_Event_BAO_Unsubscribe::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort, TRUE);
break;
case 'optout':
return CRM_Mailing_Event_BAO_Unsubscribe::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $offset, $rowCount, $sort, FALSE);
break;
case 'click':
return CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($this->_mailing_id, $this->_job_id, $this->_is_distinct, $this->_url_id, $offset, $rowCount, $sort);
break;
default:
return NULL;
}
}
示例10: deliver
/**
* Send the mailing
*
* @param object $mailer A Mail object to send the messages
* @return void
* @access public
*/
public function deliver(&$mailer, $testParams = null)
{
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing =& new CRM_Mailing_BAO_Mailing();
$mailing->id = $this->mailing_id;
$mailing->find(true);
$eq =& new CRM_Mailing_Event_BAO_Queue();
$eqTable = CRM_Mailing_Event_BAO_Queue::getTableName();
$emailTable = CRM_Core_BAO_Email::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 FROM {$eqTable}\n INNER JOIN {$emailTable}\n ON {$eqTable}.email_id = {$emailTable}.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";
$eq->query($query);
static $config = null;
$mailsProcessed = 0;
if ($config == null) {
$config =& CRM_Core_Config::singleton();
}
$job_date = CRM_Utils_Date::isoToMysql($this->scheduled_date);
$fields = array();
if (!empty($testParams)) {
$mailing->from_name = ts('CiviCRM Test Mailer (%1)', array(1 => $mailing->from_name));
$mailing->subject = ts('Test Mailing:') . ' ' . $mailing->subject;
}
CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
// get and format attachments
require_once 'CRM/Core/BAO/File.php';
$attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
if (defined('CIVICRM_MAIL_SMARTY')) {
require_once 'CRM/Core/Smarty/resources/String.php';
civicrm_smarty_register_string_resource();
}
// 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 && $mailsProcessed >= $config->mailerBatchLimit) {
$this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
return false;
}
$mailsProcessed++;
$fields[] = array('id' => $eq->id, 'hash' => $eq->hash, 'contact_id' => $eq->contact_id, 'email' => $eq->email);
if (count($fields) == self::MAX_CONTACTS_TO_PROCESS) {
$isDelivered = $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
if (!$isDelivered) {
return $isDelivered;
}
$fields = array();
}
}
$isDelivered = $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
return $isDelivered;
}
示例11: CRM_Mailing_BAO_Mailing
/**
* Generate a report. Fetch event count information, mailing data, and job
* status.
*
* @param int $id The mailing id to report
* @param boolean $skipDetails whether return all detailed report
* @return array Associative array of reporting data
* @access public
* @static
*/
public static function &report($id, $skipDetails = false)
{
$mailing_id = CRM_Utils_Type::escape($id, 'Integer');
$mailing = new CRM_Mailing_BAO_Mailing();
require_once 'CRM/Mailing/Event/BAO/Opened.php';
require_once 'CRM/Mailing/Event/BAO/Reply.php';
require_once 'CRM/Mailing/Event/BAO/Unsubscribe.php';
require_once 'CRM/Mailing/Event/BAO/Forward.php';
require_once 'CRM/Mailing/Event/BAO/TrackableURLOpen.php';
require_once 'CRM/Mailing/BAO/Spool.php';
$t = array('mailing' => self::getTableName(), 'mailing_group' => CRM_Mailing_DAO_Group::getTableName(), 'group' => CRM_Contact_BAO_Group::getTableName(), 'job' => CRM_Mailing_BAO_Job::getTableName(), 'queue' => CRM_Mailing_Event_BAO_Queue::getTableName(), 'delivered' => CRM_Mailing_Event_BAO_Delivered::getTableName(), 'opened' => CRM_Mailing_Event_BAO_Opened::getTableName(), 'reply' => CRM_Mailing_Event_BAO_Reply::getTableName(), 'unsubscribe' => CRM_Mailing_Event_BAO_Unsubscribe::getTableName(), 'bounce' => CRM_Mailing_Event_BAO_Bounce::getTableName(), 'forward' => CRM_Mailing_Event_BAO_Forward::getTableName(), 'url' => CRM_Mailing_BAO_TrackableURL::getTableName(), 'urlopen' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTableName(), 'component' => CRM_Mailing_BAO_Component::getTableName(), 'spool' => CRM_Mailing_BAO_Spool::getTableName());
$report = array();
/* Get the mailing info */
$mailing->query("\n SELECT {$t['mailing']}.*\n FROM {$t['mailing']}\n WHERE {$t['mailing']}.id = {$mailing_id}");
$mailing->fetch();
$report['mailing'] = array();
foreach (array_keys(self::fields()) as $field) {
$report['mailing'][$field] = $mailing->{$field};
}
//mailing report is called by activity
//we dont need all detail report
if ($skipDetails) {
return $report;
}
/* Get the component info */
$query = array();
$components = array('header' => ts('Header'), 'footer' => ts('Footer'), 'reply' => ts('Reply'), 'unsubscribe' => ts('Unsubscribe'), 'optout' => ts('Opt-Out'));
foreach (array_keys($components) as $type) {
$query[] = "SELECT {$t['component']}.name as name,\n '{$type}' as type,\n {$t['component']}.id as id\n FROM {$t['component']}\n INNER JOIN {$t['mailing']}\n ON {$t['mailing']}.{$type}_id =\n {$t['component']}.id\n WHERE {$t['mailing']}.id = {$mailing_id}";
}
$q = '(' . implode(') UNION (', $query) . ')';
$mailing->query($q);
$report['component'] = array();
while ($mailing->fetch()) {
$report['component'][] = array('type' => $components[$mailing->type], 'name' => $mailing->name, 'link' => CRM_Utils_System::url('civicrm/mailing/component', "reset=1&action=update&id={$mailing->id}"));
}
/* Get the recipient group info */
$mailing->query("\n SELECT {$t['mailing_group']}.group_type as group_type,\n {$t['group']}.id as group_id,\n {$t['group']}.title as group_title,\n {$t['mailing']}.id as mailing_id,\n {$t['mailing']}.name as mailing_name\n FROM {$t['mailing_group']}\n LEFT JOIN {$t['group']}\n ON {$t['mailing_group']}.entity_id = {$t['group']}.id\n AND {$t['mailing_group']}.entity_table =\n '{$t['group']}'\n LEFT JOIN {$t['mailing']}\n ON {$t['mailing_group']}.entity_id =\n {$t['mailing']}.id\n AND {$t['mailing_group']}.entity_table =\n '{$t['mailing']}'\n\n WHERE {$t['mailing_group']}.mailing_id = {$mailing_id}\n ");
$report['group'] = array('include' => array(), 'exclude' => array());
while ($mailing->fetch()) {
$row = array();
if (isset($mailing->group_id)) {
$row['id'] = $mailing->group_id;
$row['name'] = $mailing->group_title;
$row['link'] = CRM_Utils_System::url('civicrm/group/search', "reset=1&force=1&context=smog&gid={$row['id']}");
} else {
$row['id'] = $mailing->mailing_id;
$row['name'] = $mailing->mailing_name;
$row['mailing'] = true;
$row['link'] = CRM_Utils_System::url('civicrm/mailing/report', "mid={$row['id']}");
}
if ($mailing->group_type == 'Include') {
$report['group']['include'][] = $row;
} else {
$report['group']['exclude'][] = $row;
}
}
/* Get the event totals, grouped by job (retries) */
$mailing->query("\n SELECT {$t['job']}.*,\n COUNT(DISTINCT {$t['queue']}.id) as queue,\n COUNT(DISTINCT {$t['delivered']}.id) as delivered,\n COUNT(DISTINCT {$t['reply']}.id) as reply,\n COUNT(DISTINCT {$t['forward']}.id) as forward,\n COUNT(DISTINCT {$t['bounce']}.id) as bounce,\n COUNT(DISTINCT {$t['urlopen']}.id) as url,\n COUNT(DISTINCT {$t['spool']}.id) as spool\n FROM {$t['job']}\n LEFT JOIN {$t['queue']}\n ON {$t['queue']}.job_id = {$t['job']}.id\n LEFT JOIN {$t['reply']}\n ON {$t['reply']}.event_queue_id = {$t['queue']}.id\n LEFT JOIN {$t['forward']}\n ON {$t['forward']}.event_queue_id = {$t['queue']}.id\n LEFT JOIN {$t['bounce']}\n ON {$t['bounce']}.event_queue_id = {$t['queue']}.id\n LEFT JOIN {$t['delivered']}\n ON {$t['delivered']}.event_queue_id = {$t['queue']}.id\n AND {$t['bounce']}.id IS null\n LEFT JOIN {$t['urlopen']}\n ON {$t['urlopen']}.event_queue_id = {$t['queue']}.id\n LEFT JOIN {$t['spool']}\n ON {$t['spool']}.job_id = {$t['job']}.id\n WHERE {$t['job']}.mailing_id = {$mailing_id}\n AND {$t['job']}.is_test = 0\n GROUP BY {$t['job']}.id");
$report['jobs'] = array();
$report['event_totals'] = array();
$elements = array('queue', 'delivered', 'url', 'forward', 'reply', 'unsubscribe', 'opened', 'bounce', 'spool');
// initialize various counters
foreach ($elements as $field) {
$report['event_totals'][$field] = 0;
}
while ($mailing->fetch()) {
$row = array();
foreach ($elements as $field) {
if (isset($mailing->{$field})) {
$row[$field] = $mailing->{$field};
$report['event_totals'][$field] += $mailing->{$field};
}
}
// compute open total separately to discount duplicates
// CRM-1258
$row['opened'] = CRM_Mailing_Event_BAO_Opened::getTotalCount($mailing_id, $mailing->id, true);
$report['event_totals']['opened'] += $row['opened'];
// compute unsub total separately to discount duplicates
// CRM-1783
$row['unsubscribe'] = CRM_Mailing_Event_BAO_Unsubscribe::getTotalCount($mailing_id, $mailing->id, true);
$report['event_totals']['unsubscribe'] += $row['unsubscribe'];
foreach (array_keys(CRM_Mailing_BAO_Job::fields()) as $field) {
$row[$field] = $mailing->{$field};
}
if ($mailing->queue) {
$row['delivered_rate'] = 100.0 * $mailing->delivered / $mailing->queue;
$row['bounce_rate'] = 100.0 * $mailing->bounce / $mailing->queue;
$row['unsubscribe_rate'] = 100.0 * $row['unsubscribe'] / $mailing->queue;
} else {
//.........这里部分代码省略.........
示例12: deleteLocation
/**
* Delete email address records from a location
*
* @param int $locationId Location ID to delete for
*
* @return void
*
* @access public
* @static
*/
function deleteLocation($locationId)
{
$dao =& new CRM_Core_DAO_Email();
$dao->location_id = $locationId;
$dao->find();
require_once 'CRM/Mailing/Event/BAO/Queue.php';
while ($dao->fetch()) {
CRM_Mailing_Event_BAO_Queue::deleteEmail($dao->id);
}
$dao->reset();
$dao->location_id = $locationId;
$dao->delete();
}
示例13: elseif
//.........这里部分代码省略.........
$emails .= $emails ? ",'{$email}'" : "'{$email}'";
if (!CRM_Utils_Rule::email($email)) {
CRM_Core_Session::setStatus(ts('Please enter valid email addresses only.'));
$error = TRUE;
}
}
}
if ($error) {
$url = CRM_Utils_System::url($urlString, $urlParams);
CRM_Utils_System::redirect($url);
return $error;
}
}
if (CRM_Utils_Array::value('_qf_Test_submit', $testParams)) {
//when user perform mailing from search context
//redirect it to search result CRM-3711.
if ($ssID && $self->_searchBasedMailing) {
$draftURL = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
$status = ts("Your mailing has been saved. You can continue later by clicking the 'Continue' action to resume working on it.<br /> From <a href='%1'>Draft and Unscheduled Mailings</a>.", array(1 => $draftURL));
CRM_Core_Session::setStatus($status);
//replace user context to search.
$context = $self->get('context');
if (!CRM_Contact_Form_Search::isSearchContext($context)) {
$context = 'search';
}
$urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}&qfKey={$testParams['qfKey']}";
$url = CRM_Utils_System::url($urlString, $urlParams);
CRM_Utils_System::redirect($url);
} else {
$status = ts("Your mailing has been saved. Click the 'Continue' action to resume working on it.");
CRM_Core_Session::setStatus($status);
$url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
CRM_Utils_System::redirect($url);
}
}
if (CRM_Mailing_Info::workflowEnabled()) {
if (!CRM_Core_Permission::check('schedule mailings') && CRM_Core_Permission::check('create mailings')) {
$url = CRM_Utils_System::url('civicrm/mailing/browse/unscheduled', 'scheduled=false&reset=1');
CRM_Utils_System::redirect($url);
}
}
if (CRM_Utils_Array::value('_qf_Import_refresh', $_POST) || CRM_Utils_Array::value('_qf_Test_next', $testParams) || !CRM_Utils_Array::value('sendtest', $testParams)) {
$error = TRUE;
return $error;
}
$job = new CRM_Mailing_BAO_Job();
$job->mailing_id = $self->get('mailing_id');
$job->is_test = TRUE;
$job->save();
$newEmails = NULL;
$session = CRM_Core_Session::singleton();
if (!empty($testParams['emails'])) {
$query = "\n SELECT id, contact_id, email \n FROM civicrm_email \n WHERE civicrm_email.email IN ({$emails})";
$dao = CRM_Core_DAO::executeQuery($query);
$emailDetail = array();
// fetch contact_id and email id for all existing emails
while ($dao->fetch()) {
$emailDetail[$dao->email] = array('contact_id' => $dao->contact_id, 'email_id' => $dao->id);
}
$dao->free();
foreach ($testParams['emails'] as $key => $email) {
$email = trim($email);
$contactId = $emailId = NULL;
if (array_key_exists($email, $emailDetail)) {
$emailId = $emailDetail[$email]['email_id'];
$contactId = $emailDetail[$email]['contact_id'];
}
if (!$contactId) {
//create new contact.
$params = array('contact_type' => 'Individual', 'email' => array(1 => array('email' => $email, 'is_primary' => 1, 'location_type_id' => 1)));
$contact = CRM_Contact_BAO_Contact::create($params);
$emailId = $contact->email[0]->id;
$contactId = $contact->id;
$contact->free();
}
$params = array('job_id' => $job->id, 'email_id' => $emailId, 'contact_id' => $contactId);
CRM_Mailing_Event_BAO_Queue::create($params);
}
}
$testParams['job_id'] = $job->id;
$isComplete = FALSE;
while (!$isComplete) {
$isComplete = CRM_Mailing_BAO_Job::runJobs($testParams);
}
if (CRM_Utils_Array::value('sendtest', $testParams)) {
$status = ts('Your test message has been sent.');
if (CRM_Mailing_Info::workflowEnabled()) {
if (CRM_Core_Permission::check('schedule mailings') && CRM_Core_Permission::check('create mailings') || CRM_Core_Permission::check('access CiviMail')) {
$status .= ts(" Click 'Next' when you are ready to Schedule or Send your live mailing (you will still have a chance to confirm or cancel sending this mailing on the next page).");
}
} else {
$status .= ts(" Click 'Next' when you are ready to Schedule or Send your live mailing (you will still have a chance to confirm or cancel sending this mailing on the next page).");
}
CRM_Core_Session::setStatus($status);
$url = CRM_Utils_System::url($urlString, $urlParams);
CRM_Utils_System::redirect($url);
}
$error = TRUE;
return $error;
}
示例14: mte_createQueue
function mte_createQueue(&$mandrillHeader, $toEmail)
{
$mail = new CRM_Mailing_DAO_Mailing();
$mail->subject = "***All Transactional Emails***";
$mail->url_tracking = TRUE;
$mail->forward_replies = FALSE;
$mail->auto_responder = FALSE;
$mail->open_tracking = TRUE;
if ($mail->find(TRUE)) {
$emails = CRM_Mte_BAO_Mandrill::retrieveEmailContactId($toEmail);
$jobCLassName = 'CRM_Mailing_DAO_MailingJob';
if (version_compare('4.4alpha1', CRM_Core_Config::singleton()->civiVersion) > 0) {
$jobCLassName = 'CRM_Mailing_DAO_Job';
}
$params = array('job_id' => CRM_Core_DAO::getFieldValue($jobCLassName, $mail->id, 'id', 'mailing_id'), 'contact_id' => $emails['email']['contact_id'], 'email_id' => $emails['email']['id']);
$eventQueue = CRM_Mailing_Event_BAO_Queue::create($params);
$mandrillHeader = implode(CRM_Core_Config::singleton()->verpSeparator, array($mandrillHeader, 'm', $params['job_id'], $eventQueue->id, $eventQueue->hash));
}
}
示例15: deliver
/**
* Send the mailing
*
* @param object $mailer A Mail object to send the messages
* @return void
* @access public
*/
function deliver(&$mailer)
{
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing =& new CRM_Mailing_BAO_Mailing();
$mailing->id = $this->mailing_id;
$mailing->find(true);
$eq =& new CRM_Mailing_Event_BAO_Queue();
$eqTable = CRM_Mailing_Event_BAO_Queue::getTableName();
$emailTable = CRM_Core_BAO_Email::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 FROM {$eqTable}\n INNER JOIN {$emailTable}\n ON {$eqTable}.email_id = {$emailTable}.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";
$eq->query($query);
while ($eq->fetch()) {
/* Compose the mailing */
$recipient = null;
$message = $mailing->compose($this->id, $eq->id, $eq->hash, $eq->contact_id, $eq->email, $recipient);
/* Send the mailing */
$body = $message->get();
$headers = $message->headers();
/* TODO: when we separate the content generator from the delivery
* engine, maybe we should dump the messages into a table */
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('CRM_Mailing_BAO_Mailing', 'catchSMTP'));
$result = $mailer->send($recipient, $headers, $body);
CRM_Core_Error::setCallback();
$params = array('event_queue_id' => $eq->id, 'job_id' => $this->id, 'hash' => $eq->hash);
if (is_a($result, PEAR_Error)) {
/* Register the bounce event */
require_once 'CRM/Mailing/BAO/BouncePattern.php';
require_once 'CRM/Mailing/Event/BAO/Bounce.php';
$params = array_merge($params, CRM_Mailing_BAO_BouncePattern::match($result->getMessage()));
CRM_Mailing_Event_BAO_Bounce::create($params);
} else {
/* Register the delivery event */
CRM_Mailing_Event_BAO_Delivered::create($params);
}
}
}