<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
* Class CRM_Mailing_BAO_MailingJob
*/
class CRM_Mailing_BAO_MailingJob extends CRM_Mailing_DAO_MailingJob {
- CONST MAX_CONTACTS_TO_PROCESS = 1000;
+ const MAX_CONTACTS_TO_PROCESS = 1000;
/**
- * class constructor
+ * (Dear God Why) Keep a global count of mails processed within the current
+ * request.
+ *
+ * @static
+ * @var int
+ */
+ static $mailsProcessed = 0;
+
+ /**
+ * Class constructor
*/
- function __construct() {
+ public function __construct() {
parent::__construct();
}
/**
- * @param $params
+ * @param array $params
*
* @return CRM_Mailing_BAO_MailingJob
*/
/**
* Initiate all pending/ready jobs
*
- * @param null $testParams
+ * @param array $testParams
* @param null $mode
*
* @return void
- * @access public
* @static
*/
public static function runJobs($testParams = NULL, $mode = NULL) {
}
/**
- * @param null $testParams
+ * @param array $testParams
*/
public function queue($testParams = NULL) {
$mailing = new CRM_Mailing_BAO_Mailing();
/**
* Send the mailing
*
- * @param object $mailer A Mail object to send the messages
+ * @param object $mailer
+ * A Mail object to send the messages.
*
- * @param null $testParams
+ * @param array $testParams
*
* @return void
- * @access public
*/
public function deliver(&$mailer, $testParams = NULL) {
$mailing = new CRM_Mailing_BAO_Mailing();
WHERE $eqTable.job_id = " . $this->id . "
AND $edTable.id IS null
AND $ebTable.id IS null
- AND $contactTable.is_opt_out = 0";
+ AND ( $contactTable.is_opt_out = 0
+ OR $contactTable.do_not_sms = 0 )";
}
$eq->query($query);
- static $config = NULL;
- static $mailsProcessed = 0;
+ $config = NULL;
if ($config == NULL) {
$config = CRM_Core_Config::singleton();
if (
$config->mailerBatchLimit > 0 &&
- $mailsProcessed >= $config->mailerBatchLimit
+ self::$mailsProcessed >= $config->mailerBatchLimit
) {
if (!empty($fields)) {
$this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
$eq->free();
return FALSE;
}
- $mailsProcessed++;
+ self::$mailsProcessed++;
$fields[] = array(
'id' => $eq->id,
$params = $targetParams = $deliveredParams = array();
$count = 0;
+ /**
+ * CRM-15702: Sending bulk sms to contacts without e-mail addres fails.
+ * Solution is to skip checking for on hold
+ */
+ $skipOnHold = true; //do include a statement to check wether e-mail address is on hold
+ if ($mailing->sms_provider_id) {
+ $skipOnHold = false; //do not include a statement to check wether e-mail address is on hold
+ }
+
foreach ($fields as $key => $field) {
$params[] = $field['contact_id'];
}
$details = CRM_Utils_Token::getTokenDetails(
$params,
$returnProperties,
- TRUE, TRUE, NULL,
+ $skipOnHold, TRUE, NULL,
$mailing->getFlattenedTokens(),
get_class($this),
$this->id
}
/**
- * cancel a mailing
+ * Cancel a mailing
*
- * @param int $mailingId the id of the mailing to be canceled
+ * @param int $mailingId
+ * The id of the mailing to be canceled.
* @static
*/
public static function cancel($mailingId) {
/**
* Return a translated status enum string
*
- * @param string $status The status enum
+ * @param string $status
+ * The status enum.
*
* @return string The translated version
- * @access public
* @static
*/
public static function status($status) {
* to only process jobs that are approved.
*
* @return string For use in a WHERE clause
- * @access public
* @static
*/
public static function workflowClause() {
}
/**
- * @param $deliveredParams
- * @param $targetParams
+ * @param array $deliveredParams
+ * @param array $targetParams
* @param $mailing
* @param $job_date
*
return $result;
}
}
-