From 005f02ec79a7317b4f7beac27ebdf1e5723696ff Mon Sep 17 00:00:00 2001 From: Matthew Wire <mjw@mjwconsult.co.uk> Date: Tue, 26 Jan 2021 10:54:41 +0000 Subject: [PATCH] Add is_active field to Country/StateProvince/County --- CRM/Core/DAO/Country.php | 22 +++++++++++++- CRM/Core/DAO/County.php | 22 +++++++++++++- CRM/Core/DAO/StateProvince.php | 22 +++++++++++++- .../Incremental/php/FiveThirtyFive.php | 29 +++++++++---------- xml/schema/Core/Country.xml | 8 +++++ xml/schema/Core/County.xml | 8 +++++ xml/schema/Core/StateProvince.xml | 8 +++++ 7 files changed, 101 insertions(+), 18 deletions(-) diff --git a/CRM/Core/DAO/Country.php b/CRM/Core/DAO/Country.php index 2ac1296eb8..f382ac3ea1 100644 --- a/CRM/Core/DAO/Country.php +++ b/CRM/Core/DAO/Country.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/Country.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:baa7ed7cb183bc7f1ee86a41a001e580) + * (GenCodeChecksum:a2520444699acbd151d715ccadc6e2b7) */ /** @@ -93,6 +93,13 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO { */ public $is_province_abbreviated; + /** + * Is this Country active? + * + * @var bool + */ + public $is_active; + /** * Class constructor. */ @@ -268,6 +275,19 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO { 'localizable' => 0, 'add' => '3.1', ], + 'is_active' => [ + 'name' => 'is_active', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'title' => ts('Country Is Active'), + 'description' => ts('Is this Country active?'), + 'where' => 'civicrm_country.is_active', + 'default' => '1', + 'table_name' => 'civicrm_country', + 'entity' => 'Country', + 'bao' => 'CRM_Core_BAO_Country', + 'localizable' => 0, + 'add' => '5.35', + ], ]; CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); } diff --git a/CRM/Core/DAO/County.php b/CRM/Core/DAO/County.php index 6ec5bf444f..3bfb53cd73 100644 --- a/CRM/Core/DAO/County.php +++ b/CRM/Core/DAO/County.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/County.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:9e49f92ab040fc02002d5ec5507cf49a) + * (GenCodeChecksum:5626c0a01aa4e5da8dedc064ce3a9dff) */ /** @@ -58,6 +58,13 @@ class CRM_Core_DAO_County extends CRM_Core_DAO { */ public $state_province_id; + /** + * Is this County active? + * + * @var bool + */ + public $is_active; + /** * Class constructor. */ @@ -163,6 +170,19 @@ class CRM_Core_DAO_County extends CRM_Core_DAO { ], 'add' => '1.1', ], + 'is_active' => [ + 'name' => 'is_active', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'title' => ts('County Is Active'), + 'description' => ts('Is this County active?'), + 'where' => 'civicrm_county.is_active', + 'default' => '1', + 'table_name' => 'civicrm_county', + 'entity' => 'County', + 'bao' => 'CRM_Core_DAO_County', + 'localizable' => 0, + 'add' => '5.35', + ], ]; CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); } diff --git a/CRM/Core/DAO/StateProvince.php b/CRM/Core/DAO/StateProvince.php index c39952b652..777af4481b 100644 --- a/CRM/Core/DAO/StateProvince.php +++ b/CRM/Core/DAO/StateProvince.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/StateProvince.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:abd329da6e7801c901c3c97c1b09ef59) + * (GenCodeChecksum:92fa37e3fe2a55ec5b0efc3fc220ac4f) */ /** @@ -58,6 +58,13 @@ class CRM_Core_DAO_StateProvince extends CRM_Core_DAO { */ public $country_id; + /** + * Is this StateProvince active? + * + * @var bool + */ + public $is_active; + /** * Class constructor. */ @@ -158,6 +165,19 @@ class CRM_Core_DAO_StateProvince extends CRM_Core_DAO { 'FKClassName' => 'CRM_Core_DAO_Country', 'add' => '1.1', ], + 'is_active' => [ + 'name' => 'is_active', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'title' => ts('StateProvince Is Active'), + 'description' => ts('Is this StateProvince active?'), + 'where' => 'civicrm_state_province.is_active', + 'default' => '1', + 'table_name' => 'civicrm_state_province', + 'entity' => 'StateProvince', + 'bao' => 'CRM_Core_DAO_StateProvince', + 'localizable' => 0, + 'add' => '5.35', + ], ]; CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); } diff --git a/CRM/Upgrade/Incremental/php/FiveThirtyFive.php b/CRM/Upgrade/Incremental/php/FiveThirtyFive.php index 05f2a69c13..5d3ac9b3d8 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirtyFive.php +++ b/CRM/Upgrade/Incremental/php/FiveThirtyFive.php @@ -52,21 +52,20 @@ class CRM_Upgrade_Incremental_php_FiveThirtyFive extends CRM_Upgrade_Incremental * (change the x in the function name): */ - // /** - // * Upgrade function. - // * - // * @param string $rev - // */ - // public function upgrade_5_0_x($rev) { - // $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); - // $this->addTask('Do the foo change', 'taskFoo', ...); - // // Additional tasks here... - // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex. - // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable. - // } + /** + * Upgrade function. + * + * @param string $rev + */ + public function upgrade_5_35_alpha1(string $rev): void { + $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); - // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) { - // return TRUE; - // } + $this->addTask('dev/core/#2329 - Add is_active to Country', 'addColumn', + 'civicrm_country', 'is_active', "tinyint DEFAULT 1 COMMENT 'Is this Country active?'"); + $this->addTask('dev/core/#2329 - Add is_active to StateProvince', 'addColumn', + 'civicrm_state_province', 'is_active', "tinyint DEFAULT 1 COMMENT 'Is this StateProvince active?'"); + $this->addTask('dev/core/#2329 - Add is_active to County', 'addColumn', + 'civicrm_county', 'is_active', "tinyint DEFAULT 1 COMMENT 'Is this County active?'"); + } } diff --git a/xml/schema/Core/Country.xml b/xml/schema/Core/Country.xml index cae1255812..fdf1173165 100644 --- a/xml/schema/Core/Country.xml +++ b/xml/schema/Core/Country.xml @@ -101,6 +101,14 @@ <comment>Should state/province be displayed as abbreviation for contacts from this country?</comment> <add>3.1</add> </field> + <field> + <name>is_active</name> + <title>Country Is Active</title> + <type>boolean</type> + <default>1</default> + <comment>Is this Country active?</comment> + <add>5.35</add> + </field> <index> <name>UI_name_iso_code</name> <fieldName>name</fieldName> diff --git a/xml/schema/Core/County.xml b/xml/schema/Core/County.xml index 0d25df4511..936064e9eb 100644 --- a/xml/schema/Core/County.xml +++ b/xml/schema/Core/County.xml @@ -55,6 +55,14 @@ <key>id</key> <add>1.1</add> </foreignKey> + <field> + <name>is_active</name> + <title>County Is Active</title> + <type>boolean</type> + <default>1</default> + <comment>Is this County active?</comment> + <add>5.35</add> + </field> <index> <name>UI_name_state_id</name> <fieldName>name</fieldName> diff --git a/xml/schema/Core/StateProvince.xml b/xml/schema/Core/StateProvince.xml index 9d7d94e886..3963138abb 100644 --- a/xml/schema/Core/StateProvince.xml +++ b/xml/schema/Core/StateProvince.xml @@ -52,6 +52,14 @@ <key>id</key> <add>1.1</add> </foreignKey> + <field> + <name>is_active</name> + <title>StateProvince Is Active</title> + <type>boolean</type> + <default>1</default> + <comment>Is this StateProvince active?</comment> + <add>5.35</add> + </field> <index> <name>UI_name_country_id</name> <fieldName>name</fieldName> -- 2.25.1