From 6cd56230f4fb46c9509141ca9257b2fc68b73495 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 3 Dec 2022 15:11:49 +1300 Subject: [PATCH] Remove further usage of 'preferred_mail_format' --- .../Event/BAO/MailingEventResubscribe.php | 19 ++++++++----------- .../Event/BAO/MailingEventUnsubscribe.php | 19 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/CRM/Mailing/Event/BAO/MailingEventResubscribe.php b/CRM/Mailing/Event/BAO/MailingEventResubscribe.php index 55a94cfb25..be7637215b 100644 --- a/CRM/Mailing/Event/BAO/MailingEventResubscribe.php +++ b/CRM/Mailing/Event/BAO/MailingEventResubscribe.php @@ -213,7 +213,7 @@ class CRM_Mailing_Event_BAO_Resubscribe { $eq = new CRM_Core_DAO(); $eq->query( - "SELECT $contacts.preferred_mail_format as format, + "SELECT $contacts.id as contact_id, $email.email as email, $queue.hash as hash @@ -236,16 +236,13 @@ class CRM_Mailing_Event_BAO_Resubscribe { $tokens = $bao->getTokens(); $templates = $bao->getTemplates(); - if ($eq->format == 'HTML' || $eq->format == 'Both') { - $html = CRM_Utils_Token::replaceResubscribeTokens($templates['html'], $domain, $groups, TRUE, $eq->contact_id, $eq->hash); - $html = CRM_Utils_Token::replaceActionTokens($html, $addresses, $urls, TRUE, $tokens['html']); - $html = CRM_Utils_Token::replaceMailingTokens($html, $dao, NULL, $tokens['html']); - } - if (!$html || $eq->format == 'Text' || $eq->format == 'Both') { - $text = CRM_Utils_Token::replaceResubscribeTokens($templates['text'], $domain, $groups, FALSE, $eq->contact_id, $eq->hash); - $text = CRM_Utils_Token::replaceActionTokens($text, $addresses, $urls, FALSE, $tokens['text']); - $text = CRM_Utils_Token::replaceMailingTokens($text, $dao, NULL, $tokens['text']); - } + $html = CRM_Utils_Token::replaceResubscribeTokens($templates['html'], $domain, $groups, TRUE, $eq->contact_id, $eq->hash); + $html = CRM_Utils_Token::replaceActionTokens($html, $addresses, $urls, TRUE, $tokens['html']); + $html = CRM_Utils_Token::replaceMailingTokens($html, $dao, NULL, $tokens['html']); + + $text = CRM_Utils_Token::replaceResubscribeTokens($templates['text'], $domain, $groups, FALSE, $eq->contact_id, $eq->hash); + $text = CRM_Utils_Token::replaceActionTokens($text, $addresses, $urls, FALSE, $tokens['text']); + $text = CRM_Utils_Token::replaceMailingTokens($text, $dao, NULL, $tokens['text']); $tokenProcessor = new TokenProcessor(\Civi::dispatcher(), [ 'controller' => __CLASS__, diff --git a/CRM/Mailing/Event/BAO/MailingEventUnsubscribe.php b/CRM/Mailing/Event/BAO/MailingEventUnsubscribe.php index 574084caf3..7afd235ef4 100644 --- a/CRM/Mailing/Event/BAO/MailingEventUnsubscribe.php +++ b/CRM/Mailing/Event/BAO/MailingEventUnsubscribe.php @@ -376,7 +376,7 @@ WHERE email = %2 $eq = new CRM_Core_DAO(); $eq->query( - "SELECT $contacts.preferred_mail_format as format, + "SELECT $contacts.id as contact_id, $email.email as email, $queue.hash as hash @@ -402,16 +402,13 @@ WHERE email = %2 $tokens = $bao->getTokens(); $templates = $bao->getTemplates(); - if ($eq->format == 'HTML' || $eq->format == 'Both') { - $html = CRM_Utils_Token::replaceUnsubscribeTokens($templates['html'], $domain, $groups, TRUE, $eq->contact_id, $eq->hash); - $html = CRM_Utils_Token::replaceActionTokens($html, $addresses, $urls, TRUE, $tokens['html']); - $html = CRM_Utils_Token::replaceMailingTokens($html, $dao, NULL, $tokens['html']); - } - if (!$html || $eq->format == 'Text' || $eq->format == 'Both') { - $text = CRM_Utils_Token::replaceUnsubscribeTokens($templates['text'], $domain, $groups, FALSE, $eq->contact_id, $eq->hash); - $text = CRM_Utils_Token::replaceActionTokens($text, $addresses, $urls, FALSE, $tokens['text']); - $text = CRM_Utils_Token::replaceMailingTokens($text, $dao, NULL, $tokens['text']); - } + $html = CRM_Utils_Token::replaceUnsubscribeTokens($templates['html'], $domain, $groups, TRUE, $eq->contact_id, $eq->hash); + $html = CRM_Utils_Token::replaceActionTokens($html, $addresses, $urls, TRUE, $tokens['html']); + $html = CRM_Utils_Token::replaceMailingTokens($html, $dao, NULL, $tokens['html']); + + $text = CRM_Utils_Token::replaceUnsubscribeTokens($templates['text'], $domain, $groups, FALSE, $eq->contact_id, $eq->hash); + $text = CRM_Utils_Token::replaceActionTokens($text, $addresses, $urls, FALSE, $tokens['text']); + $text = CRM_Utils_Token::replaceMailingTokens($text, $dao, NULL, $tokens['text']); $tokenProcessor = new TokenProcessor(\Civi::dispatcher(), [ 'controller' => __CLASS__, -- 2.25.1