From: eileen Date: Tue, 19 Jan 2021 00:02:49 +0000 (+1300) Subject: [REF] Move related code to be together X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=18afc442c6922aeacf888f7edc30fff2f6088472;p=civicrm-core.git [REF] Move related code to be together Puts both if (contactID) sections into the same if --- diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index 1904d750ca..0daa7769ec 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -433,9 +433,16 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $mailing->body_html = $mailContent['html']; $tokens = $mailing->getTokens(); - $contactID = $params['contactId'] ?? NULL; + // When using Smarty we need to pass the $escapeSmarty parameter. + $escapeSmarty = !$params['disableSmarty']; + + $mailContent['subject'] = CRM_Utils_Token::replaceDomainTokens($mailContent['subject'], $domain, FALSE, $tokens['subject'], $escapeSmarty); + $mailContent['text'] = CRM_Utils_Token::replaceDomainTokens($mailContent['text'], $domain, FALSE, $tokens['text'], $escapeSmarty); + $mailContent['html'] = CRM_Utils_Token::replaceDomainTokens($mailContent['html'], $domain, TRUE, $tokens['html'], $escapeSmarty); + $contactID = $params['contactId'] ?? NULL; if ($contactID) { + $contactParams = ['contact_id' => $contactID]; $returnProperties = []; @@ -469,16 +476,6 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { 'CRM_Core_BAO_MessageTemplate' ); $contact = $contact[$contactID]; - } - - // When using Smarty we need to pass the $escapeSmarty parameter. - $escapeSmarty = !$params['disableSmarty']; - - $mailContent['subject'] = CRM_Utils_Token::replaceDomainTokens($mailContent['subject'], $domain, FALSE, $tokens['subject'], $escapeSmarty); - $mailContent['text'] = CRM_Utils_Token::replaceDomainTokens($mailContent['text'], $domain, FALSE, $tokens['text'], $escapeSmarty); - $mailContent['html'] = CRM_Utils_Token::replaceDomainTokens($mailContent['html'], $domain, TRUE, $tokens['html'], $escapeSmarty); - - if ($contactID) { $mailContent['subject'] = CRM_Utils_Token::replaceContactTokens($mailContent['subject'], $contact, FALSE, $tokens['subject'], FALSE, $escapeSmarty); $mailContent['text'] = CRM_Utils_Token::replaceContactTokens($mailContent['text'], $contact, FALSE, $tokens['text'], FALSE, $escapeSmarty); $mailContent['html'] = CRM_Utils_Token::replaceContactTokens($mailContent['html'], $contact, FALSE, $tokens['html'], FALSE, $escapeSmarty);