From 4c257e173ba1ed08f29abeba0c21636cf5a26f22 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 8 Apr 2019 10:16:10 +1200 Subject: [PATCH] Update new payment_processor.title field to be localisable Re-order upgrade to fix upgrade process and ensure there is the runSql step --- CRM/Core/I18n/SchemaStructure.php | 8 + CRM/Core/I18n/SchemaStructure_5_13_alpha1.php | 722 ++++++++++++++++++ CRM/Financial/DAO/PaymentProcessor.php | 6 +- CRM/Upgrade/Incremental/php/FiveThirteen.php | 7 +- CRM/Upgrade/Incremental/php/FourThree.php | 2 +- xml/schema/Financial/PaymentProcessor.xml | 1 + 6 files changed, 739 insertions(+), 7 deletions(-) create mode 100644 CRM/Core/I18n/SchemaStructure_5_13_alpha1.php diff --git a/CRM/Core/I18n/SchemaStructure.php b/CRM/Core/I18n/SchemaStructure.php index bec6ec355e..5bc0a76f01 100644 --- a/CRM/Core/I18n/SchemaStructure.php +++ b/CRM/Core/I18n/SchemaStructure.php @@ -129,6 +129,9 @@ class CRM_Core_I18n_SchemaStructure { 'description' => "text", 'options' => "text", ], + 'civicrm_payment_processor' => [ + 'title' => "varchar(127)", + ], 'civicrm_membership_type' => [ 'name' => "varchar(128)", 'description' => "varchar(255)", @@ -486,6 +489,11 @@ class CRM_Core_I18n_SchemaStructure { 'type' => "Text", ], ], + 'civicrm_payment_processor' => [ + 'title' => [ + 'type' => "Text", + ], + ], 'civicrm_membership_type' => [ 'name' => [ 'type' => "Text", diff --git a/CRM/Core/I18n/SchemaStructure_5_13_alpha1.php b/CRM/Core/I18n/SchemaStructure_5_13_alpha1.php new file mode 100644 index 0000000000..2daed95568 --- /dev/null +++ b/CRM/Core/I18n/SchemaStructure_5_13_alpha1.php @@ -0,0 +1,722 @@ + [ + 'display_name' => "varchar(64)", + ], + 'civicrm_option_group' => [ + 'title' => "varchar(255)", + 'description' => "varchar(255)", + ], + 'civicrm_relationship_type' => [ + 'label_a_b' => "varchar(64)", + 'label_b_a' => "varchar(64)", + 'description' => "varchar(255)", + ], + 'civicrm_contact_type' => [ + 'label' => "varchar(64)", + 'description' => "text", + ], + 'civicrm_batch' => [ + 'title' => "varchar(255)", + 'description' => "text", + ], + 'civicrm_premiums' => [ + 'premiums_intro_title' => "varchar(255)", + 'premiums_intro_text' => "text", + 'premiums_nothankyou_label' => "varchar(255)", + ], + 'civicrm_membership_status' => [ + 'label' => "varchar(128)", + ], + 'civicrm_survey' => [ + 'title' => "varchar(255)", + 'instructions' => "text", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + ], + 'civicrm_participant_status_type' => [ + 'label' => "varchar(255)", + ], + 'civicrm_case_type' => [ + 'title' => "varchar(64)", + 'description' => "varchar(255)", + ], + 'civicrm_tell_friend' => [ + 'title' => "varchar(255)", + 'intro' => "text", + 'suggested_message' => "text", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + ], + 'civicrm_custom_group' => [ + 'title' => "varchar(64)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_custom_field' => [ + 'label' => "varchar(255)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_option_value' => [ + 'label' => "varchar(512)", + 'description' => "text", + ], + 'civicrm_group' => [ + 'title' => "varchar(64)", + ], + 'civicrm_contribution_page' => [ + 'title' => "varchar(255)", + 'intro_text' => "text", + 'pay_later_text' => "text", + 'pay_later_receipt' => "text", + 'initial_amount_label' => "varchar(255)", + 'initial_amount_help_text' => "text", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + 'thankyou_footer' => "text", + 'receipt_from_name' => "varchar(255)", + 'receipt_text' => "text", + 'footer_text' => "text", + ], + 'civicrm_product' => [ + 'name' => "varchar(255)", + 'description' => "text", + 'options' => "text", + ], + 'civicrm_payment_processor' => [ + 'title' => "varchar(127)", + ], + 'civicrm_membership_type' => [ + 'name' => "varchar(128)", + 'description' => "varchar(255)", + ], + 'civicrm_membership_block' => [ + 'new_title' => "varchar(255)", + 'new_text' => "text", + 'renewal_title' => "varchar(255)", + 'renewal_text' => "text", + ], + 'civicrm_price_set' => [ + 'title' => "varchar(255)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_dashboard' => [ + 'label' => "varchar(255)", + ], + 'civicrm_uf_group' => [ + 'title' => "varchar(64)", + 'frontend_title' => "varchar(64)", + 'help_pre' => "text", + 'help_post' => "text", + 'cancel_button_text' => "varchar(64)", + 'submit_button_text' => "varchar(64)", + ], + 'civicrm_uf_field' => [ + 'help_post' => "text", + 'help_pre' => "text", + 'label' => "varchar(255)", + ], + 'civicrm_price_field' => [ + 'label' => "varchar(255)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_price_field_value' => [ + 'label' => "varchar(255)", + 'description' => "text", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_pcp_block' => [ + 'link_text' => "varchar(255)", + ], + 'civicrm_event' => [ + 'title' => "varchar(255)", + 'summary' => "text", + 'description' => "text", + 'registration_link_text' => "varchar(255)", + 'event_full_text' => "text", + 'fee_label' => "varchar(255)", + 'intro_text' => "text", + 'footer_text' => "text", + 'confirm_title' => "varchar(255)", + 'confirm_text' => "text", + 'confirm_footer_text' => "text", + 'confirm_email_text' => "text", + 'confirm_from_name' => "varchar(255)", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + 'thankyou_footer_text' => "text", + 'pay_later_text' => "text", + 'pay_later_receipt' => "text", + 'initial_amount_label' => "varchar(255)", + 'initial_amount_help_text' => "text", + 'waitlist_text' => "text", + 'approval_req_text' => "text", + 'template_title' => "varchar(255)", + ], + ]; + } + return $result; + } + + /** + * Get a table indexed array of the indices for translatable fields. + * + * @return array + * Indices for translatable fields. + */ + public static function &indices() { + static $result = NULL; + if (!$result) { + $result = [ + 'civicrm_custom_group' => [ + 'UI_title_extends' => [ + 'name' => 'UI_title_extends', + 'field' => [ + 'title', + 'extends', + ], + 'unique' => 1, + ], + ], + 'civicrm_custom_field' => [ + 'UI_label_custom_group_id' => [ + 'name' => 'UI_label_custom_group_id', + 'field' => [ + 'label', + 'custom_group_id', + ], + 'unique' => 1, + ], + ], + 'civicrm_group' => [ + 'UI_title' => [ + 'name' => 'UI_title', + 'field' => [ + 'title', + ], + 'unique' => 1, + ], + ], + ]; + } + return $result; + } + + /** + * Get tables with translatable fields. + * + * @return array + * Array of names of tables with fields that can be translated. + */ + public static function &tables() { + static $result = NULL; + if (!$result) { + $result = array_keys(self::columns()); + } + return $result; + } + + /** + * Get a list of widgets for editing translatable fields. + * + * @return array + * Array of the widgets for editing translatable fields. + */ + public static function &widgets() { + static $result = NULL; + if (!$result) { + $result = [ + 'civicrm_location_type' => [ + 'display_name' => [ + 'type' => "Text", + ], + ], + 'civicrm_option_group' => [ + 'title' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_relationship_type' => [ + 'label_a_b' => [ + 'type' => "Text", + ], + 'label_b_a' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_contact_type' => [ + 'label' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + ], + 'civicrm_batch' => [ + 'title' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_premiums' => [ + 'premiums_intro_title' => [ + 'type' => "Text", + ], + 'premiums_intro_text' => [ + 'type' => "Text", + ], + 'premiums_nothankyou_label' => [ + 'type' => "Text", + ], + ], + 'civicrm_membership_status' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_survey' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'instructions' => [ + 'type' => "TextArea", + 'rows' => "20", + 'cols' => "80", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + ], + 'civicrm_participant_status_type' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_case_type' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_tell_friend' => [ + 'title' => [ + 'type' => "Text", + ], + 'intro' => [ + 'type' => "Text", + ], + 'suggested_message' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_custom_group' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_custom_field' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "Text", + ], + 'help_post' => [ + 'type' => "Text", + ], + ], + 'civicrm_option_value' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + ], + 'civicrm_group' => [ + 'title' => [ + 'type' => "Text", + ], + ], + 'civicrm_contribution_page' => [ + 'title' => [ + 'type' => "Text", + ], + 'intro_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'pay_later_text' => [ + 'type' => "Text", + ], + 'pay_later_receipt' => [ + 'type' => "Text", + ], + 'initial_amount_label' => [ + 'type' => "Text", + ], + 'initial_amount_help_text' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "RichTextEditor", + 'rows' => "8", + 'cols' => "60", + ], + 'thankyou_footer' => [ + 'type' => "RichTextEditor", + 'rows' => "8", + 'cols' => "60", + ], + 'receipt_from_name' => [ + 'type' => "Text", + ], + 'receipt_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'footer_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + ], + 'civicrm_product' => [ + 'name' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "Text", + ], + 'options' => [ + 'type' => "Text", + ], + ], + 'civicrm_payment_processor' => [ + 'title' => [ + 'type' => "Text", + ], + ], + 'civicrm_membership_type' => [ + 'name' => [ + 'type' => "Text", + 'label' => "Name", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + 'label' => "Description", + ], + ], + 'civicrm_membership_block' => [ + 'new_title' => [ + 'type' => "Text", + ], + 'new_text' => [ + 'type' => "Text", + ], + 'renewal_title' => [ + 'type' => "Text", + ], + 'renewal_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_price_set' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_dashboard' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_uf_group' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'frontend_title' => [ + 'type' => "Text", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'cancel_button_text' => [ + 'type' => "Text", + ], + 'submit_button_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_uf_field' => [ + 'help_post' => [ + 'type' => "Text", + ], + 'help_pre' => [ + 'type' => "Text", + ], + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + ], + 'civicrm_price_field' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_price_field_value' => [ + 'label' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + ], + 'civicrm_pcp_block' => [ + 'link_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_event' => [ + 'title' => [ + 'type' => "Text", + ], + 'summary' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + 'registration_link_text' => [ + 'type' => "Text", + ], + 'event_full_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'fee_label' => [ + 'type' => "Text", + ], + 'intro_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'footer_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_title' => [ + 'type' => "Text", + ], + 'confirm_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_footer_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_email_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "50", + ], + 'confirm_from_name' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'thankyou_footer_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'pay_later_text' => [ + 'type' => "Text", + ], + 'pay_later_receipt' => [ + 'type' => "Text", + ], + 'initial_amount_label' => [ + 'type' => "Text", + ], + 'initial_amount_help_text' => [ + 'type' => "Text", + ], + 'waitlist_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'approval_req_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'template_title' => [ + 'type' => "Text", + ], + ], + ]; + } + return $result; + } + +} diff --git a/CRM/Financial/DAO/PaymentProcessor.php b/CRM/Financial/DAO/PaymentProcessor.php index 2c8bcffc34..eccbc23fc1 100644 --- a/CRM/Financial/DAO/PaymentProcessor.php +++ b/CRM/Financial/DAO/PaymentProcessor.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Financial/PaymentProcessor.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:42c6dc8a71daeb67aaa687156121ebf4) + * (GenCodeChecksum:83f0467b531d70e84945e9c55a8824b6) */ /** @@ -254,7 +254,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { 'table_name' => 'civicrm_payment_processor', 'entity' => 'PaymentProcessor', 'bao' => 'CRM_Financial_BAO_PaymentProcessor', - 'localizable' => 0, + 'localizable' => 1, 'html' => [ 'type' => 'Text', ], @@ -523,7 +523,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { * @return string */ public static function getTableName() { - return self::$_tableName; + return CRM_Core_DAO::getLocaleTableName(self::$_tableName); } /** diff --git a/CRM/Upgrade/Incremental/php/FiveThirteen.php b/CRM/Upgrade/Incremental/php/FiveThirteen.php index 5bfafc9e97..22078f3732 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirteen.php +++ b/CRM/Upgrade/Incremental/php/FiveThirteen.php @@ -74,12 +74,13 @@ class CRM_Upgrade_Incremental_php_FiveThirteen extends CRM_Upgrade_Incremental_B * @param string $rev */ public function upgrade_5_13_alpha1($rev) { + $this->addTask('Add title to civicrm_payment_processor', 'addColumn', + 'civicrm_payment_processor', 'title', "text COMMENT 'Payment Processor Descriptive Name.'", TRUE, '5.13.alpha1' + ); $this->addTask('Add cancel reason column to civicrm_contribution_recur', 'addColumn', 'civicrm_contribution_recur', 'cancel_reason', "text COMMENT 'Free text field for a reason for cancelling'", FALSE ); - $this->addTask('Add title to civicrm_payment_processor', 'addColumn', - 'civicrm_payment_processor', 'title', "text COMMENT 'Payment Processor Descriptive Name.'", FALSE - ); + $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); } } diff --git a/CRM/Upgrade/Incremental/php/FourThree.php b/CRM/Upgrade/Incremental/php/FourThree.php index fe264d9577..a444e4962b 100644 --- a/CRM/Upgrade/Incremental/php/FourThree.php +++ b/CRM/Upgrade/Incremental/php/FourThree.php @@ -92,7 +92,7 @@ WHERE {$key}.id IS NULL"; if ($value != 'contact_id') { $query .= " AND contri_recur.{$value} IS NOT NULL "; } - $dao = CRM_Core_DAO::executeQuery($query); + $dao = CRM_Core_DAO::executeQuery($query, [], TRUE, NULL, FALSE, FALSE); if ($dao->N) { $invalidDataMessage = 'Oops, it looks like you have orphaned recurring contribution records in your database. Before this upgrade can complete they will need to be fixed or deleted. You can review steps to correct this situation on the documentation wiki.'; CRM_Core_Error::fatal($invalidDataMessage); diff --git a/xml/schema/Financial/PaymentProcessor.xml b/xml/schema/Financial/PaymentProcessor.xml index ceeba6b0ad..76d1ef13be 100644 --- a/xml/schema/Financial/PaymentProcessor.xml +++ b/xml/schema/Financial/PaymentProcessor.xml @@ -52,6 +52,7 @@ Payment Processor Title varchar 127 + true Text -- 2.25.1