projects
/
civicrm-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #16986 from colemanw/importParser
[civicrm-core.git]
/
CRM
/
Mailing
/
BAO
/
Mailing.php
diff --git
a/CRM/Mailing/BAO/Mailing.php
b/CRM/Mailing/BAO/Mailing.php
index 57fca1a971a32377e96fc19cae34ac1ed47e214d..a2b20bcf32dd27d459df3020d808f00d6876a3e6 100644
(file)
--- a/
CRM/Mailing/BAO/Mailing.php
+++ b/
CRM/Mailing/BAO/Mailing.php
@@
-1080,15
+1080,18
@@
ORDER BY civicrm_email.is_bulkmail DESC
elseif ($contactId === 0) {
//anonymous user
$contact = [];
elseif ($contactId === 0) {
//anonymous user
$contact = [];
- CRM_Utils_Hook::tokenValues($contact,
$contactId
, $job_id);
+ CRM_Utils_Hook::tokenValues($contact,
[$contactId]
, $job_id);
}
else {
$params = [['contact_id', '=', $contactId, 0, 0]];
list($contact) = CRM_Contact_BAO_Query::apiQuery($params);
}
else {
$params = [['contact_id', '=', $contactId, 0, 0]];
list($contact) = CRM_Contact_BAO_Query::apiQuery($params);
+ // $contact is an array of [ contactID => contactDetails ]
- //
CRM-4524
-
$contact = reset($contact
);
+ //
also call the hook to get contact details
+
CRM_Utils_Hook::tokenValues($contact, [$contactId], $job_id
);
+ // Don't send if contact doesn't exist
+ $contact = reset($contact);
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',
[1 => $contactId]
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',
[1 => $contactId]
@@
-1098,16
+1101,13
@@
ORDER BY civicrm_email.is_bulkmail DESC
$res = NULL;
return $res;
}
$res = NULL;
return $res;
}
-
- // also call the hook to get contact details
- CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id);
}
$pTemplates = $this->getPreparedTemplates();
$pEmails = [];
foreach ($pTemplates as $type => $pTemplate) {
}
$pTemplates = $this->getPreparedTemplates();
$pEmails = [];
foreach ($pTemplates as $type => $pTemplate) {
- $html =
($type == 'html') ? TRUE : FALSE
;
+ $html =
$type == 'html'
;
$pEmails[$type] = [];
$pEmail = &$pEmails[$type];
$template = &$pTemplates[$type]['template'];
$pEmails[$type] = [];
$pEmail = &$pEmails[$type];
$template = &$pTemplates[$type]['template'];
@@
-1148,7
+1148,7
@@
ORDER BY civicrm_email.is_bulkmail DESC
$message = new Mail_mime("\n");
$message = new Mail_mime("\n");
- $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY
? TRUE : FALSE
;
+ $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY;
if ($useSmarty) {
$smarty = CRM_Core_Smarty::singleton();
// also add the contact tokens to the template
if ($useSmarty) {
$smarty = CRM_Core_Smarty::singleton();
// also add the contact tokens to the template
@@
-1191,7
+1191,7
@@
ORDER BY civicrm_email.is_bulkmail DESC
$mailParams['attachments'] = $attachments;
$mailParams['attachments'] = $attachments;
- $mailParams['Subject'] =
CRM_Utils_Array::value('subject', $pEmails)
;
+ $mailParams['Subject'] =
$pEmails['subject'] ?? NULL
;
if (is_array($mailParams['Subject'])) {
$mailParams['Subject'] = implode('', $mailParams['Subject']);
}
if (is_array($mailParams['Subject'])) {
$mailParams['Subject'] = implode('', $mailParams['Subject']);
}
@@
-1300,7
+1300,7
@@
ORDER BY civicrm_email.is_bulkmail DESC
$mailing->templates[$type] = CRM_Utils_Token::replaceDomainTokens(
$mailing->templates[$type],
$domain,
$mailing->templates[$type] = CRM_Utils_Token::replaceDomainTokens(
$mailing->templates[$type],
$domain,
- $type == 'html'
? TRUE : FALSE
,
+ $type == 'html',
$tokens[$type]
);
$mailing->templates[$type] = CRM_Utils_Token::replaceMailingTokens($mailing->templates[$type], $mailing, NULL, $tokens[$type]);
$tokens[$type]
);
$mailing->templates[$type] = CRM_Utils_Token::replaceMailingTokens($mailing->templates[$type], $mailing, NULL, $tokens[$type]);
@@
-1329,7
+1329,7
@@
ORDER BY civicrm_email.is_bulkmail DESC
$token = $token_a['token'];
$data = $token;
$token = $token_a['token'];
$data = $token;
- $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY
? TRUE : FALSE
;
+ $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY;
if ($type == 'embedded_url') {
$embed_data = [];
if ($type == 'embedded_url') {
$embed_data = [];
@@
-1396,7
+1396,7
@@
ORDER BY civicrm_email.is_bulkmail DESC
}
}
else {
}
}
else {
- $data =
CRM_Utils_Array::value("{$type}.{$token}", $contact)
;
+ $data =
$contact["{$type}.{$token}"] ?? NULL
;
}
return $data;
}
}
return $data;
}
@@
-1523,7
+1523,7
@@
ORDER BY civicrm_email.is_bulkmail DESC
public static function create(&$params, $ids = []) {
if (empty($params['id']) && (array_filter($ids) !== [])) {
public static function create(&$params, $ids = []) {
if (empty($params['id']) && (array_filter($ids) !== [])) {
- $params['id'] =
isset($ids['mailing_id']) ? $ids['mailing_id'] :
$ids['id'];
+ $params['id'] =
$ids['mailing_id'] ??
$ids['id'];
\Civi::log('Parameter $ids is no longer used by Mailing::create. Use the api or just pass $params', ['civi.tag' => 'deprecated']);
}
\Civi::log('Parameter $ids is no longer used by Mailing::create. Use the api or just pass $params', ['civi.tag' => 'deprecated']);
}
@@
-2858,7
+2858,7
@@
ORDER BY civicrm_mailing.name";
// format the params
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
// format the params
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['rowCount'] = $params['rp'];
- $params['sort'] =
CRM_Utils_Array::value('sortBy', $params)
;
+ $params['sort'] =
$params['sortBy'] ?? NULL
;
$params['caseId'] = NULL;
// get contact mailings
$params['caseId'] = NULL;
// get contact mailings
@@
-2951,7
+2951,7
@@
ORDER BY civicrm_mailing.name";
$params['version'] = 3;
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['limit'] = $params['rp'];
$params['version'] = 3;
$params['offset'] = ($params['page'] - 1) * $params['rp'];
$params['limit'] = $params['rp'];
- $params['sort'] =
CRM_Utils_Array::value('sortBy', $params)
;
+ $params['sort'] =
$params['sortBy'] ?? NULL
;
$result = civicrm_api('MailingContact', 'get', $params);
return $result['values'];
$result = civicrm_api('MailingContact', 'get', $params);
return $result['values'];