From c808593d872d671313b7823df3ccc7c8ac164783 Mon Sep 17 00:00:00 2001 From: Herb v/d Dool Date: Fri, 5 Aug 2022 16:37:38 -0400 Subject: [PATCH] Put Grant option into extension. Put upgrade query into PHP --- .../Incremental/php/FiveFiftyThree.php | 34 +++++++++++++++++++ .../Incremental/sql/5.53.alpha1.mysql.tpl | 21 ------------ ..._items_providers_OptionValue_Grant.mgd.php | 32 +++++++++++++++++ 3 files changed, 66 insertions(+), 21 deletions(-) create mode 100644 ext/civigrant/managed/OptionGroup_recent_items_providers_OptionValue_Grant.mgd.php diff --git a/CRM/Upgrade/Incremental/php/FiveFiftyThree.php b/CRM/Upgrade/Incremental/php/FiveFiftyThree.php index 1d735abcd1..91460a0b45 100644 --- a/CRM/Upgrade/Incremental/php/FiveFiftyThree.php +++ b/CRM/Upgrade/Incremental/php/FiveFiftyThree.php @@ -58,6 +58,7 @@ class CRM_Upgrade_Incremental_php_FiveFiftyThree extends CRM_Upgrade_Incremental $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); $this->addTask('Replace %A specifier in date settings.', 'replacePercentA'); $this->addTask('Add invoice pdf format', 'addInvoicePDFFormat'); + $this->addTask('Add Recent Items Providers', 'addRecentItemsProviders'); } /** @@ -106,4 +107,37 @@ class CRM_Upgrade_Incremental_php_FiveFiftyThree extends CRM_Upgrade_Incremental return $usages; } + /** + * dev/core#3783 Add Recent Items Providers. + * @return bool + */ + public static function addRecentItemsProviders() { + CRM_Core_BAO_OptionGroup::ensureOptionGroupExists([ + 'name' => 'recent_items_providers', + 'title' => ts('Recent Items Providers'), + 'is_reserved' => 0, + ]); + $values = [ + 'Contact' => ['label' => ts('Contacts')], + 'Relationship' => ['label' => ts('Relationships')], + 'Activity' => ['label' => ts('Activities')], + 'Note' => ['label' => ts('Notes')], + 'Group' => ['label' => ts('Groups')], + 'Case' => ['label' => ts('Cases')], + 'Contribution' => ['label' => ts('Contributions')], + 'Participant' => ['label' => ts('Participants')], + 'Membership' => ['label' => ts('Memberships')], + 'Pledge' => ['label' => ts('Pledges')], + 'Event' => ['label' => ts('Events')], + 'Campaign' => ['label' => ts('Campaigns')], + ]; + foreach ($values as $name => $value) { + CRM_Core_BAO_OptionValue::ensureOptionValueExists($value + [ + 'name' => $name, + 'option_group_id' => 'recent_items_providers', + ]); + } + return TRUE; + } + } diff --git a/CRM/Upgrade/Incremental/sql/5.53.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.53.alpha1.mysql.tpl index 4d4dfc1e83..51260ffa7e 100644 --- a/CRM/Upgrade/Incremental/sql/5.53.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.53.alpha1.mysql.tpl @@ -1,22 +1 @@ {* file to handle db changes in 5.53.alpha1 during upgrade *} - --- dev/core#3783 Recent Items providers -INSERT INTO civicrm_option_group - (name, {localize field='title'}title{/localize}, is_reserved, is_active) VALUES ('recent_items_provider', {localize}'{ts escape="sql"}Recent Items Provider{/ts}'{/localize}, 0, 1); - -SELECT @option_group_id_recent := max(id) from civicrm_option_group where name = 'recent_items_provider'; -INSERT INTO civicrm_option_value (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}description{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`) - VALUES - (@option_group_id_recent, {localize}'{ts escape="sql"}Contacts{/ts}'{/localize}, 'Contact', 'Contacts', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Relationships{/ts}'{/localize}, 'Relationship', 'Relationships', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Activities{/ts}'{/localize}, 'Activity', 'Activities', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Notes{/ts}'{/localize}, 'Note', 'Notes', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Groups{/ts}'{/localize}, 'Group', 'Groups', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Cases{/ts}'{/localize}, 'Case', 'Cases', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Contributions{/ts}'{/localize}, 'Contribution', 'Contributions', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Participants{/ts}'{/localize}, 'Participant', 'Participants', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Grants{/ts}'{/localize}, 'Grant', 'Grants', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Memberships{/ts}'{/localize}, 'Membership', 'Memberships', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Pledges{/ts}'{/localize}, 'Pledge', 'Pledges', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Events{/ts}'{/localize}, 'Event', 'Events', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Campaigns{/ts}'{/localize}, 'Campaign', 'Campaigns', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL); diff --git a/ext/civigrant/managed/OptionGroup_recent_items_providers_OptionValue_Grant.mgd.php b/ext/civigrant/managed/OptionGroup_recent_items_providers_OptionValue_Grant.mgd.php new file mode 100644 index 0000000000..2a7c9dd8a1 --- /dev/null +++ b/ext/civigrant/managed/OptionGroup_recent_items_providers_OptionValue_Grant.mgd.php @@ -0,0 +1,32 @@ + 'OptionGroup_recent_items_providers_OptionValue_Grant', + 'entity' => 'OptionValue', + 'cleanup' => 'always', + 'update' => 'always', + 'params' => [ + 'version' => 4, + 'values' => [ + 'option_group_id.name' => 'recent_items_providers', + 'label' => E::ts('Grants'), + 'value' => 'Grant', + 'name' => 'Grants', + 'grouping' => NULL, + 'filter' => 0, + 'is_default' => FALSE, + 'description' => NULL, + 'is_optgroup' => FALSE, + 'is_reserved' => FALSE, + 'is_active' => TRUE, + 'icon' => NULL, + 'color' => NULL, + 'component_id' => NULL, + 'domain_id' => NULL, + 'visibility_id' => NULL, + ], + ], + ], +]; -- 2.25.1