From 5b7cf256ff036fb46157ce765b7a8a0819575c5e Mon Sep 17 00:00:00 2001 From: Adam Roses Wight Date: Thu, 1 May 2014 17:29:55 -0700 Subject: [PATCH] CiviCase sample data is localized Uses code generation now. TODO: There may be issues with multilingual upgrades. --- .gitignore | 1 + CRM/Case/Info.php | 1 - .../configuration.sample/SampleConfig.mysql | 58 ------------------- CRM/Core/CodeGen/Schema.php | 2 + bin/regen.sh | 1 - sql/case_sample1.mysql | 25 -------- xml/schema/Case/Case.xml | 2 +- .../templates/case_sample.tpl | 42 ++++++++++---- 8 files changed, 35 insertions(+), 97 deletions(-) delete mode 100644 CRM/Case/xml/configuration.sample/SampleConfig.mysql delete mode 100644 sql/case_sample1.mysql rename sql/case_sample.mysql => xml/templates/case_sample.tpl (51%) diff --git a/.gitignore b/.gitignore index c1c0357721..9f0c884c4a 100644 --- a/.gitignore +++ b/.gitignore @@ -123,6 +123,7 @@ packages/doc packages/temp packages/test settings_location.php +sql/case_sample.mysql sql/civicrm.mysql sql/civicrm_acl.??_??.mysql sql/civicrm_acl.mysql diff --git a/CRM/Case/Info.php b/CRM/Case/Info.php index e0f4428d1c..b03c42b605 100644 --- a/CRM/Case/Info.php +++ b/CRM/Case/Info.php @@ -126,7 +126,6 @@ class CRM_Case_Info extends CRM_Core_Component_Info { ) { $config = CRM_Core_Config::singleton(); CRM_Admin_Form_Setting_Component::loadCaseSampleData($config->dsn, $config->sqlDir . 'case_sample.mysql'); - CRM_Admin_Form_Setting_Component::loadCaseSampleData($config->dsn, $config->sqlDir . 'case_sample1.mysql'); if (!CRM_Case_BAO_Case::createCaseViews()) { $msg = ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission"); CRM_Core_Error::fatal($msg); diff --git a/CRM/Case/xml/configuration.sample/SampleConfig.mysql b/CRM/Case/xml/configuration.sample/SampleConfig.mysql deleted file mode 100644 index 091a8f26a6..0000000000 --- a/CRM/Case/xml/configuration.sample/SampleConfig.mysql +++ /dev/null @@ -1,58 +0,0 @@ --- /********************************************************************** --- * --- * Configuration Data for CiviCase Component --- * For: Sample Case Types - Housing Support and Adult Day Care Referral --- * --- **********************************************************************/ - -SELECT @caseCompId := id FROM `civicrm_component` where `name` like 'CiviCase'; - --- /******************************************************* --- * --- * Case Types --- * --- *******************************************************/ -SELECT @max_wt := COALESCE ( max(weight), 0 ) from civicrm_case_type; - -INSERT INTO `civicrm_case_type` (`title`, `name`, `weight`, `description`, `is_reserved`, `is_active`) VALUES -('Housing Support', 'housing_support', @max_wt + 1, 'Help homeless individuals obtain temporary and long-term housing', 0, 1), -('Adult Day Care Referral', 'adult_day_care_referral', @max_wt + 2, 'Arranging adult day care for senior individuals', 0, 1); - --- /******************************************************* --- * --- * Case Status - Set names for Open and Closed --- * --- *******************************************************/ -SELECT @csgId := max(id) from civicrm_option_group where name = 'case_status'; -UPDATE civicrm_option_value SET name = 'Open' where option_group_id = @csgId AND label = 'Ongoing'; -UPDATE civicrm_option_value SET name = 'Closed' where option_group_id = @csgId AND label = 'Resolved'; - --- /******************************************************* --- * --- * Activity Types --- * --- *******************************************************/ -SELECT @option_group_id_activity_type := max(id) from civicrm_option_group where name = 'activity_type'; - -SELECT @max_val := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = @option_group_id_activity_type; - -INSERT INTO `civicrm_option_value` (`option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id` ) VALUES (@option_group_id_activity_type, 'Medical evaluation', (SELECT @max_val := @max_val+1), 'Medical evaluation', NULL, 0, 0, (SELECT @max_val := @max_val+1), '', 0, 1, 1, @caseCompId ), (@option_group_id_activity_type, 'Mental health evaluation', (SELECT @max_val := @max_val+1), 'Mental health evaluation', NULL, 0, 0, (SELECT @max_val := @max_val+1), '', 0, 1, 1, @caseCompId ), (@option_group_id_activity_type, 'Secure temporary housing', (SELECT @max_val := @max_val+1), 'Secure temporary housing', NULL, 0, 0, (SELECT @max_val := @max_val+1), '', 0, 1, 1, @caseCompId ), (@option_group_id_activity_type, 'Income and benefits stabilization', (SELECT @max_val := @max_val+1), 'Income and benefits stabilization', NULL, 0, 0, (SELECT @max_val := @max_val+1), '', 0, 1, 1, @caseCompId ), (@option_group_id_activity_type, 'Long-term housing plan', (SELECT @max_val := @max_val+1), 'Long-term housing plan', NULL, 0, 0, (SELECT @max_val := @max_val+1), '', 0, 1, 1, @caseCompId ), (@option_group_id_activity_type, 'ADC referral', (SELECT @max_val := @max_val+1), 'ADC referral', NULL, 0, 0, (SELECT @max_val := @max_val+1), '', 0, 1, 1, @caseCompId ); - --- Get Open Case id so we can add custom fields for this activity type if we need to -SELECT @at1 := max(value) from civicrm_option_value where name = 'Open Case'; - --- /******************************************************* --- * --- * Relationship Types (Case Roles) --- * --- *******************************************************/ - -INSERT INTO `civicrm_relationship_type` ( name_a_b, label_a_b, name_b_a, label_b_a, description, contact_type_a, contact_type_b, is_reserved, is_active ) VALUES ('Homeless Services Coordinator is', 'Homeless Services Coordinator is', 'Homeless Services Coordinator', 'Homeless Services Coordinator', 'Homeless Services Coordinator', 'Individual', 'Individual', 0, 1), ('Health Services Coordinator is', 'Health Services Coordinator is', 'Health Services Coordinator', 'Health Services Coordinator', 'Health Services Coordinator', 'Individual', 'Individual', 0, 1), ('Senior Services Coordinator is', 'Senior Services Coordinator is', 'Senior Services Coordinator', 'Senior Services Coordinator', 'Senior Services Coordinator', 'Individual', 'Individual', 0, 1), ('Benefits Specialist is', 'Benefits Specialist is', 'Benefits Specialist', 'Benefits Specialist', 'Benefits Specialist', 'Individual', 'Individual', 0, 1); - --- /******************************************************* --- * --- * Case Resources Group --- * --- *******************************************************/ - -INSERT INTO `civicrm_group` (`name`, `title`, `description`, `source`, `saved_search_id`, `is_active`, `visibility`, `where_clause`, `select_tables`, `where_tables`, `group_type`, `cache_date`, `parents`, `children`, `is_hidden`) VALUES ('Case_Resources', 'Case Resources', 'Contacts in this group are listed with their phone number and email when viewing case. You also can send copies of case activities to these contacts.', NULL, NULL, 1, 'User and User Admin Only', ' ( `civicrm_group_contact-5`.group_id IN ( 5 ) AND `civicrm_group_contact-5`.status IN ("Added") ) ', 'a:10:{s:15:"civicrm_contact";i:1;s:15:"civicrm_address";i:1;s:22:"civicrm_state_province";i:1;s:15:"civicrm_country";i:1;s:13:"civicrm_email";i:1;s:13:"civicrm_phone";i:1;s:10:"civicrm_im";i:1;s:19:"civicrm_worldregion";i:1;s:25:"`civicrm_group_contact-5`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-5` ON contact_a.id = `civicrm_group_contact-5`.contact_id ";s:6:"gender";i:1;}', 'a:2:{s:15:"civicrm_contact";i:1;s:25:"`civicrm_group_contact-5`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-5` ON contact_a.id = `civicrm_group_contact-5`.contact_id ";}', '2', NULL, NULL, NULL, 0); diff --git a/CRM/Core/CodeGen/Schema.php b/CRM/Core/CodeGen/Schema.php index 51bdf6dc79..2745392fed 100644 --- a/CRM/Core/CodeGen/Schema.php +++ b/CRM/Core/CodeGen/Schema.php @@ -89,6 +89,8 @@ class CRM_Core_CodeGen_Schema extends CRM_Core_CodeGen_BaseTask { 'civicrm_acl.tpl', ); $template->runConcat($sections, $this->config->sqlCodePath . 'civicrm_sample.mysql'); + + $template->run('case_sample.tpl', $this->config->sqlCodePath . 'case_sample.mysql'); } function findLocales() { diff --git a/bin/regen.sh b/bin/regen.sh index ce3b42ea8a..378be1c62a 100755 --- a/bin/regen.sh +++ b/bin/regen.sh @@ -48,7 +48,6 @@ mysqldump -cent --skip-triggers -u $DBUSER $PASSWDSECTION $DBARGS $DBNAME > civi #cat civicrm_sample_report.mysql >> civicrm_generated.mysql cat civicrm_sample_custom_data.mysql >> civicrm_generated.mysql #cat civicrm_devel_config.mysql >> civicrm_generated.mysql -cat ../CRM/Case/xml/configuration.sample/SampleConfig.mysql >> civicrm_generated.mysql cat civicrm_dummy_processor.mysql >> civicrm_generated.mysql mysqladmin -f -u$DBUSER $PASSWDSECTION $DBARGS drop $DBNAME mysqladmin -u$DBUSER $PASSWDSECTION $DBARGS create $DBNAME diff --git a/sql/case_sample1.mysql b/sql/case_sample1.mysql deleted file mode 100644 index a45b38d096..0000000000 --- a/sql/case_sample1.mysql +++ /dev/null @@ -1,25 +0,0 @@ --- /******************************************************* --- * --- * Relationship Types --- * --- *******************************************************/ -INSERT INTO `civicrm_relationship_type` ( `name_a_b`, `label_a_b`, `name_b_a`, `label_b_a`, `description`, `contact_type_a`, `contact_type_b`, `is_reserved`, `is_active` ) (SELECT 'Homeless Services Coordinator is', 'Homeless Services Coordinator is', 'Homeless Services Coordinator', 'Homeless Services Coordinator', 'Homeless Services Coordinator', 'Individual', 'Individual', 0, 1 FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_relationship_type` WHERE `name_a_b` = 'Homeless Services Coordinator is')); - - -INSERT INTO `civicrm_relationship_type` ( `name_a_b`, `label_a_b`, `name_b_a`, `label_b_a`, `description`, `contact_type_a`, `contact_type_b`, `is_reserved`, `is_active` ) ( -SELECT 'Health Services Coordinator is', 'Health Services Coordinator is', 'Health Services Coordinator', 'Health Services Coordinator', 'Health Services Coordinator', 'Individual', 'Individual', 0, 1 FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_relationship_type` WHERE `name_a_b` = 'Health Services Coordinator is')); - - -INSERT INTO `civicrm_relationship_type` ( `name_a_b`, `label_a_b`, `name_b_a`, `label_b_a`, `description`, `contact_type_a`, `contact_type_b`, `is_reserved`, `is_active` ) ( -SELECT 'Senior Services Coordinator is', 'Senior Services Coordinator is', 'Senior Services Coordinator', 'Senior Services Coordinator', 'Senior Services Coordinator', 'Individual', 'Individual', 0, 1 FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_relationship_type` WHERE `name_a_b` = 'Senior Services Coordinator is')); - -INSERT INTO `civicrm_relationship_type` ( `name_a_b`, `label_a_b`, `name_b_a`, `label_b_a`, `description`, `contact_type_a`, `contact_type_b`, `is_reserved`, `is_active` ) ( -SELECT 'Benefits Specialist is', 'Benefits Specialist is', 'Benefits Specialist', 'Benefits Specialist', 'Benefits Specialist', 'Individual', 'Individual', 0, 1 FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_relationship_type` WHERE `name_a_b` = 'Benefits Specialist is')); - --- /******************************************************* --- * --- * Case Resources Group --- * --- *******************************************************/ - -INSERT INTO `civicrm_group` ( `name`, `title`, `description`, `source`, `saved_search_id`, `is_active`, `visibility`, `where_clause`, `select_tables`, `where_tables`, `group_type`, `cache_date`, `parents`, `children`, `is_hidden` ) (SELECT 'Case_Resources', 'Case Resources', 'Contacts in this group are listed with their phone number and email when viewing case. You also can send copies of case activities to these contacts.', NULL, NULL, 1, 'User and User Admin Only', ' ( `civicrm_group_contact-5`.group_id IN ( 5 ) AND `civicrm_group_contact-5`.status IN ("Added") ) ', 'a:10:{s:15:"civicrm_contact";i:1;s:15:"civicrm_address";i:1;s:22:"civicrm_state_province";i:1;s:15:"civicrm_country";i:1;s:13:"civicrm_email";i:1;s:13:"civicrm_phone";i:1;s:10:"civicrm_im";i:1;s:19:"civicrm_worldregion";i:1;s:25:"`civicrm_group_contact-5`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-5` ON contact_a.id = `civicrm_group_contact-5`.contact_id ";s:6:"gender";i:1;}', 'a:2:{s:15:"civicrm_contact";i:1;s:25:"`civicrm_group_contact-5`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-5` ON contact_a.id = `civicrm_group_contact-5`.contact_id ";}', '2', NULL, NULL, NULL, 0 FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_group` WHERE `name` = 'Case_Resources')); \ No newline at end of file diff --git a/xml/schema/Case/Case.xml b/xml/schema/Case/Case.xml index 4d741a71e9..71d2a1de93 100644 --- a/xml/schema/Case/Case.xml +++ b/xml/schema/Case/Case.xml @@ -56,7 +56,7 @@ 2.0 - case_type + case_type_id civicrm_case_type
id 4.5 diff --git a/sql/case_sample.mysql b/xml/templates/case_sample.tpl similarity index 51% rename from sql/case_sample.mysql rename to xml/templates/case_sample.tpl index 595b77ad57..b295575033 100644 --- a/sql/case_sample.mysql +++ b/xml/templates/case_sample.tpl @@ -12,17 +12,11 @@ SELECT @caseCompId := id FROM `civicrm_component` where `name` like 'CiviCase'; -- * Case Types -- * -- *******************************************************/ -SELECT @option_group_id_case_type := max(id) from civicrm_option_group where name = 'case_type'; -SELECT @max_val := IF ( value <> 'NULL',max(value) , 0 ) from civicrm_option_value where option_group_id=@option_group_id_case_type; -SELECT @max_wt := IF ( value <> 'NULL',max(weight), 0 ) from civicrm_option_value where option_group_id=@option_group_id_case_type; +SELECT @max_wt := COALESCE ( max(weight), 0 ) from civicrm_case_type; -INSERT INTO `civicrm_option_value` ( `option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`) -(SELECT @option_group_id_case_type, 'Housing Support', @max_val + 1, 'housing_support', NULL, 0, 0, @max_wt + 1, 'Help homeless individuals obtain temporary and long-term housing', 0, 0, 1 - FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_option_value` WHERE `name` = 'housing_support')); - -INSERT INTO `civicrm_option_value` ( `option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`) -(SELECT @option_group_id_case_type, 'Adult Day Care Referral', @max_val + 2, 'adult_day_care_referral', NULL, 0, 0, @max_wt + 2, 'Arranging adult day care for senior individuals', 0, 0, 1 - FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_option_value` WHERE `name` = 'adult_day_care_referral')); +INSERT IGNORE INTO `civicrm_case_type` ( `title`, `name`, `description`, `weight`, `is_reserved`, `is_active`) VALUES + ('{ts}Housing Support{/ts}', 'housing_support', '{ts}Help homeless individuals obtain temporary and long-term housing{/ts}', @max_wt + 1, 0, 1), + ('{ts}Adult Day Care Referral{/ts}', 'adult_day_care_referral', '{ts}Arranging adult day care for senior individuals{/ts}', @max_wt + 2, 0, 1); -- /******************************************************* @@ -65,4 +59,30 @@ INSERT INTO `civicrm_option_value` ( `option_group_id`, `label`, `value`, `name` INSERT INTO `civicrm_option_value` ( `option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id` ) (SELECT @option_group_id_activity_type, 'ADC referral', (SELECT @max_val := @max_val+1), 'ADC referral', NULL, 0, 0, (SELECT @max_val := @max_val+1), '', 0, 0, 1, @caseCompId - FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_option_value` WHERE `name` = 'ADC referral')); \ No newline at end of file + FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_option_value` WHERE `name` = 'ADC referral')); + +-- /******************************************************* +-- * +-- * Relationship Types +-- * +-- *******************************************************/ +INSERT INTO `civicrm_relationship_type` ( `name_a_b`, `label_a_b`, `name_b_a`, `label_b_a`, `description`, `contact_type_a`, `contact_type_b`, `is_reserved`, `is_active` ) (SELECT 'Homeless Services Coordinator is', 'Homeless Services Coordinator is', 'Homeless Services Coordinator', 'Homeless Services Coordinator', 'Homeless Services Coordinator', 'Individual', 'Individual', 0, 1 FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_relationship_type` WHERE `name_a_b` = 'Homeless Services Coordinator is')); + + +INSERT INTO `civicrm_relationship_type` ( `name_a_b`, `label_a_b`, `name_b_a`, `label_b_a`, `description`, `contact_type_a`, `contact_type_b`, `is_reserved`, `is_active` ) ( +SELECT 'Health Services Coordinator is', 'Health Services Coordinator is', 'Health Services Coordinator', 'Health Services Coordinator', 'Health Services Coordinator', 'Individual', 'Individual', 0, 1 FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_relationship_type` WHERE `name_a_b` = 'Health Services Coordinator is')); + + +INSERT INTO `civicrm_relationship_type` ( `name_a_b`, `label_a_b`, `name_b_a`, `label_b_a`, `description`, `contact_type_a`, `contact_type_b`, `is_reserved`, `is_active` ) ( +SELECT 'Senior Services Coordinator is', 'Senior Services Coordinator is', 'Senior Services Coordinator', 'Senior Services Coordinator', 'Senior Services Coordinator', 'Individual', 'Individual', 0, 1 FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_relationship_type` WHERE `name_a_b` = 'Senior Services Coordinator is')); + +INSERT INTO `civicrm_relationship_type` ( `name_a_b`, `label_a_b`, `name_b_a`, `label_b_a`, `description`, `contact_type_a`, `contact_type_b`, `is_reserved`, `is_active` ) ( +SELECT 'Benefits Specialist is', 'Benefits Specialist is', 'Benefits Specialist', 'Benefits Specialist', 'Benefits Specialist', 'Individual', 'Individual', 0, 1 FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_relationship_type` WHERE `name_a_b` = 'Benefits Specialist is')); + +-- /******************************************************* +-- * +-- * Case Resources Group +-- * +-- *******************************************************/ + +INSERT INTO `civicrm_group` ( `name`, `title`, `description`, `source`, `saved_search_id`, `is_active`, `visibility`, `where_clause`, `select_tables`, `where_tables`, `group_type`, `cache_date`, `parents`, `children`, `is_hidden` ) (SELECT 'Case_Resources', 'Case Resources', 'Contacts in this group are listed with their phone number and email when viewing case. You also can send copies of case activities to these contacts.', NULL, NULL, 1, 'User and User Admin Only', ' ( `civicrm_group_contact-5`.group_id IN ( 5 ) AND `civicrm_group_contact-5`.status IN ("Added") ) ', 'a:10:{ldelim}s:15:"civicrm_contact";i:1;s:15:"civicrm_address";i:1;s:22:"civicrm_state_province";i:1;s:15:"civicrm_country";i:1;s:13:"civicrm_email";i:1;s:13:"civicrm_phone";i:1;s:10:"civicrm_im";i:1;s:19:"civicrm_worldregion";i:1;s:25:"`civicrm_group_contact-5`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-5` ON contact_a.id = `civicrm_group_contact-5`.contact_id ";s:6:"gender";i:1;{rdelim}', 'a:2:{ldelim}s:15:"civicrm_contact";i:1;s:25:"`civicrm_group_contact-5`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-5` ON contact_a.id = `civicrm_group_contact-5`.contact_id ";{rdelim}', '2', NULL, NULL, NULL, 0 FROM dual WHERE NOT EXISTS (SELECT * FROM `civicrm_group` WHERE `name` = 'Case_Resources')); -- 2.25.1