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);
+ // $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]
$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) {
- $html = ($type == 'html') ? TRUE : FALSE;
+ $html = $type == 'html';
$pEmails[$type] = [];
$pEmail = &$pEmails[$type];
$template = &$pTemplates[$type]['template'];
$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
$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]);
$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 = [];