From 233319bf5123f64e9ad93ba7fa2148875607a160 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Thu, 3 May 2018 12:41:16 +0530 Subject: [PATCH] CRM-20459: Actively deprecate CRM_Core_OptionGroup::getValue --- CRM/Contribute/Form/Contribution/Main.php | 2 +- CRM/Core/BAO/UFGroup.php | 4 ++-- CRM/Core/DAO/CustomGroup.php | 9 ++++++++- CRM/Event/Form/Registration/AdditionalParticipant.php | 2 +- CRM/Event/Form/Registration/Register.php | 2 +- xml/schema/Core/CustomGroup.xml | 6 ++++++ 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index da9214d221..9d7ed7c59b 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -956,7 +956,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) { if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) { - $customizedValue = CRM_Core_OptionGroup::getValue($greeting, 'Customized', 'name'); + $customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized'); if ($customizedValue == $greetingType && empty($fielse[$greeting . '_custom'])) { $errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.', array(1 => ucwords(str_replace('_', " ", $greeting))) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 5543a56015..02055aa760 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -2161,7 +2161,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) //else (for contribution), use configured SCT default value $SCTDefaultValue = CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"); if ($field['field_type'] == 'Membership') { - $SCTDefaultValue = CRM_Core_OptionGroup::getValue('soft_credit_type', 'Gift', 'name'); + $SCTDefaultValue = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'gift'); } $form->addElement('hidden', 'sct_default_id', $SCTDefaultValue, array('id' => 'sct_default_id')); } @@ -3041,7 +3041,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $groupTypeName = "{$customGroups->extends}Type"; if ($customGroups->extends == 'Participant' && $customGroups->extends_entity_column_id) { - $groupTypeName = CRM_Core_OptionGroup::getValue('custom_data_type', $customGroups->extends_entity_column_id, 'value', 'String', 'name'); + $groupTypeName = CRM_Core_PseudoConstant::getName('CRM_Core_DAO_CustomGroup', 'extends_entity_column_id', $customGroups->extends_entity_column_id); } foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $customGroups->extends_entity_column_value) as $val) { diff --git a/CRM/Core/DAO/CustomGroup.php b/CRM/Core/DAO/CustomGroup.php index 839c61fb9c..f747321fd9 100644 --- a/CRM/Core/DAO/CustomGroup.php +++ b/CRM/Core/DAO/CustomGroup.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/CustomGroup.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:4b960c311aed67174e9c55901ba3993b) + * (GenCodeChecksum:e0236d574279679e242f45bc73c4680a) */ /** @@ -265,6 +265,13 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO { 'entity' => 'CustomGroup', 'bao' => 'CRM_Core_BAO_CustomGroup', 'localizable' => 0, + 'html' => [ + 'type' => 'Select', + ], + 'pseudoconstant' => [ + 'optionGroupName' => 'custom_data_type', + 'optionEditPath' => 'civicrm/admin/options/custom_data_type', + ] ], 'extends_entity_column_value' => [ 'name' => 'extends_entity_column_value', diff --git a/CRM/Event/Form/Registration/AdditionalParticipant.php b/CRM/Event/Form/Registration/AdditionalParticipant.php index 160c0132b3..f107d94157 100644 --- a/CRM/Event/Form/Registration/AdditionalParticipant.php +++ b/CRM/Event/Form/Registration/AdditionalParticipant.php @@ -583,7 +583,7 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) { if ($greetingType = CRM_Utils_Array::value($greeting, $self->_params[0])) { - $customizedValue = CRM_Core_OptionGroup::getValue($greeting, 'Customized', 'name'); + $customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized'); if ($customizedValue == $greetingType && empty($self->_params[0][$greeting . '_custom'])) { return FALSE; } diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index af1519a351..f9844dedca 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -904,7 +904,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) { if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) { - $customizedValue = CRM_Core_OptionGroup::getValue($greeting, 'Customized', 'name'); + $customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized'); if ($customizedValue == $greetingType && empty($fields[$greeting . '_custom'])) { $errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.', array(1 => ucwords(str_replace('_', ' ', $greeting))) diff --git a/xml/schema/Core/CustomGroup.xml b/xml/schema/Core/CustomGroup.xml index de3a4d70f1..49df6dc5c4 100644 --- a/xml/schema/Core/CustomGroup.xml +++ b/xml/schema/Core/CustomGroup.xml @@ -61,7 +61,13 @@ Custom Group Subtype List NULL FK to civicrm_option_value.id (for option group custom_data_type.) + + custom_data_type + 2.2 + + Select + extends_entity_column_value -- 2.25.1