*/
public static function updateMessageToken($ctx, string $workflowName, string $old, string $new, $version):bool {
$messageObj = new CRM_Upgrade_Incremental_MessageTemplates($version);
- $messageObj->replaceTokenInTemplate($workflowName, $old, $new);
+ if (!empty($workflowName)) {
+ $messageObj->replaceTokenInTemplate($workflowName, $old, $new);
+ }
+ else {
+ $messageObj->replaceTokenInMessageTemplates($old, $new);
+ }
return TRUE;
}
");
}
+ /**
+ * Replace a token with the new preferred option in non-workflow templates.
+ *
+ * @param string $old
+ * @param string $new
+ */
+ public function replaceTokenInMessageTemplates(string $old, string $new): void {
+ $oldToken = '{' . $old . '}';
+ $newToken = '{' . $new . '}';
+ CRM_Core_DAO::executeQuery("UPDATE civicrm_msg_template
+ SET
+ msg_text = REPLACE(msg_text, '$oldToken', '$newToken'),
+ msg_subject = REPLACE(msg_subject, '$oldToken', '$newToken'),
+ msg_html = REPLACE(msg_html, '$oldToken', '$newToken')
+ WHERE workflow_name IS NULL
+ ");
+ }
+
/**
* Replace a token with the new preferred option.
*
$this->addTask('Update participant registered by id token in event badges',
'updatePrintLabelToken', 'participant.participant_registered_by_id', 'participant.registered_by_id', $rev
);
-
+ $this->addTask('Update contribution status token in saved message templates',
+ 'updateMessageToken', '', 'contribution.contribution_status', 'contribution.contribution_status_id:label', $rev
+ );
+ $this->addTask('Update campaign token in saved message templates',
+ 'updateMessageToken', '', 'contribution.campaign', 'contribution.campaign_id:label', $rev
+ );
}
/**