//rebuild the recipients
self::getRecipients($mailingID);
- return civicrm_api3('MailingRecipients', 'getcount', array('mailing_id' => $mailingID));
+ return civicrm_api3('MailingRecipients', 'getcount', ['mailing_id' => $mailingID]);
}
/**
$isSMSmode = (!CRM_Utils_System::isNull($mailingObj->sms_provider_id));
$mailingGroup = new CRM_Mailing_DAO_MailingGroup();
- $recipientsGroup = $excludeSmartGroupIDs = $includeSmartGroupIDs = $priorMailingIDs = array();
+ $recipientsGroup = $excludeSmartGroupIDs = $includeSmartGroupIDs = $priorMailingIDs = [];
$dao = CRM_Utils_SQL_Select::from('civicrm_mailing_group')
- ->select('GROUP_CONCAT(entity_id SEPARATOR ",") as group_ids, group_type, entity_table')
- ->where('mailing_id = #mailing_id AND entity_table RLIKE "^civicrm_(group.*|mailing)$" ')
- ->groupBy(array('group_type', 'entity_table'))
- ->param('!groupTableName', CRM_Contact_BAO_Group::getTableName())
- ->param('#mailing_id', $mailingID)
- ->execute();
+ ->select('GROUP_CONCAT(entity_id SEPARATOR ",") as group_ids, group_type, entity_table')
+ ->where('mailing_id = #mailing_id AND entity_table RLIKE "^civicrm_(group.*|mailing)$" ')
+ ->groupBy(['group_type', 'entity_table'])
+ ->param('!groupTableName', CRM_Contact_BAO_Group::getTableName())
+ ->param('#mailing_id', $mailingID)
+ ->execute();
while ($dao->fetch()) {
if ($dao->entity_table == 'civicrm_mailing') {
$priorMailingIDs[$dao->group_type] = explode(',', $dao->group_ids);
// there is no need to proceed further if no mailing group is selected to include recipients,
// but before return clear the mailing recipients populated earlier since as per current params no group is selected
if (empty($recipientsGroup['Include']) && empty($priorMailingIDs['Include'])) {
- CRM_Core_DAO::executeQuery(" DELETE FROM civicrm_mailing_recipients WHERE mailing_id = %1 ", array(1 => array($mailingID, 'Integer')));
+ CRM_Core_DAO::executeQuery(" DELETE FROM civicrm_mailing_recipients WHERE mailing_id = %1 ", [
+ 1 => [
+ $mailingID,
+ 'Integer',
+ ],
+ ]);
return;
}
->select('DISTINCT contact_id')
->where('status = "Added" AND group_id IN (#groups)')
->param('#groups', $recipientsGroup['Exclude'])
- ->insertInto($excludeTempTablename, array('contact_id'))
+ ->insertInto($excludeTempTablename, ['contact_id'])
->execute();
if (count($excludeSmartGroupIDs)) {
->select('contact_id')
->where('group_id IN (#groups)')
->param('#groups', $excludeSmartGroupIDs)
- ->insertIgnoreInto($excludeTempTablename, array('contact_id'))
+ ->insertIgnoreInto($excludeTempTablename, ['contact_id'])
->execute();
}
}
->select('DISTINCT contact_id')
->where('mailing_id IN (#mailings)')
->param('#mailings', $priorMailingIDs['Exclude'])
- ->insertIgnoreInto($excludeTempTablename, array('contact_id'))
+ ->insertIgnoreInto($excludeTempTablename, ['contact_id'])
->execute();
}
->select('DISTINCT contact_id')
->where('status = "Removed" AND group_id IN (#groups)')
->param('#groups', $recipientsGroup['Base'])
- ->insertIgnoreInto($excludeTempTablename, array('contact_id'))
+ ->insertIgnoreInto($excludeTempTablename, ['contact_id'])
->execute();
}
);
if ($isSMSmode) {
- $criteria = array(
+ $criteria = [
'is_opt_out' => CRM_Utils_SQL_Select::fragment()->where("$contact.is_opt_out = 0"),
'is_deceased' => CRM_Utils_SQL_Select::fragment()->where("$contact.is_deceased <> 1"),
'do_not_sms' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_sms = 0"),
'mailing_id' => CRM_Utils_SQL_Select::fragment()->where("mg.mailing_id = #mailingID"),
'temp_contact_null' => CRM_Utils_SQL_Select::fragment()->where('temp.contact_id IS null'),
'order_by' => CRM_Utils_SQL_Select::fragment()->orderBy("$entityTable.is_primary"),
- );
+ ];
}
else {
// Criterias to filter recipients that need to be included
- $criteria = array(
+ $criteria = [
'do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0"),
'is_opt_out' => CRM_Utils_SQL_Select::fragment()->where("$contact.is_opt_out = 0"),
'is_deceased' => CRM_Utils_SQL_Select::fragment()->where("$contact.is_deceased <> 1"),
'mailing_id' => CRM_Utils_SQL_Select::fragment()->where("mg.mailing_id = #mailingID"),
'temp_contact_null' => CRM_Utils_SQL_Select::fragment()->where('temp.contact_id IS NULL'),
'order_by' => CRM_Utils_SQL_Select::fragment()->orderBy($order_by),
- );
+ ];
}
// Allow user to alter query responsible to fetch mailing recipients before build,
->join('temp', " LEFT JOIN $excludeTempTablename temp ON $contact.id = temp.contact_id ")
->where('gc.group_id IN (#groups) AND gc.status = "Added"')
->merge($criteria)
- ->groupBy(array("$contact.id", "$entityTable.id"))
- ->replaceInto($includedTempTablename, array('contact_id', $entityColumn))
+ ->groupBy(["$contact.id", "$entityTable.id"])
+ ->replaceInto($includedTempTablename, ['contact_id', $entityColumn])
->param('#groups', $recipientsGroup['Include'])
->param('#mailingID', $mailingID)
->execute();
->where('mailing_id IN (#mailings)')
->where('temp.contact_id IS NULL')
->param('#mailings', $priorMailingIDs['Include'])
- ->insertIgnoreInto($includedTempTablename, array('contact_id', $entityColumn))
+ ->insertIgnoreInto($includedTempTablename, [
+ 'contact_id',
+ $entityColumn,
+ ])
->execute();
}
->where('gc.group_id IN (#groups)')
->where('gcr.status IS NULL OR gcr.status != "Removed"')
->merge($criteria)
- ->replaceInto($includedTempTablename, array('contact_id', $entityColumn))
+ ->replaceInto($includedTempTablename, ['contact_id', $entityColumn])
->param('#groups', $includeSmartGroupIDs)
->param('#mailingID', $mailingID)
->execute();
// Construct the filtered search queries.
$dao = CRM_Utils_SQL_Select::from('civicrm_mailing_group')
- ->select('search_id, search_args, entity_id')
- ->where('search_id IS NOT NULL AND mailing_id = #mailingID')
- ->param('#mailingID', $mailingID)
- ->execute();
+ ->select('search_id, search_args, entity_id')
+ ->where('search_id IS NOT NULL AND mailing_id = #mailingID')
+ ->param('#mailingID', $mailingID)
+ ->execute();
while ($dao->fetch()) {
$customSQL = CRM_Contact_BAO_SearchCustom::civiMailSQL($dao->search_id,
$dao->search_args,
list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause();
// clear all the mailing recipients before populating
- CRM_Core_DAO::executeQuery(" DELETE FROM civicrm_mailing_recipients WHERE mailing_id = %1 ", array(1 => array($mailingID, 'Integer')));
-
- $selectClause = array('#mailingID', 'i.contact_id', "i.$entityColumn");
+ CRM_Core_DAO::executeQuery(" DELETE FROM civicrm_mailing_recipients WHERE mailing_id = %1 ", [
+ 1 => [
+ $mailingID,
+ 'Integer',
+ ],
+ ]);
+
+ $selectClause = ['#mailingID', 'i.contact_id', "i.$entityColumn"];
// CRM-3975
- $orderBy = array("i.contact_id", "i.$entityColumn");
+ $orderBy = ["i.contact_id", "i.$entityColumn"];
- $query = CRM_Utils_SQL_Select::from('civicrm_contact contact_a')->join('i', " INNER JOIN {$includedTempTablename} i ON contact_a.id = i.contact_id ");
+ $query = CRM_Utils_SQL_Select::from('civicrm_contact contact_a')
+ ->join('i', " INNER JOIN {$includedTempTablename} i ON contact_a.id = i.contact_id ");
if (!$isSMSmode && $mailingObj->dedupe_email) {
- $orderBy = array("MIN(i.contact_id)", "MIN(i.$entityColumn)");
- $query = $query->join('e', " INNER JOIN civicrm_email e ON e.id = i.email_id ")->groupBy("e.email");
+ $orderBy = ["MIN(i.contact_id)", "MIN(i.$entityColumn)"];
+ $query = $query->join('e', " INNER JOIN civicrm_email e ON e.id = i.email_id ")
+ ->groupBy("e.email");
if (CRM_Utils_SQL::supportsFullGroupBy()) {
- $selectClause = array('#mailingID', 'ANY_VALUE(i.contact_id) contact_id', "ANY_VALUE(i.$entityColumn) $entityColumn", "e.email");
+ $selectClause = [
+ '#mailingID',
+ 'ANY_VALUE(i.contact_id) contact_id',
+ "ANY_VALUE(i.$entityColumn) $entityColumn",
+ "e.email",
+ ];
}
}
$sql = $query->toSQL();
CRM_Utils_SQL_Select::from("( $sql ) AS i ")
->select($selectClause)
- ->insertInto('civicrm_mailing_recipients', array('mailing_id', 'contact_id', $entityColumn))
+ ->insertInto('civicrm_mailing_recipients', ['mailing_id', 'contact_id', $entityColumn])
->param('#mailingID', $mailingID)
->execute();
}
else {
- $query->insertInto('civicrm_mailing_recipients', array('mailing_id', 'contact_id', $entityColumn))
+ $query->insertInto('civicrm_mailing_recipients', ['mailing_id', 'contact_id', $entityColumn])
->param('#mailingID', $mailingID)
->execute();
}
$location_filter = "($email.location_type_id != $location_type_id)";
// If there is more than one email that doesn't match the location,
// prefer the one marked is_bulkmail, followed by is_primary.
- $orderBy = array("$email.is_bulkmail", "$email.is_primary");
+ $orderBy = ["$email.is_bulkmail", "$email.is_primary"];
break;
case 'location-only':
$location_filter = "($email.location_type_id = $location_type_id)";
// If there is more than one email of the desired location, prefer
// the one marked is_bulkmail, followed by is_primary.
- $orderBy = array("$email.is_bulkmail", "$email.is_primary");
+ $orderBy = ["$email.is_bulkmail", "$email.is_primary"];
break;
case 'location-prefer':
// types are left out, so they will be assigned the value 0. That
// means, they will all be equally tied for first place, with our
// location being last.
- $orderBy = array("FIELD($email.location_type_id, $location_type_id)", "$email.is_bulkmail", "$email.is_primary");
+ $orderBy = [
+ "FIELD($email.location_type_id, $location_type_id)",
+ "$email.is_bulkmail",
+ "$email.is_primary",
+ ];
break;
case 'automatic':
// fall through to default
default:
$location_filter = "($email.is_bulkmail = 1 OR $email.is_primary = 1)";
- $orderBy = array("$email.is_bulkmail");
+ $orderBy = ["$email.is_bulkmail"];
}
- return array($location_filter, $orderBy);
+ return [$location_filter, $orderBy];
}
/**
}
$mailingGroup->query($query);
- $groupIds = array();
+ $groupIds = [];
while ($mailingGroup->fetch()) {
$groupIds[] = $mailingGroup->entity_id;
}
*/
private function getPatterns($onlyHrefs = FALSE) {
- $patterns = array();
+ $patterns = [];
$protos = '(https?|ftp|mailto)';
$letters = '\w';
static $_categories = NULL;
static $_categoryString = NULL;
if (!$_categories) {
- $_categories = array(
+ $_categories = [
'domain' => NULL,
'action' => NULL,
'mailing' => NULL,
'contact' => NULL,
- );
+ ];
CRM_Utils_Hook::tokens($_categories);
$_categoryString = implode('|', array_keys($_categories));
}
- $funcStruct = array('type' => NULL, 'token' => $token);
- $matches = array();
+ $funcStruct = ['type' => NULL, 'token' => $token];
+ $matches = [];
if ((preg_match('/^href/i', $token) || preg_match('/^http/i', $token))) {
// it is a url so we need to check to see if there are any tokens embedded
// if so then call this function again to get the token dataFunc
// will know what how to handle this token.
if (preg_match_all('/(\{\w+\.\w+\})/', $token, $matches)) {
$funcStruct['type'] = 'embedded_url';
- $funcStruct['embed_parts'] = $funcStruct['token'] = array();
+ $funcStruct['embed_parts'] = $funcStruct['token'] = [];
foreach ($matches[1] as $match) {
$preg_token = '/' . preg_quote($match, '/') . '/';
$list = preg_split($preg_token, $token, 2);
$patterns['subject'] = $patterns['text'] = $this->getPatterns();
$templates = $this->getTemplates();
- $this->preparedTemplates = array();
+ $this->preparedTemplates = [];
- foreach (array(
+ foreach ([
'html',
'text',
'subject',
- ) as $key) {
+ ] as $key) {
if (!isset($templates[$key])) {
continue;
}
- $matches = array();
- $tokens = array();
- $split_template = array();
+ $matches = [];
+ $tokens = [];
+ $split_template = [];
$email = $templates[$key];
preg_match_all($patterns[$key], $email, $matches, PREG_PATTERN_ORDER);
public function getTemplates() {
if (!$this->templates) {
$this->getHeaderFooter();
- $this->templates = array();
+ $this->templates = [];
if ($this->body_text || !empty($this->header)) {
- $template = array();
+ $template = [];
if (!empty($this->header->body_text)) {
$template[] = $this->header->body_text;
}
// To check for an html part strip tags
if (trim(strip_tags($this->body_html, '<img>'))) {
- $template = array();
+ $template = [];
if ($this->header) {
$template[] = $this->header->body_html;
}
}
if ($this->subject) {
- $template = array();
+ $template = [];
$template[] = $this->subject;
$this->templates['subject'] = implode("\n", $template);
}
public function &getTokens() {
if (!$this->tokens) {
- $this->tokens = array('html' => array(), 'text' => array(), 'subject' => array());
+ $this->tokens = ['html' => [], 'text' => [], 'subject' => []];
if ($this->body_html) {
$this->_getTokens('html');
foreach ($newTokens as $type => $names) {
if (!isset($this->tokens[$prop][$type])) {
- $this->tokens[$prop][$type] = array();
+ $this->tokens[$prop][$type] = [];
}
foreach ($names as $key => $name) {
$this->tokens[$prop][$type][] = $name;
*/
public function getTestRecipients($testParams) {
if (!empty($testParams['test_group']) && array_key_exists($testParams['test_group'], CRM_Core_PseudoConstant::group())) {
- $contacts = civicrm_api('contact', 'get', array(
+ $contacts = civicrm_api('contact', 'get', [
'version' => 3,
'group' => $testParams['test_group'],
'return' => 'id',
- 'options' => array(
+ 'options' => [
'limit' => 100000000000,
- ),
- )
+ ],
+ ]
);
foreach (array_keys($contacts['values']) as $groupContact) {
";
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->fetch()) {
- $params = array(
+ $params = [
'job_id' => $testParams['job_id'],
'email_id' => $dao->email_id,
'contact_id' => $groupContact,
- );
+ ];
CRM_Mailing_Event_BAO_Queue::create($params);
}
}
$localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
$includeMessageId = CRM_Core_BAO_MailSettings::includeMessageId();
- $fields = array();
+ $fields = [];
$fields[] = 'Message-ID';
// CRM-17754 check if Resent-Message-id is set also if not add it in when re-laying reply email
if ($prefix == 'r') {
foreach ($fields as $field) {
if ($includeMessageId && (!array_key_exists($field, $headers))) {
$headers[$field] = '<' . implode($config->verpSeparator,
- array(
+ [
$localpart . $prefix,
$job_id,
$event_queue_id,
$hash,
- )
+ ]
) . "@{$emailDomain}>";
}
}
// use $bao's instance method to get verp and urls
list($verp, $urls, $_) = $bao->getVerpAndUrlsAndHeaders($job_id, $event_queue_id, $hash, $email);
- return array($verp, $urls);
+ return [$verp, $urls];
}
/**
* resubscribe: contact opts back into all target lists for the mailing
* optOut: contact unsubscribes from the domain
*/
- $verp = array();
- $verpTokens = array(
+ $verp = [];
+ $verpTokens = [
'reply' => 'r',
'bounce' => 'b',
'unsubscribe' => 'u',
'resubscribe' => 'e',
'optOut' => 'o',
- );
+ ];
$localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
foreach ($verpTokens as $key => $value) {
$verp[$key] = implode($config->verpSeparator,
- array(
+ [
$localpart . $value,
$job_id,
$event_queue_id,
$hash,
- )
+ ]
) . "@$emailDomain";
}
$verp['reply'] = "\"{$this->from_name}\" <{$this->from_email}>";
}
- $urls = array(
- 'forward' => CRM_Utils_System::url('civicrm/mailing/forward',
- "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}",
- TRUE, NULL, TRUE, TRUE
- ),
- 'unsubscribeUrl' => CRM_Utils_System::url('civicrm/mailing/unsubscribe',
- "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}",
- TRUE, NULL, TRUE, TRUE
- ),
- 'resubscribeUrl' => CRM_Utils_System::url('civicrm/mailing/resubscribe',
- "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}",
- TRUE, NULL, TRUE, TRUE
- ),
- 'optOutUrl' => CRM_Utils_System::url('civicrm/mailing/optout',
- "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}",
- TRUE, NULL, TRUE, TRUE
- ),
- 'subscribeUrl' => CRM_Utils_System::url('civicrm/mailing/subscribe',
- 'reset=1',
- TRUE, NULL, TRUE, TRUE
- ),
- );
+ $urls = [
+ 'forward' => CRM_Utils_System::url('civicrm/mailing/forward', "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", TRUE, NULL, TRUE, TRUE),
+ 'unsubscribeUrl' => CRM_Utils_System::url('civicrm/mailing/unsubscribe', "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", TRUE, NULL, TRUE, TRUE),
+ 'resubscribeUrl' => CRM_Utils_System::url('civicrm/mailing/resubscribe', "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", TRUE, NULL, TRUE, TRUE),
+ 'optOutUrl' => CRM_Utils_System::url('civicrm/mailing/optout', "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", TRUE, NULL, TRUE, TRUE),
+ 'subscribeUrl' => CRM_Utils_System::url('civicrm/mailing/subscribe', 'reset=1', TRUE, NULL, TRUE, TRUE),
+ ];
- $headers = array(
+ $headers = [
'Reply-To' => $verp['reply'],
'Return-Path' => $verp['bounce'],
'From' => "\"{$this->from_name}\" <{$this->from_email}>",
'Subject' => $this->subject,
'List-Unsubscribe' => "<mailto:{$verp['unsubscribe']}>",
- );
+ ];
self::addMessageIdHeader($headers, 'm', $job_id, $event_queue_id, $hash);
if ($isForward) {
$headers['Subject'] = "[Fwd:{$this->subject}]";
}
- return array(&$verp, &$urls, &$headers);
+ return [&$verp, &$urls, &$headers];
}
/**
}
elseif ($contactId === 0) {
//anonymous user
- $contact = array();
+ $contact = [];
CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id);
}
else {
- $params = array(array('contact_id', '=', $contactId, 0, 0));
+ $params = [['contact_id', '=', $contactId, 0, 0]];
list($contact) = CRM_Contact_BAO_Query::apiQuery($params);
//CRM-4524
if (!$contact || is_a($contact, 'CRM_Core_Error')) {
CRM_Core_Error::debug_log_message(ts('CiviMail will not send email to a non-existent contact: %1',
- array(1 => $contactId)
+ [1 => $contactId]
));
// setting this because function is called by reference
//@todo test not calling function by reference
}
$pTemplates = $this->getPreparedTemplates();
- $pEmails = array();
+ $pEmails = [];
foreach ($pTemplates as $type => $pTemplate) {
$html = ($type == 'html') ? TRUE : FALSE;
- $pEmails[$type] = array();
+ $pEmails[$type] = [];
$pEmail = &$pEmails[$type];
$template = &$pTemplates[$type]['template'];
$tokens = &$pTemplates[$type]['tokens'];
// CRM-9833
// something went wrong, lets log it and return null (by reference)
CRM_Core_Error::debug_log_message(ts('CiviMail will not send an empty mail body, Skipping: %1',
- array(1 => $email)
+ [1 => $email]
));
$res = NULL;
return $res;
//cycle through mailParams and set headers array
foreach ($mailParams as $paramKey => $paramValue) {
//exclude values not intended for the header
- if (!in_array($paramKey, array(
+ if (!in_array($paramKey, [
'text',
'html',
'attachments',
'toName',
'toEmail',
- ))
+ ])
) {
$headers[$paramKey] = $paramValue;
}
public static function tokenReplace(&$mailing) {
$domain = CRM_Core_BAO_Domain::getDomain();
- foreach (array('text', 'html') as $type) {
+ foreach (['text', 'html'] as $type) {
$tokens = $mailing->getTokens();
if (isset($mailing->templates[$type])) {
$mailing->templates[$type] = CRM_Utils_Token::replaceSubscribeInviteTokens($mailing->templates[$type]);
$useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY ? TRUE : FALSE;
if ($type == 'embedded_url') {
- $embed_data = array();
+ $embed_data = [];
foreach ($token as $t) {
$embed_data[] = $this->getTokenData($t, $html, $contact, $verp, $urls, $event_queue_id);
}
*/
public function &getGroupNames() {
if (!isset($this->id)) {
- return array();
+ return [];
}
$mg = new CRM_Mailing_DAO_MailingGroup();
$mgtable = CRM_Mailing_DAO_MailingGroup::getTableName();
AND $mgtable.group_type = 'Include'
ORDER BY $group.name");
- $groups = array();
+ $groups = [];
while ($mg->fetch()) {
$groups[] = $mg->name;
}
*
* @return CRM_Mailing_DAO_Mailing
*/
- public static function add(&$params, $ids = array()) {
+ public static function add(&$params, $ids = []) {
$id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('mailing_id', $ids));
if (empty($params['id']) && !empty($ids)) {
* $mailing The new mailing object
* @throws \Exception
*/
- public static function create(&$params, $ids = array()) {
+ public static function create(&$params, $ids = []) {
if (empty($params['id']) && (array_filter($ids) !== [])) {
$params['id'] = isset($ids['mailing_id']) ? $ids['mailing_id'] : $ids['id'];
$domain = civicrm_api(
'Domain',
'getsingle',
- array(
+ [
'version' => 3,
'current_domain' => 1,
'sequential' => 1,
- )
+ ]
);
if (isset($domain['from_email'])) {
$domain_email = $domain['from_email'];
$session =& CRM_Core_Session::singleton();
$params['created_id'] = $session->get('userID');
}
- $defaults = array(
+ $defaults = [
// load the default config settings for each
// eg reply_id, unsubscribe_id need to use
// correct template IDs here
'created_date' => date('YmdHis'),
'scheduled_date' => NULL,
'approval_date' => NULL,
- );
+ ];
// Get the default from email address, if not provided.
if (empty($defaults['from_email'])) {
/* Create the mailing group record */
$mg = new CRM_Mailing_DAO_MailingGroup();
- $groupTypes = array('include' => 'Include', 'exclude' => 'Exclude', 'base' => 'Base');
- foreach (array('groups', 'mailings') as $entity) {
- foreach (array('include', 'exclude', 'base') as $type) {
+ $groupTypes = [
+ 'include' => 'Include',
+ 'exclude' => 'Exclude',
+ 'base' => 'Base',
+ ];
+ foreach (['groups', 'mailings'] as $entity) {
+ foreach (['include', 'exclude', 'base'] as $type) {
if (isset($params[$entity][$type])) {
self::replaceGroups($mailing->id, $groupTypes[$type], $entity, $params[$entity][$type]);
}
// If we're going to autosend, then check validity before saving.
if (empty($params['is_completed']) && !empty($params['scheduled_date']) && $params['scheduled_date'] != 'null' && !empty($params['_evil_bao_validator_'])) {
- $cb = Civi\Core\Resolver::singleton()->get($params['_evil_bao_validator_']);
+ $cb = Civi\Core\Resolver::singleton()
+ ->get($params['_evil_bao_validator_']);
$errors = call_user_func($cb, $mailing);
if (!empty($errors)) {
$fields = implode(',', array_keys($errors));
* List of error messages.
*/
public static function checkSendable($mailing) {
- $errors = array();
- foreach (array('subject', 'name', 'from_name', 'from_email') as $field) {
+ $errors = [];
+ foreach (['subject', 'name', 'from_name', 'from_email'] as $field) {
if (empty($mailing->{$field})) {
- $errors[$field] = ts('Field "%1" is required.', array(
+ $errors[$field] = ts('Field "%1" is required.', [
1 => $field,
- ));
+ ]);
}
}
if (empty($mailing->body_html) && empty($mailing->body_text)) {
if (!Civi::settings()->get('disable_mandatory_tokens_check')) {
$header = $mailing->header_id && $mailing->header_id != 'null' ? CRM_Mailing_BAO_MailingComponent::findById($mailing->header_id) : NULL;
$footer = $mailing->footer_id && $mailing->footer_id != 'null' ? CRM_Mailing_BAO_MailingComponent::findById($mailing->footer_id) : NULL;
- foreach (array('body_html', 'body_text') as $field) {
+ foreach (['body_html', 'body_text'] as $field) {
if (empty($mailing->{$field})) {
continue;
}
if ($err !== TRUE) {
foreach ($err as $token => $desc) {
$errors["{$field}:{$token}"] = ts('This message is missing a required token - {%1}: %2',
- array(1 => $token, 2 => $desc)
+ [1 => $token, 2 => $desc]
);
}
}
* @throws CiviCRM_API3_Exception
*/
public static function replaceGroups($mailingId, $type, $entity, $entityIds) {
- $values = array();
+ $values = [];
foreach ($entityIds as $entityId) {
- $values[] = array('entity_id' => $entityId);
+ $values[] = ['entity_id' => $entityId];
}
- civicrm_api3('mailing_group', 'replace', array(
+ civicrm_api3('mailing_group', 'replace', [
'mailing_id' => $mailingId,
'group_type' => $type,
'entity_table' => ($entity == 'groups') ? CRM_Contact_BAO_Group::getTableName() : CRM_Mailing_BAO_Mailing::getTableName(),
'values' => $values,
- ));
+ ]);
}
/**
$mailing = new CRM_Mailing_BAO_Mailing();
- $t = array(
+ $t = [
'mailing' => self::getTableName(),
'mailing_group' => CRM_Mailing_DAO_MailingGroup::getTableName(),
'group' => CRM_Contact_BAO_Group::getTableName(),
'urlopen' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTableName(),
'component' => CRM_Mailing_BAO_MailingComponent::getTableName(),
'spool' => CRM_Mailing_BAO_Spool::getTableName(),
- );
+ ];
- $report = array();
+ $report = [];
$additionalWhereClause = " AND ";
if (!$isSMS) {
$additionalWhereClause .= " {$t['mailing']}.sms_provider_id IS NULL ";
$mailing->fetch();
- $report['mailing'] = array();
+ $report['mailing'] = [];
foreach (array_keys(self::fields()) as $field) {
if ($field == 'mailing_modified_date') {
$field = 'modified_date';
/* Get the component info */
- $query = array();
+ $query = [];
- $components = array(
+ $components = [
'header' => ts('Header'),
'footer' => ts('Footer'),
'reply' => ts('Reply'),
'optout' => ts('Opt-Out'),
'resubscribe' => ts('Resubscribe'),
'unsubscribe' => ts('Unsubscribe'),
- );
+ ];
foreach (array_keys($components) as $type) {
$query[] = "SELECT {$t['component']}.name as name,
'$type' as type,
$q = '(' . implode(') UNION (', $query) . ')';
$mailing->query($q);
- $report['component'] = array();
+ $report['component'] = [];
while ($mailing->fetch()) {
- $report['component'][] = array(
+ $report['component'][] = [
'type' => $components[$mailing->type],
'name' => $mailing->name,
- 'link' => CRM_Utils_System::url('civicrm/mailing/component',
- "reset=1&action=update&id={$mailing->id}"
- ),
- );
+ 'link' => CRM_Utils_System::url('civicrm/mailing/component', "reset=1&action=update&id={$mailing->id}"),
+ ];
}
/* Get the recipient group info */
WHERE {$t['mailing_group']}.mailing_id = $mailing_id
");
- $report['group'] = array('include' => array(), 'exclude' => array(), 'base' => array());
+ $report['group'] = ['include' => [], 'exclude' => [], 'base' => []];
while ($mailing->fetch()) {
- $row = array();
+ $row = [];
if (isset($mailing->group_id)) {
$row['id'] = $mailing->group_id;
$row['name'] = $mailing->group_title;
AND {$t['job']}.is_test = 0
GROUP BY {$t['job']}.id");
- $report['jobs'] = array();
- $report['event_totals'] = array();
- $elements = array(
+ $report['jobs'] = [];
+ $report['event_totals'] = [];
+ $path = 'civicrm/mailing/report/event';
+ $elements = [
'queue',
'delivered',
'url',
'total_opened',
'bounce',
'spool',
- );
+ ];
// initialize various counters
foreach ($elements as $field) {
}
while ($mailing->fetch()) {
- $row = array();
+ $row = [];
foreach ($elements as $field) {
if (isset($mailing->$field)) {
$row[$field] = $mailing->$field;
$row['clickthrough_rate'] = 0;
}
- $row['links'] = array(
- 'clicks' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=click&mid=$mailing_id&jid={$mailing->id}"
- ),
- 'queue' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=queue&mid=$mailing_id&jid={$mailing->id}"
- ),
- 'delivered' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=delivered&mid=$mailing_id&jid={$mailing->id}"
- ),
- 'bounce' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=bounce&mid=$mailing_id&jid={$mailing->id}"
- ),
- 'unsubscribe' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=unsubscribe&mid=$mailing_id&jid={$mailing->id}"
- ),
- 'forward' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=forward&mid=$mailing_id&jid={$mailing->id}"
- ),
- 'reply' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=reply&mid=$mailing_id&jid={$mailing->id}"
- ),
- 'opened' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=opened&mid=$mailing_id&jid={$mailing->id}"
- ),
- );
+ $arg = "reset=1&mid=$mailing_id&jid={$mailing->id}";
+ $row['links'] = [
+ 'clicks' => CRM_Utils_System::url($path, "$arg&event=click"),
+ 'queue' => CRM_Utils_System::url($path, "$arg&event=queue"),
+ 'delivered' => CRM_Utils_System::url($path, "$arg&event=delivered"),
+ 'bounce' => CRM_Utils_System::url($path, "$arg&event=bounce"),
+ 'unsubscribe' => CRM_Utils_System::url($path, "$arg&event=unsubscribe"),
+ 'forward' => CRM_Utils_System::url($path, "$arg&event=forward"),
+ 'reply' => CRM_Utils_System::url($path, "$arg&event=reply"),
+ 'opened' => CRM_Utils_System::url($path, "$arg&event=opened"),
+ ];
- foreach (array(
- 'scheduled_date',
- 'start_date',
- 'end_date',
- ) as $key) {
+ foreach (['scheduled_date', 'start_date', 'end_date'] as $key) {
$row[$key] = CRM_Utils_Date::customFormat($row[$key]);
}
$report['jobs'][] = $row;
GROUP BY {$t['url']}.id
ORDER BY unique_clicks DESC");
- $report['click_through'] = array();
+ $report['click_through'] = [];
while ($mailing->fetch()) {
- $report['click_through'][] = array(
+ $report['click_through'][] = [
'url' => $mailing->url,
- 'link' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=click&mid=$mailing_id&uid={$mailing->id}"
- ),
- 'link_unique' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=click&mid=$mailing_id&uid={$mailing->id}&distinct=1"
- ),
+ 'link' => CRM_Utils_System::url($path, "reset=1&event=click&mid=$mailing_id&uid={$mailing->id}"),
+ 'link_unique' => CRM_Utils_System::url($path, "reset=1&event=click&mid=$mailing_id&uid={$mailing->id}&distinct=1"),
'clicks' => $mailing->clicks,
'unique' => $mailing->unique_clicks,
'rate' => CRM_Utils_Array::value('delivered', $report['event_totals']) ? (100.0 * $mailing->unique_clicks) / $report['event_totals']['delivered'] : 0,
'report' => CRM_Report_Utils_Report::getNextUrl('mailing/clicks', "reset=1&mailing_id_value={$mailing_id}&url_value={$mailing->url}", FALSE, TRUE),
- );
- }
-
- $report['event_totals']['links'] = array(
- 'clicks' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=click&mid=$mailing_id"
- ),
- 'clicks_unique' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=click&mid=$mailing_id&distinct=1"
- ),
- 'queue' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=queue&mid=$mailing_id"
- ),
- 'delivered' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=delivered&mid=$mailing_id"
- ),
- 'bounce' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=bounce&mid=$mailing_id"
- ),
- 'unsubscribe' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=unsubscribe&mid=$mailing_id"
- ),
- 'optout' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=optout&mid=$mailing_id"
- ),
- 'forward' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=forward&mid=$mailing_id"
- ),
- 'reply' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=reply&mid=$mailing_id"
- ),
- 'opened' => CRM_Utils_System::url(
- 'civicrm/mailing/report/event',
- "reset=1&event=opened&mid=$mailing_id"
- ),
- );
-
- $actionLinks = array(CRM_Core_Action::VIEW => array('name' => ts('Report')));
- $actionLinks[CRM_Core_Action::ADVANCED] = array(
+ ];
+ }
+
+ $arg = "reset=1&mid=$mailing_id";
+ $report['event_totals']['links'] = [
+ 'clicks' => CRM_Utils_System::url($path, "$arg&event=click"),
+ 'clicks_unique' => CRM_Utils_System::url($path, "$arg&event=click&distinct=1"),
+ 'queue' => CRM_Utils_System::url($path, "$arg&event=queue"),
+ 'delivered' => CRM_Utils_System::url($path, "$arg&event=delivered"),
+ 'bounce' => CRM_Utils_System::url($path, "$arg&event=bounce"),
+ 'unsubscribe' => CRM_Utils_System::url($path, "$arg&event=unsubscribe"),
+ 'optout' => CRM_Utils_System::url($path, "$arg&event=optout"),
+ 'forward' => CRM_Utils_System::url($path, "$arg&event=forward"),
+ 'reply' => CRM_Utils_System::url($path, "$arg&event=reply"),
+ 'opened' => CRM_Utils_System::url($path, "$arg&event=opened"),
+ ];
+
+ $actionLinks = [CRM_Core_Action::VIEW => ['name' => ts('Report')]];
+ $actionLinks[CRM_Core_Action::ADVANCED] = [
'name' => ts('Advanced Search'),
'url' => 'civicrm/contact/search/advanced',
- );
+ ];
$action = array_sum(array_keys($actionLinks));
- $report['event_totals']['actionlinks'] = array();
- foreach (array(
- 'clicks',
- 'clicks_unique',
- 'queue',
- 'delivered',
- 'bounce',
- 'unsubscribe',
- 'forward',
- 'reply',
- 'opened',
- 'opened_unique',
- 'optout',
- ) as $key) {
+ $report['event_totals']['actionlinks'] = [];
+ foreach (['clicks', 'clicks_unique', 'queue', 'delivered', 'bounce', 'unsubscribe', 'forward', 'reply', 'opened', 'opened_unique', 'optout'] as $key) {
$url = 'mailing/detail';
$reportFilter = "reset=1&mailing_id_value={$mailing_id}";
$searchFilter = "force=1&mailing_id=%%mid%%";
$report['event_totals']['actionlinks'][$key] = CRM_Core_Action::formLink(
$actionLinks,
$action,
- array('mid' => $mailing_id),
+ ['mid' => $mailing_id],
ts('more'),
FALSE,
'mailing.report.action',
return TRUE;
}
- $mailingIDs = array();
+ $mailingIDs = [];
// get all the groups that this user can access
// if they dont have universal access
- $groupNames = civicrm_api3('Group', 'get', array(
+ $groupNames = civicrm_api3('Group', 'get', [
'check_permissions' => TRUE,
- 'return' => array('title', 'id'),
- 'options' => array('limit' => 0),
- ));
+ 'return' => ['title', 'id'],
+ 'options' => ['limit' => 0],
+ ]);
foreach ($groupNames['values'] as $group) {
$groups[$group['id']] = $group['title'];
}
";
$dao = CRM_Core_DAO::executeQuery($query);
- $mailingIDs = array();
+ $mailingIDs = [];
while ($dao->fetch()) {
$mailingIDs[] = $dao->id;
}
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
- $select = array(
- "$mailing.id", "$mailing.name", "$job.status",
- "$mailing.approval_status_id", "createdContact.sort_name as created_by", "scheduledContact.sort_name as scheduled_by",
- "$mailing.created_id as created_id", "$mailing.scheduled_id as scheduled_id", "$mailing.is_archived as archived",
- "$mailing.created_date as created_date", "campaign_id", "$mailing.sms_provider_id as sms_provider_id",
+ $select = [
+ "$mailing.id",
+ "$mailing.name",
+ "$job.status",
+ "$mailing.approval_status_id",
+ "createdContact.sort_name as created_by",
+ "scheduledContact.sort_name as scheduled_by",
+ "$mailing.created_id as created_id",
+ "$mailing.scheduled_id as scheduled_id",
+ "$mailing.is_archived as archived",
+ "$mailing.created_date as created_date",
+ "campaign_id",
+ "$mailing.sms_provider_id as sms_provider_id",
"$mailing.language",
- );
+ ];
// we only care about parent jobs, since that holds all the info on
// the mailing
}
if (!$additionalParams) {
- $additionalParams = array();
+ $additionalParams = [];
}
$dao = CRM_Core_DAO::executeQuery($query, $additionalParams);
- $rows = array();
+ $rows = [];
while ($dao->fetch()) {
- $rows[] = array(
+ $rows[] = [
'id' => $dao->id,
'name' => $dao->name,
'status' => $dao->status ? $dao->status : 'Not scheduled',
'campaign' => empty($dao->campaign_id) ? NULL : $allCampaigns[$dao->campaign_id],
'sms_provider_id' => $dao->sms_provider_id,
'language' => $dao->language,
- );
+ ];
}
return $rows;
}
public function getReturnProperties() {
$tokens = &$this->getTokens();
- $properties = array();
+ $properties = [];
if (isset($tokens['html']) &&
isset($tokens['html']['contact'])
) {
$properties = array_merge($properties, $tokens['subject']['contact']);
}
- $returnProperties = array();
+ $returnProperties = [];
$returnProperties['display_name'] = $returnProperties['contact_id'] = $returnProperties['preferred_mail_format'] = $returnProperties['hash'] = 1;
foreach ($properties as $p) {
*/
public static function commonCompose(&$form) {
//get the tokens.
- $tokens = array();
+ $tokens = [];
if (method_exists($form, 'listTokens')) {
$tokens = array_merge($form->listTokens(), $tokens);
//sorted in ascending order tokens by ignoring word case
$form->assign('tokens', CRM_Utils_Token::formatTokensForDisplay($tokens));
- $templates = array();
+ $templates = [];
- $textFields = array('text_message' => ts('HTML Format'), 'sms_text_message' => ts('SMS Message'));
- $modePrefixes = array('Mail' => NULL, 'SMS' => 'SMS');
+ $textFields = [
+ 'text_message' => ts('HTML Format'),
+ 'sms_text_message' => ts('SMS Message'),
+ ];
+ $modePrefixes = ['Mail' => NULL, 'SMS' => 'SMS'];
$className = CRM_Utils_System::getClassName($form);
) {
$form->add('wysiwyg', 'html_message',
strstr($className, 'PDF') ? ts('Document Body') : ts('HTML Format'),
- array(
+ [
'cols' => '80',
'rows' => '8',
'onkeyup' => "return verify(this)",
- )
+ ]
);
if ($className != 'CRM_Admin_Form_ScheduleReminders') {
$form->assign('max_sms_length', CRM_SMS_Provider::MAX_SMS_CHAR);
}
$form->add('textarea', $id, $label,
- array(
+ [
'cols' => '80',
'rows' => '8',
'onkeyup' => "return verify(this, '{$prefix}')",
- )
+ ]
);
}
$form->assign('templates', TRUE);
$form->add('select', "{$prefix}template", ts('Use Template'),
- array('' => ts('- select -')) + $templates[$prefix], FALSE,
- array('onChange' => "selectValue( this.value, '{$prefix}');")
+ ['' => ts('- select -')] + $templates[$prefix], FALSE,
+ ['onChange' => "selectValue( this.value, '{$prefix}');"]
);
}
$form->add('checkbox', "{$prefix}updateTemplate", ts('Update Template'), NULL);
$form->add('checkbox', "{$prefix}saveTemplate", ts('Save As New Template'), NULL, FALSE,
- array('onclick' => "showSaveDetails(this, '{$prefix}');")
+ ['onclick' => "showSaveDetails(this, '{$prefix}');"]
);
$form->add('text', "{$prefix}saveTemplateName", ts('Template Title'));
}
// I'm not sure this is ever called.
$action = CRM_Utils_Request::retrieve('action', 'String', $form, FALSE);
if ((CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Task_PDF') &&
- $action == CRM_Core_Action::VIEW
+ $action == CRM_Core_Action::VIEW
) {
$form->freeze('html_message');
}
AND $group.group_type = 'Base'";
$searchDAO = CRM_Core_DAO::executeQuery($query);
- $mailingIDs = array();
+ $mailingIDs = [];
while ($searchDAO->fetch()) {
$mailingIDs[] = $searchDAO->mailing_id;
}
* @return mixed
*/
public static function overrideVerp($jobID) {
- static $_cache = array();
+ static $_cache = [];
if (!isset($_cache[$jobID])) {
$query = "
INNER JOIN civicrm_mailing_job ON civicrm_mailing.id = civicrm_mailing_job.mailing_id
WHERE civicrm_mailing_job.id = %1
";
- $params = array(1 => array($jobID, 'Integer'));
+ $params = [1 => [$jobID, 'Integer']];
$_cache[$jobID] = CRM_Core_DAO::singleValueQuery($query, $params);
}
return $_cache[$jobID];
$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 system administrator guide</a>', array(
- 1 => CRM_Utils_System::url('civicrm/admin/mailSettings', 'reset=1'),
- 2 => "https://docs.civicrm.org/sysadmin/en/latest/setup/civimail/",
- )));
+ 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 system administrator guide</a>', [
+ 1 => CRM_Utils_System::url('civicrm/admin/mailSettings', 'reset=1'),
+ 2 => "https://docs.civicrm.org/sysadmin/en/latest/setup/civimail/",
+ ]));
}
// check if we are enforcing number of parallel cron jobs
// Check if we are using global locks
foreach ($lockArray as $lockID) {
- $cronLock = Civi::lockManager()->acquire("worker.mailing.send.{$lockID}");
+ $cronLock = Civi::lockManager()
+ ->acquire("worker.mailing.send.{$lockID}");
if ($cronLock->isAcquired()) {
$gotCronLock = TRUE;
break;
( SELECT contact_id FROM civicrm_mailing_recipients mr WHERE mailing_id = %1 )
AND e.id NOT IN ( SELECT email_id FROM civicrm_mailing_recipients mr WHERE mailing_id = %1 )
";
- $params = array(1 => array($mailingID, 'Integer'));
+ $params = [1 => [$mailingID, 'Integer']];
$dao = CRM_Core_DAO::executeQuery($sql, $params);
}
* @return mixed
*/
public static function getMailingsList($isSMS = FALSE) {
- static $list = array();
+ static $list = [];
$where = " WHERE ";
if (!$isSMS) {
$where .= " civicrm_mailing.sms_provider_id IS NULL ";
}
// format params and add links
- $contactMailings = array();
+ $contactMailings = [];
foreach ($mailings as $mailingId => $values) {
- $mailing = array();
+ $mailing = [];
$mailing['subject'] = $values['subject'];
$mailing['creator_name'] = CRM_Utils_System::href(
$values['creator_name'],
"<br />Clicks: " .
CRM_Utils_Array::value($values['mailing_id'], $clickCounts, 0);
- $actionLinks = array(
- CRM_Core_Action::VIEW => array(
+ $actionLinks = [
+ CRM_Core_Action::VIEW => [
'name' => ts('View'),
'url' => 'civicrm/mailing/view',
'qs' => "reset=1&id=%%mkey%%",
'title' => ts('View Mailing'),
'class' => 'crm-popup',
- ),
- CRM_Core_Action::BROWSE => array(
+ ],
+ CRM_Core_Action::BROWSE => [
'name' => ts('Mailing Report'),
'url' => 'civicrm/mailing/report',
'qs' => "mid=%%mid%%&reset=1&cid=%%cid%%&context=mailing",
'title' => ts('View Mailing Report'),
- ),
- );
+ ],
+ ];
$mailingKey = $values['mailing_id'];
if ($hash = CRM_Mailing_BAO_Mailing::getMailingHash($mailingKey)) {
$mailing['links'] = CRM_Core_Action::formLink(
$actionLinks,
NULL,
- array(
+ [
'mid' => $values['mailing_id'],
'cid' => $params['contact_id'],
'mkey' => $mailingKey,
- ),
+ ],
ts('more'),
FALSE,
'mailing.contact.action',
array_push($contactMailings, $mailing);
}
- $contactMailingsDT = array();
+ $contactMailingsDT = [];
$contactMailingsDT['data'] = $contactMailings;
$contactMailingsDT['recordsTotal'] = $params['total'];
$contactMailingsDT['recordsFiltered'] = $params['total'];
*/
public static function getWorkflowFieldPerms() {
$fieldNames = array_keys(CRM_Mailing_DAO_Mailing::fields());
- $fieldPerms = array();
+ $fieldPerms = [];
foreach ($fieldNames as $fieldName) {
if ($fieldName == 'id') {
- $fieldPerms[$fieldName] = array(
- array('access CiviMail', 'schedule mailings', 'approve mailings', 'create mailings'), // OR
- );
- }
- elseif (in_array($fieldName, array('scheduled_date', 'scheduled_id'))) {
- $fieldPerms[$fieldName] = array(
- array('access CiviMail', 'schedule mailings'), // OR
- );
- }
- elseif (in_array($fieldName, array('approval_date', 'approver_id', 'approval_status_id', 'approval_note'))) {
- $fieldPerms[$fieldName] = array(
- array('access CiviMail', 'approve mailings'), // OR
- );
+ $fieldPerms[$fieldName] = [
+ [
+ 'access CiviMail',
+ 'schedule mailings',
+ 'approve mailings',
+ 'create mailings',
+ ], // OR
+ ];
+ }
+ elseif (in_array($fieldName, ['scheduled_date', 'scheduled_id'])) {
+ $fieldPerms[$fieldName] = [
+ ['access CiviMail', 'schedule mailings'], // OR
+ ];
+ }
+ elseif (in_array($fieldName, [
+ 'approval_date',
+ 'approver_id',
+ 'approval_status_id',
+ 'approval_note',
+ ])) {
+ $fieldPerms[$fieldName] = [
+ ['access CiviMail', 'approve mailings'], // OR
+ ];
}
else {
- $fieldPerms[$fieldName] = array(
- array('access CiviMail', 'create mailings'), // OR
- );
+ $fieldPerms[$fieldName] = [
+ ['access CiviMail', 'create mailings'], // OR
+ ];
}
}
return $fieldPerms;
* @return array
*/
public static function mailingGroupEntityTables() {
- return array(
+ return [
CRM_Contact_BAO_Group::getTableName() => 'Group',
CRM_Mailing_BAO_Mailing::getTableName() => 'Mailing',
- );
+ ];
}
/**
* @return string
*/
public static function getPublicViewUrl($id, $absolute = TRUE) {
- if ((civicrm_api3('Mailing', 'getvalue', array('id' => $id, 'return' => 'visibility'))) === 'Public Pages') {
- return CRM_Utils_System::url('civicrm/mailing/view', array('id' => $id), $absolute, NULL, TRUE, TRUE);
+ if ((civicrm_api3('Mailing', 'getvalue', [
+ 'id' => $id,
+ 'return' => 'visibility',
+ ])) === 'Public Pages') {
+ return CRM_Utils_System::url('civicrm/mailing/view', ['id' => $id], $absolute, NULL, TRUE, TRUE);
}
}
*/
public static function getTemplateTypes() {
if (!isset(Civi::$statics[__CLASS__]['templateTypes'])) {
- $types = array();
- $types[] = array(
+ $types = [];
+ $types[] = [
'name' => 'traditional',
'editorUrl' => CRM_Mailing_Info::workflowEnabled() ? '~/crmMailing/EditMailingCtrl/workflow.html' : '~/crmMailing/EditMailingCtrl/2step.html',
'weight' => 0,
- );
+ ];
CRM_Utils_Hook::mailingTemplateTypes($types);
- $defaults = array('weight' => 0);
+ $defaults = ['weight' => 0];
foreach (array_keys($types) as $typeName) {
$types[$typeName] = array_merge($defaults, $types[$typeName]);
}
* Array(string $name => string $label).
*/
public static function getTemplateTypeNames() {
- $r = array();
+ $r = [];
foreach (self::getTemplateTypes() as $type) {
$r[$type['name']] = $type['name'];
}