<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
}
/**
+ * @deprecated
+ *
* @param int $job_id
* @param int $mailing_id
- * @param null $mode
*
* @return int
*/
- public static function &getRecipientsCount($job_id, $mailing_id = NULL, $mode = NULL) {
+ public static function getRecipientsCount($job_id, $mailing_id = NULL) {
// need this for backward compatibility, so we can get count for old mailings
// please do not use this function if possible
$eq = self::getRecipients($job_id, $mailing_id);
* @param int $job_id
* (misnomer) a nonce value used to name temporary tables.
* @param int $mailing_id
- * @param null $offset
- * @param null $limit
* @param bool $storeRecipients
* @param bool $dedupeEmail
* @param null $mode
*
* @return CRM_Mailing_Event_BAO_Queue|string
*/
- public static function &getRecipients(
+ public static function getRecipients(
$job_id,
$mailing_id = NULL,
- $offset = NULL,
- $limit = NULL,
$storeRecipients = FALSE,
$dedupeEmail = FALSE,
$mode = NULL) {
$job = CRM_Mailing_BAO_MailingJob::getTableName();
$mg = CRM_Mailing_DAO_MailingGroup::getTableName();
$eq = CRM_Mailing_Event_DAO_Queue::getTableName();
- $ed = CRM_Mailing_Event_DAO_Delivered::getTableName();
- $eb = CRM_Mailing_Event_DAO_Bounce::getTableName();
$email = CRM_Core_DAO_Email::getTableName();
if ($mode == 'sms') {
}
$mailingGroup->query($query);
- $results = array();
-
$eq = new CRM_Mailing_Event_BAO_Queue();
list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause();
$aclWhere = $aclWhere ? "WHERE {$aclWhere}" : '';
- $limitString = NULL;
- if ($limit && $offset !== NULL) {
- $offset = CRM_Utils_Type::escape($offset, 'Int');
- $limit = CRM_Utils_Type::escape($limit, 'Int');
-
- $limitString = "LIMIT $offset, $limit";
- }
if ($storeRecipients && $mailing_id) {
$sql = "
/**
* Returns the regex patterns that are used for preparing the text and html templates.
*/
- private function &getPatterns($onlyHrefs = FALSE) {
+ private function getPatterns($onlyHrefs = FALSE) {
$patterns = array();
*
* @return Mail_mime The mail object
*/
- public function &compose(
+ public function compose(
$job_id, $event_queue_id, $hash, $contactId,
$email, &$recipient, $test,
$contactDetails, &$attachments, $isForward = FALSE,
$fromEmail = NULL, $replyToEmail = NULL
) {
$config = CRM_Core_Config::singleton();
- $knownTokens = $this->getTokens();
+ $this->getTokens();
if ($this->_domain == NULL) {
$this->_domain = CRM_Core_BAO_Domain::getDomain();
}
else {
$params = array(array('contact_id', '=', $contactId, 0, 0));
- list($contact, $_) = CRM_Contact_BAO_Query::apiQuery($params);
+ list($contact) = CRM_Contact_BAO_Query::apiQuery($params);
//CRM-4524
$contact = reset($contact);
// Populate the recipients.
if (empty($params['_skip_evil_bao_auto_recipients_'])) {
- self::getRecipients($job->id, $mailing->id, NULL, NULL, TRUE, $mailing->dedupe_email);
+ self::getRecipients($job->id, $mailing->id, TRUE, $mailing->dedupe_email);
}
}
'unsubscribe',
'optout',
'opened',
+ 'total_opened',
'bounce',
'spool',
);
// CRM-1258
$row['opened'] = CRM_Mailing_Event_BAO_Opened::getTotalCount($mailing_id, $mailing->id, TRUE);
$report['event_totals']['opened'] += $row['opened'];
+ $row['total_opened'] = CRM_Mailing_Event_BAO_Opened::getTotalCount($mailing_id, $mailing->id);
+ $report['event_totals']['total_opened'] += $row['total_opened'];
// compute unsub total separately to discount duplicates
// CRM-1783
// get all the groups that this user can access
// if they dont have universal access
- $groups = CRM_Core_PseudoConstant::group(NULL, FALSE);
+ $groupNames = civicrm_api3('Group', 'get', array(
+ 'is_active' => 1,
+ 'check_permissions' => TRUE,
+ 'return' => array('title', 'id'),
+ 'options' => array('limit' => 0),
+ ));
+ foreach ($groupNames['values'] as $group) {
+ $groups[$group['id']] = $group['title'];
+ }
if (!empty($groups)) {
$groupIDs = implode(',', array_keys($groups));
+ $domain_id = CRM_Core_Config::domainID();
// get all the mailings that are in this subset of groups
$query = "
FROM civicrm_mailing m
LEFT JOIN civicrm_mailing_group g ON g.mailing_id = m.id
WHERE ( ( g.entity_table like 'civicrm_group%' AND g.entity_id IN ( $groupIDs ) )
- OR ( g.entity_table IS NULL AND g.entity_id IS NULL ) )
+ OR ( g.entity_table IS NULL AND g.entity_id IS NULL AND m.domain_id = $domain_id ) )
";
$dao = CRM_Core_DAO::executeQuery($query);
* @throws Exception
*/
public static function processQueue($mode = NULL) {
- $config = &CRM_Core_Config::singleton();
+ $config = CRM_Core_Config::singleton();
if ($mode == NULL && CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG") {
throw new CRM_Core_Exception(ts('The <a href="%1">default mailbox</a> has not been configured. You will find <a href="%2">more info in the online user and administrator guide</a>', array(
// CRM-8460
$gotCronLock = FALSE;
- if (property_exists($config, 'mailerJobsMax') && $config->mailerJobsMax && $config->mailerJobsMax > 0) {
- $lockArray = range(1, $config->mailerJobsMax);
+ $mailerJobsMax = Civi::settings()->get('mailerJobsMax');
+ if (is_numeric($mailerJobsMax) && $mailerJobsMax > 0) {
+ $lockArray = range(1, $mailerJobsMax);
shuffle($lockArray);
// check if we are using global locks
foreach ($lockArray as $lockID) {
- $cronLock = Civi\Core\Container::singleton()->get('lockManager')->acquire("worker.mailing.send.{$lockID}");
+ $cronLock = Civi::lockManager()->acquire("worker.mailing.send.{$lockID}");
if ($cronLock->isAcquired()) {
$gotCronLock = TRUE;
break;
// load bootstrap to call hooks
// Split up the parent jobs into multiple child jobs
- $mailerJobSize = (property_exists($config, 'mailerJobSize')) ? $config->mailerJobSize : NULL;
+ $mailerJobSize = Civi::settings()->get('mailerJobSize');
CRM_Mailing_BAO_MailingJob::runJobs_pre($mailerJobSize, $mode);
CRM_Mailing_BAO_MailingJob::runJobs(NULL, $mode);
CRM_Mailing_BAO_MailingJob::runJobs_post($mode);