X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUpgrade%2FIncremental%2FBase.php;h=771ed8ad679391d8b20291436bbf027eaca6e7a2;hb=b998240f2331b6635fd99e9e280611ae40dba005;hp=8e2e8641f7471661bdf3c984ed0ae1bc905de931;hpb=50991431cfdc5a98179404d5d9ba3f2ecc445301;p=civicrm-core.git diff --git a/CRM/Upgrade/Incremental/Base.php b/CRM/Upgrade/Incremental/Base.php index 8e2e8641f7..771ed8ad67 100644 --- a/CRM/Upgrade/Incremental/Base.php +++ b/CRM/Upgrade/Incremental/Base.php @@ -68,17 +68,6 @@ class CRM_Upgrade_Incremental_Base { return $revList; } - /** - * Verify DB state. - * - * @param $errors - * - * @return bool - */ - public function verifyPreDBstate(&$errors) { - return TRUE; - } - /** * Compute any messages which should be displayed before upgrade. * @@ -264,12 +253,17 @@ class CRM_Upgrade_Incremental_Base { */ 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; } /** - * Updated a message token within a template. + * Updated a message token within a scheduled reminder. * * @param CRM_Queue_TaskContext $ctx * @param string $old @@ -284,6 +278,93 @@ class CRM_Upgrade_Incremental_Base { return TRUE; } + /** + * Updated a message token within a label. + * + * @param CRM_Queue_TaskContext $ctx + * @param string $old + * @param string $new + * @param $version + * + * @return bool + */ + public static function updatePrintLabelToken($ctx, string $old, string $new, $version):bool { + $messageObj = new CRM_Upgrade_Incremental_MessageTemplates($version); + $messageObj->replaceTokenInPrintLabel($old, $new); + return TRUE; + } + + /** + * Updated a message token within greeting options. + * + * @param CRM_Queue_TaskContext $ctx + * @param string $old + * @param string $new + * @param $version + * + * @return bool + */ + public static function updateGreetingOptions($ctx, string $old, string $new, $version):bool { + $messageObj = new CRM_Upgrade_Incremental_MessageTemplates($version); + $messageObj->replaceTokenInGreetingOptions($old, $new); + return TRUE; + } + + /** + * Updated a currency in civicrm_currency and related configurations + * + * @param CRM_Queue_TaskContext $ctx + * @param string $old_name + * @param string $new_name + * + * @return bool + */ + public static function updateCurrencyName($ctx, string $old_name, string $new_name): bool { + CRM_Core_DAO::executeQuery('UPDATE civicrm_currency SET name = %1 WHERE name = %2', [ + 1 => [$new_name, 'String'], + 2 => [$old_name, 'String'], + ]); + + $oid = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_option_group WHERE name = 'currencies_enabled'"); + if ($oid) { + CRM_Core_DAO::executeQuery('UPDATE civicrm_option_value SET value = %1 WHERE value = %2 AND option_group_id = %3', [ + 1 => [$new_name, 'String'], + 2 => [$old_name, 'String'], + 3 => [$oid, 'String'], + ]); + } + + CRM_Core_DAO::executeQuery('UPDATE civicrm_participant SET fee_currency = %1 WHERE fee_currency = %2', [ + 1 => [$new_name, 'String'], + 2 => [$old_name, 'String'], + ]); + + $tables = [ + 'civicrm_contribution', + 'civicrm_contribution_page', + 'civicrm_contribution_recur', + 'civicrm_contribution_soft', + 'civicrm_event', + 'civicrm_financial_item', + 'civicrm_financial_trxn', + 'civicrm_grant', + 'civicrm_pcp', + 'civicrm_pledge_payment', + 'civicrm_pledge', + 'civicrm_product', + ]; + + foreach ($tables as $table) { + CRM_Core_DAO::executeQuery('UPDATE %3 SET currency = %1 WHERE currency = %2', [ + 1 => [$new_name, 'String'], + 2 => [$old_name, 'String'], + 3 => [$table, 'MysqlColumnNameOrAlias'], + ]); + } + + return TRUE; + } + /** * Re-save any valid values from contribute settings into the normal setting * format.