From 71cdd8fb92a7d9ae3da66ed3114969ae402391ec Mon Sep 17 00:00:00 2001 From: Michael McAndrew <michaelmcandrew@thirdsectordesign.org> Date: Fri, 27 Jan 2023 15:24:43 +0000 Subject: [PATCH] Add setting to disable Smarty in scheduled reminders dev/core#4100 --- CRM/Admin/Form/Preferences/Mailing.php | 1 + CRM/Core/BAO/ActionSchedule.php | 2 +- CRM/Upgrade/Incremental/php/FiveSixty.php | 12 ++++++++++++ settings/Mailing.setting.php | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CRM/Admin/Form/Preferences/Mailing.php b/CRM/Admin/Form/Preferences/Mailing.php index 726a31dd4e2..23cc19a9b8c 100644 --- a/CRM/Admin/Form/Preferences/Mailing.php +++ b/CRM/Admin/Form/Preferences/Mailing.php @@ -35,6 +35,7 @@ class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences { 'auto_recipient_rebuild' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'url_tracking_default' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'open_tracking_default' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, + 'scheduled_reminder_smarty' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, ]; public function postProcess() { diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 04c08c59a08..8307501bb60 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -631,7 +631,7 @@ FROM civicrm_action_schedule cas 'controller' => __CLASS__, 'actionSchedule' => $schedule, 'actionMapping' => $mapping, - 'smarty' => TRUE, + 'smarty' => Civi::settings()->get('scheduled_reminder_smarty'), 'schema' => ['contactId'], ]); $tp->addMessage('body_text', $schedule->body_text, 'text/plain'); diff --git a/CRM/Upgrade/Incremental/php/FiveSixty.php b/CRM/Upgrade/Incremental/php/FiveSixty.php index 977d68b0778..e9a690896cd 100644 --- a/CRM/Upgrade/Incremental/php/FiveSixty.php +++ b/CRM/Upgrade/Incremental/php/FiveSixty.php @@ -29,6 +29,18 @@ class CRM_Upgrade_Incremental_php_FiveSixty extends CRM_Upgrade_Incremental_Base */ public function upgrade_5_60_alpha1($rev): void { $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); + $this->addTask('Add scheduled_reminder_smarty setting', 'addScheduledReminderSmartySetting'); + } + + public function setPostUpgradeMessage(&$postUpgradeMessage, $rev): void { + if ($rev === '5.60.alpha1') { + $postUpgradeMessage .= '<p>' . ts('You can now choose whether to use Smarty in Scheduled Reminders at <em>Administer >> CiviMail >> CiviMail Component Settings</em>. The setting is disabled by default on new installations but we have enabled it during this upgrade to preserve the existing behavior. More information <a %1>in this lab ticket</a>.', [1 => 'href="https://lab.civicrm.org/dev/core/-/issues/4100" target="_blank"']) . '<p>'; + } + } + + public static function addScheduledReminderSmartySetting(): bool { + Civi::settings()->set('scheduled_reminder_smarty', TRUE); + return TRUE; } } diff --git a/settings/Mailing.setting.php b/settings/Mailing.setting.php index 97904cad54e..434e78a7ee3 100644 --- a/settings/Mailing.setting.php +++ b/settings/Mailing.setting.php @@ -393,4 +393,18 @@ return [ 'description' => ts('The frequency that CiviMail updates its sent mail database.'), 'help_text' => NULL, ], + 'scheduled_reminder_smarty' => [ + 'group_name' => 'Mailing Preferences', + 'group' => 'mailing', + 'name' => 'scheduled_reminder_smarty', + 'type' => 'Boolean', + 'html_type' => 'checkbox', + 'default' => 0, + 'title' => ts('Use Smarty in scheduled reminders'), + 'add' => '5.60', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => ts('Controls whether scheduled reminders will attempt to process smarty tokens.'), + 'help_text' => NULL, + ], ]; -- GitLab