OptionGroup - Update some descriptions and fix multilingual upgrader
authorColeman Watts <coleman@civicrm.org>
Wed, 14 Dec 2022 15:18:59 +0000 (10:18 -0500)
committerColeman Watts <coleman@civicrm.org>
Wed, 14 Dec 2022 15:18:59 +0000 (10:18 -0500)
CRM/Upgrade/Incremental/php/FiveFiftyEight.php
xml/templates/civicrm_data.tpl

index e8c12fb88429be3905a8c098fef9b35bc063238b..d43eb95d60adddc70715202c052ff963ae76ebcf 100644 (file)
@@ -33,59 +33,67 @@ class CRM_Upgrade_Incremental_php_FiveFiftyEight extends CRM_Upgrade_Incremental
   }
 
   public static function addOptionGroupDescriptions($ctx): bool {
-    CRM_Core_DAO::executeQuery('ALTER TABLE `civicrm_option_group` MODIFY COLUMN `description` TEXT');
+    $locales = CRM_Core_I18n::getMultilingual();
+    if ($locales) {
+      foreach ($locales as $locale) {
+        CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_option_group` CHANGE `description_{$locale}` `description_{$locale}` TEXT COMMENT 'Option group description.'", [], TRUE, NULL, FALSE, FALSE);
+      }
+    }
+    else {
+      CRM_Core_DAO::executeQuery('ALTER TABLE `civicrm_option_group` MODIFY COLUMN `description` TEXT', [], TRUE, NULL, FALSE, FALSE);
+    }
     $values = [
       [
         'group' => 'gender',
-        'description' => '{ts escape="sql"}CiviCRM is pre-configured with standard options for individual gender (Male, Female, Other). Modify these options as needed for your installation.{/ts}',
+        'description' => ts('CiviCRM is pre-configured with standard options for individual gender (Male, Female, Other). Modify these options as needed for your installation.'),
       ],
       [
         'group' => 'individual_prefix',
-        'description' => '{ts escape="sql"}CiviCRM is pre-configured with standard options for individual contact prefixes (Ms., Mr., Dr. etc.). Customize these options and add new ones as needed for your installation.{/ts}',
+        'description' => ts('CiviCRM is pre-configured with standard options for individual contact prefixes (Ms., Mr., Dr. etc.). Customize these options and add new ones as needed for your installation.'),
       ],
       [
         'group' => 'mobile_provider',
-        'description' => '{ts escape="sql"}When recording mobile phone numbers for contacts, it may be useful to include the Mobile Phone Service Provider (e.g. Cingular, Sprint, etc.). CiviCRM is installed with the most commonly encountered service providers. Administrators may define as many additional providers as needed.{/ts}',
+        'description' => ts('When recording mobile phone numbers for contacts, it may be useful to include the Mobile Phone Service Provider (e.g. Cingular, Sprint, etc.). CiviCRM is installed with the most commonly encountered service providers. Administrators may define as many additional providers as needed.'),
       ],
       [
         'group' => 'instant_messenger_service',
-        'description' => '{ts escape="sql"}When recording Instant Messenger (IM) \'screen names\' for contacts, it is useful to include the IM Service Provider (e.g. AOL, Yahoo, etc.). CiviCRM is installed with the most commonly encountered service providers. Administrators may define as many additional providers as needed.{/ts}',
+        'description' => ts('Commonly-used messaging apps are listed here. Administrators may define as many additional providers as needed.'),
       ],
       [
         'group' => 'individual_suffix',
-        'description' => '{ts escape="sql"}CiviCRM is pre-configured with standard options for individual contact name suffixes (Jr., Sr., II etc.). Customize these options and add new ones as needed for your installation.{/ts}',
+        'description' => ts('CiviCRM is pre-configured with standard options for individual contact name suffixes (Jr., Sr., II etc.). Customize these options and add new ones as needed for your installation.'),
       ],
       [
         'group' => 'activity_type',
-        'description' => '{ts escape="sql"}Activities are \'interactions with contacts\' which you want to record and track. This list is sorted by component and then by weight within the component.{/ts}',
+        'description' => ts('Activities track interactions with contacts. Some activity types are reserved for use by automated processes, others can be freely configured.'),
       ],
       [
         'group' => 'payment_instrument',
-        'description' => '{ts escape="sql"}You may choose to record the payment method used for each contribution and fee. Reserved payment methods are required - you may modify their labels but they can not be deleted (e.g. Check, Credit Card, Debit Card). If your site requires additional payment methods, you can add them here. You can associate each payment method with a Financial Account which specifies where the payment is going (e.g. a bank account for checks and cash).{/ts}',
+        'description' => ts('You may choose to record the payment method used for each contribution and fee. Reserved payment methods are required - you may modify their labels but they can not be deleted (e.g. Check, Credit Card, Debit Card). If your site requires additional payment methods, you can add them here. You can associate each payment method with a Financial Account which specifies where the payment is going (e.g. a bank account for checks and cash).'),
       ],
       [
         'group' => 'accept_creditcard',
-        'description' => '{ts escape="sql"}The following credit card options will be offered to contributors using Online Contribution pages. You will need to verify which cards are accepted by your chosen Payment Processor and update these entries accordingly.{/ts}<br /><br />'
-        . '{ts escape="sql"}IMPORTANT: This page does NOT control credit card/payment method choices for sites and/or contributors using the PayPal Express service (e.g. where billing information is collected on the Payment Processor\'s website).{/ts}',
+        'description' => ts('The following credit card options will be offered to contributors using Online Contribution pages. You will need to verify which cards are accepted by your chosen Payment Processor and update these entries accordingly.')
+        . ts('IMPORTANT: These options do not control credit card/payment method choices for sites and/or contributors using the PayPal Express service (e.g. where billing information is collected on the Payment Processor\'s website).'),
       ],
       [
         'group' => 'event_type',
-        'description' => '{ts escape="sql"}Use Event Types to categorize your events. Event feeds can be filtered by Event Type and participant searches can use Event Type as a criteria.{/ts}',
+        'description' => ts('Use Event Types to categorize your events. Event feeds can be filtered by Event Type and participant searches can use Event Type as a criteria.'),
       ],
       [
         'group' => 'participant_role',
-        'description' => '{ts escape="sql"}Define participant roles for events here (e.g. Attendee, Host, Speaker...). You can then assign roles and search for participants by role.{/ts}',
+        'description' => ts('Define participant roles for events here (e.g. Attendee, Host, Speaker...). You can then assign roles and search for participants by role.'),
       ],
       [
         'group' => 'from_email_address',
-        'description' => '{ts escape="sql"}By default, CiviCRM uses the primary email address of the logged in user as the FROM address when sending emails to contacts. However, you can use this page to define one or more general Email Addresses that can be selected as an alternative. EXAMPLE: <em>"Client Services" &lt;clientservices@example.org&gt;</em>{/ts}',
+        'description' => ts('By default, CiviCRM uses the primary email address of the logged in user as the FROM address when sending emails to contacts. However, you can use this page to define one or more general Email Addresses that can be selected as an alternative. EXAMPLE: "Client Services" <clientservices@example.org>.'),
       ],
     ];
     foreach ($values as $value) {
-      CRM_Core_DAO::executeQuery('UPDATE `civicrm_option_group` SET `description` = %1 WHERE `name` = %2', [
-        1 => [$value['description'], 'String'],
-        2 => [$value['group'], 'String'],
-      ]);
+      \Civi\Api4\OptionGroup::update(FALSE)
+        ->addWhere('name', '=', $value['group'])
+        ->addValue('description', $value['description'])
+        ->execute();
     }
     return TRUE;
   }
index b3b40fc40aa1008189a44911324d94d95129ff47..314897d60350ff0c9f8c2741067908a812d52fb5 100644 (file)
@@ -123,11 +123,11 @@ INSERT INTO
 VALUES
    ('preferred_communication_method', '{ts escape="sql"}Preferred Communication Method{/ts}'     , NULL,      1, 1, 0, 'name,label,description', NULL),
    ('activity_type'                 , '{ts escape="sql"}Activity Type{/ts}'                      , 'Integer', 1, 1, 0, 'name,label,description,icon',
-     '{ts escape="sql"}Activities are \'interactions with contacts\' which you want to record and track. This list is sorted by component and then by weight within the component.{/ts}'),
+     '{ts escape="sql"}Activities track interactions with contacts. Some activity types are reserved for use by automated processes, others can be freely configured.{/ts}'),
    ('gender'                        , '{ts escape="sql"}Gender{/ts}'                             , 'Integer', 1, 1, 0, 'name,label,description',
      '{ts escape="sql"}CiviCRM is pre-configured with standard options for individual gender (Male, Female, Other). Modify these options as needed for your installation.{/ts}'),
    ('instant_messenger_service'     , '{ts escape="sql"}Instant Messenger (IM) screen-names{/ts}', NULL,      1, 1, 0, 'name,label,description',
-     '{ts escape="sql"}When recording Instant Messenger (IM) \'screen names\' for contacts, it is useful to include the IM Service Provider (e.g. AOL, Yahoo, etc.). CiviCRM is installed with the most commonly encountered service providers. Administrators may define as many additional providers as needed.{/ts}'),
+     '{ts escape="sql"}Commonly-used messaging apps are listed here. Administrators may define as many additional providers as needed.{/ts}'),
    ('mobile_provider'               , '{ts escape="sql"}Mobile Phone Providers{/ts}'             , NULL,      1, 1, 0, 'name,label,description',
      '{ts escape="sql"}When recording mobile phone numbers for contacts, it may be useful to include the Mobile Phone Service Provider (e.g. Cingular, Sprint, etc.). CiviCRM is installed with the most commonly encountered service providers. Administrators may define as many additional providers as needed.{/ts}'),
    ('individual_prefix'             , '{ts escape="sql"}Individual contact prefixes{/ts}'        , NULL,      1, 1, 0, 'name,label,description',
@@ -136,7 +136,7 @@ VALUES
      '{ts escape="sql"}CiviCRM is pre-configured with standard options for individual contact name suffixes (Jr., Sr., II etc.). Customize these options and add new ones as needed for your installation.{/ts}'),
    ('acl_role'                      , '{ts escape="sql"}ACL Role{/ts}'                           , NULL,      1, 1, 0, 'name,label,description', NULL),
    ('accept_creditcard'             , '{ts escape="sql"}Accepted Credit Cards{/ts}'              , NULL,      1, 1, 0, 'name,label,description',
-     '{ts escape="sql"}The following credit card options will be offered to contributors using Online Contribution pages. You will need to verify which cards are accepted by your chosen Payment Processor and update these entries accordingly.{/ts}<br /><br />{ts escape="sql"}IMPORTANT: This page does NOT control credit card/payment method choices for sites and/or contributors using the PayPal Express service (e.g. where billing information is collected on the Payment Processor\'s website).{/ts}'),
+     '{ts escape="sql"}The following credit card options will be offered to contributors using Online Contribution pages. You will need to verify which cards are accepted by your chosen Payment Processor and update these entries accordingly.{/ts}{ts escape="sql"}IMPORTANT: These options do not control credit card/payment method choices for sites and/or contributors using the PayPal Express service (e.g. where billing information is collected on the Payment Processor\'s website).{/ts}'),
    ('payment_instrument'            , '{ts escape="sql"}Payment Methods{/ts}'                    , 'Integer', 1, 1, 0, 'name,label,description',
      '{ts escape="sql"}You may choose to record the payment method used for each contribution and fee. Reserved payment methods are required - you may modify their labels but they can not be deleted (e.g. Check, Credit Card, Debit Card). If your site requires additional payment methods, you can add them here. You can associate each payment method with a Financial Account which specifies where the payment is going (e.g. a bank account for checks and cash).{/ts}'),
    ('contribution_status'           , '{ts escape="sql"}Contribution Status{/ts}'                , NULL,      1, 1, 1, 'name,label,description', NULL),
@@ -160,7 +160,7 @@ VALUES
    ('participant_listing'           , '{ts escape="sql"}Participant Listing{/ts}'                , NULL,      1, 1, 0, 'name,label,description', NULL),
    ('safe_file_extension'           , '{ts escape="sql"}Safe File Extension{/ts}'                , NULL,      1, 1, 0, 'name,label,description', NULL),
    ('from_email_address'            , '{ts escape="sql"}From Email Address{/ts}'                 , NULL,      1, 1, 0, 'name,label,description',
-     '{ts escape="sql"}By default, CiviCRM uses the primary email address of the logged in user as the FROM address when sending emails to contacts. However, you can use this page to define one or more general Email Addresses that can be selected as an alternative. EXAMPLE: <em>"Client Services" &lt;clientservices@example.org&gt;</em>{/ts}'),
+     '{ts escape="sql"}By default, CiviCRM uses the primary email address of the logged in user as the FROM address when sending emails to contacts. However, you can use this page to define one or more general Email Addresses that can be selected as an alternative. EXAMPLE: "Client Services" <clientservices@example.org>.{/ts}'),
    ('mapping_type'                  , '{ts escape="sql"}Mapping Type{/ts}'                       , NULL,      1, 1, 1, 'name,label,description', NULL),
    ('wysiwyg_editor'                , '{ts escape="sql"}WYSIWYG Editor{/ts}'                     , NULL,      1, 1, 0, 'name,label,description', NULL),
    ('recur_frequency_units'         , '{ts escape="sql"}Recurring Frequency Units{/ts}'          , NULL,      1, 1, 0, 'name,label,description', NULL),