From cac0fcc6294dcd468bfb7866b143644acd513755 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 3 Sep 2021 19:11:03 +1200 Subject: [PATCH] Remove deprecated function It was deprecated in 5.35 (and never supported to be called from outside of core) --- CRM/Core/BAO/MessageTemplate.php | 121 ------------------------------- 1 file changed, 121 deletions(-) diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index 6d9aced734..0fa7c268e3 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -212,127 +212,6 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { return $msgTpls; } - /** - * @param int $contactId - * @param $email - * @param int $messageTemplateID - * @param $from - * - * @return bool|NULL - * @throws \CRM_Core_Exception - */ - public static function sendReminder($contactId, $email, $messageTemplateID, $from) { - CRM_Core_Error::deprecatedWarning('CRM_Core_BAO_MessageTemplate::sendReminder is deprecated and will be removed in a future version of CiviCRM'); - - $messageTemplates = new CRM_Core_DAO_MessageTemplate(); - $messageTemplates->id = $messageTemplateID; - - $domain = CRM_Core_BAO_Domain::getDomain(); - $result = NULL; - $hookTokens = []; - - if ($messageTemplates->find(TRUE)) { - $body_text = $messageTemplates->msg_text; - $body_html = $messageTemplates->msg_html; - $body_subject = $messageTemplates->msg_subject; - if (!$body_text) { - $body_text = CRM_Utils_String::htmlToText($body_html); - } - - $params = [['contact_id', '=', $contactId, 0, 0]]; - [$contact] = CRM_Contact_BAO_Query::apiQuery($params); - - //CRM-4524 - $contact = reset($contact); - - if (!$contact || is_a($contact, 'CRM_Core_Error')) { - return NULL; - } - - //CRM-5734 - - // get tokens to be replaced - $tokens = array_merge(CRM_Utils_Token::getTokens($body_text), - CRM_Utils_Token::getTokens($body_html), - CRM_Utils_Token::getTokens($body_subject)); - - // get replacement text for these tokens - $returnProperties = ["preferred_mail_format" => 1]; - if (isset($tokens['contact'])) { - foreach ($tokens['contact'] as $key => $value) { - $returnProperties[$value] = 1; - } - } - [$details] = CRM_Utils_Token::getTokenDetails([$contactId], - $returnProperties, - NULL, NULL, FALSE, - $tokens, - 'CRM_Core_BAO_MessageTemplate'); - $contact = reset($details); - - // call token hook - $hookTokens = []; - CRM_Utils_Hook::tokens($hookTokens); - $categories = array_keys($hookTokens); - - // do replacements in text and html body - $type = ['html', 'text']; - foreach ($type as $key => $value) { - $bodyType = "body_{$value}"; - if ($$bodyType) { - CRM_Utils_Token::replaceGreetingTokens($$bodyType, NULL, $contact['contact_id']); - $$bodyType = CRM_Utils_Token::replaceDomainTokens($$bodyType, $domain, TRUE, $tokens, TRUE); - $$bodyType = CRM_Utils_Token::replaceContactTokens($$bodyType, $contact, FALSE, $tokens, FALSE, TRUE); - $$bodyType = CRM_Utils_Token::replaceComponentTokens($$bodyType, $contact, $tokens, TRUE); - $$bodyType = CRM_Utils_Token::replaceHookTokens($$bodyType, $contact, $categories, TRUE); - } - } - $html = $body_html; - $text = $body_text; - - $smarty = CRM_Core_Smarty::singleton(); - foreach ([ - 'text', - 'html', - ] as $elem) { - $$elem = $smarty->fetch("string:{$$elem}"); - } - - // do replacements in message subject - $messageSubject = CRM_Utils_Token::replaceContactTokens($body_subject, $contact, FALSE, $tokens); - $messageSubject = CRM_Utils_Token::replaceDomainTokens($messageSubject, $domain, TRUE, $tokens); - $messageSubject = CRM_Utils_Token::replaceComponentTokens($messageSubject, $contact, $tokens, TRUE); - $messageSubject = CRM_Utils_Token::replaceHookTokens($messageSubject, $contact, $categories, TRUE); - - $messageSubject = $smarty->fetch("string:{$messageSubject}"); - - // set up the parameters for CRM_Utils_Mail::send - $mailParams = [ - 'groupName' => 'Scheduled Reminder Sender', - 'from' => $from, - 'toName' => $contact['display_name'], - 'toEmail' => $email, - 'subject' => $messageSubject, - ]; - if (!$html || $contact['preferred_mail_format'] == 'Text' || - $contact['preferred_mail_format'] == 'Both' - ) { - // render the & entities in text mode, so that the links work - $mailParams['text'] = str_replace('&', '&', $text); - } - if ($html && ($contact['preferred_mail_format'] == 'HTML' || - $contact['preferred_mail_format'] == 'Both' - ) - ) { - $mailParams['html'] = $html; - } - - $result = CRM_Utils_Mail::send($mailParams); - } - - return $result; - } - /** * Revert a message template to its default subject+text+HTML state. * -- 2.25.1