From 0571e734a05d5e46044a5ecd5f8af2abb7f6dcd1 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Mon, 30 Apr 2018 13:58:11 +0530 Subject: [PATCH] CRM-20459: Actively dt eprecate CRM_Core_OptionGroup::getValue --- CRM/Badge/BAO/Layout.php | 5 +++-- CRM/Campaign/BAO/Petition.php | 4 ++-- CRM/Campaign/BAO/Survey.php | 2 +- CRM/Campaign/Form/Survey/Results.php | 8 ++++---- CRM/Case/BAO/Case.php | 4 ++-- CRM/Case/Form/Activity/ChangeCaseStartDate.php | 2 +- CRM/Case/Form/Activity/ChangeCaseStatus.php | 2 +- CRM/Case/Form/Activity/ChangeCaseType.php | 2 +- CRM/Contribute/BAO/ContributionSoft.php | 4 ++-- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CRM/Badge/BAO/Layout.php b/CRM/Badge/BAO/Layout.php index f38961fd3b..1c5ce80219 100644 --- a/CRM/Badge/BAO/Layout.php +++ b/CRM/Badge/BAO/Layout.php @@ -92,7 +92,7 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel { $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE); $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE); - $params['label_type_id'] = CRM_Core_OptionGroup::getValue('label_type', 'Event Badge', 'name'); + $params['label_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_PrintLabel', 'label_type_id', 'Event Badge'); // check if new layout is create, if so set the created_id (if not set) if (empty($params['id'])) { @@ -162,7 +162,8 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel { $layoutParams = array('id' => $params['badge_id']); CRM_Badge_BAO_Layout::retrieve($layoutParams, $layoutInfo); - $formatProperties = CRM_Core_OptionGroup::getValue('name_badge', $layoutInfo['label_format_name'], 'name'); + $formatProperties = CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_PrintLabel', 'label_format_name', $layoutInfo['label_format_name']); + $layoutInfo['format'] = json_decode($formatProperties, TRUE); $layoutInfo['data'] = CRM_Badge_BAO_Layout::getDecodedData($layoutInfo['data']); return $layoutInfo; diff --git a/CRM/Campaign/BAO/Petition.php b/CRM/Campaign/BAO/Petition.php index 4a8ad4095f..43246cc66f 100644 --- a/CRM/Campaign/BAO/Petition.php +++ b/CRM/Campaign/BAO/Petition.php @@ -94,7 +94,7 @@ INNER JOIN civicrm_option_group grp ON ( activity_type.option_group_id = grp.id //we only have activity type as a //difference between survey and petition. - $petitionTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'petition', 'name'); + $petitionTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Petition'); if ($petitionTypeID) { $where[] = "( petition.activity_type_id = %1 )"; $queryParams[1] = array($petitionTypeID, 'Positive'); @@ -160,7 +160,7 @@ SELECT petition.id as id, public static function getPetitionCount() { $whereClause = 'WHERE ( 1 )'; $queryParams = array(); - $petitionTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'petition', 'name'); + $petitionTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Petition'); if ($petitionTypeID) { $whereClause = "WHERE ( petition.activity_type_id = %1 )"; $queryParams[1] = array($petitionTypeID, 'Positive'); diff --git a/CRM/Campaign/BAO/Survey.php b/CRM/Campaign/BAO/Survey.php index d10d4a7aef..df9b49022b 100644 --- a/CRM/Campaign/BAO/Survey.php +++ b/CRM/Campaign/BAO/Survey.php @@ -167,7 +167,7 @@ INNER JOIN civicrm_option_group grp ON ( activity_type.option_group_id = grp.id //we only have activity type as a //difference between survey and petition. - $petitionTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'petition', 'name'); + $petitionTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Petition'); if ($petitionTypeID) { $where[] = "( survey.activity_type_id != %1 )"; $queryParams[1] = array($petitionTypeID, 'Positive'); diff --git a/CRM/Campaign/Form/Survey/Results.php b/CRM/Campaign/Form/Survey/Results.php index 241560ac72..f041d2b5b3 100644 --- a/CRM/Campaign/Form/Survey/Results.php +++ b/CRM/Campaign/Form/Survey/Results.php @@ -434,7 +434,7 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { 'street_unit', 'survey_response', ); - if (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == + if (CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'WalkList') == $this->_values['activity_type_id'] ) { $this->_params['order_bys'] = array( @@ -456,14 +456,14 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { ), ); } - elseif (CRM_Core_OptionGroup::getValue('activity_type', 'PhoneBank') == + elseif (CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'PhoneBank') == $this->_values['activity_type_id'] ) { array_push($displayFields, 'phone'); } - elseif ((CRM_Core_OptionGroup::getValue('activity_type', 'Survey') == + elseif ((CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Survey') == $this->_values['activity_type_id']) || - (CRM_Core_OptionGroup::getValue('activity_type', 'Canvass') == + (CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Canvass') == $this->_values['activity_type_id']) ) { array_push($displayFields, 'phone', 'city', 'state_province_id', 'postal_code', 'email'); diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index b6fb646535..9602becaa7 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1127,10 +1127,10 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c } if (!empty($dao->priority)) { - if ($dao->priority == CRM_Core_OptionGroup::getValue('priority', 'Urgent', 'name')) { + if ($dao->priority == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'priority_id', 'Urgent')) { $caseActivity['DT_RowClass'] .= " priority-urgent "; } - elseif ($dao->priority == CRM_Core_OptionGroup::getValue('priority', 'Low', 'name')) { + elseif ($dao->priority == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'priority_id', 'Low')) { $caseActivity['DT_RowClass'] .= " priority-low "; } } diff --git a/CRM/Case/Form/Activity/ChangeCaseStartDate.php b/CRM/Case/Form/Activity/ChangeCaseStartDate.php index 21c2e1b2c4..3a798291bc 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStartDate.php +++ b/CRM/Case/Form/Activity/ChangeCaseStartDate.php @@ -155,7 +155,7 @@ class CRM_Case_Form_Activity_ChangeCaseStartDate { $params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'); $activity->status_id = $params['status_id']; - $params['priority_id'] = CRM_Core_OptionGroup::getValue('priority', 'Normal', 'name'); + $params['priority_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'priority_id', 'Normal'); $activity->priority_id = $params['priority_id']; // 1. save activity subject with new start date diff --git a/CRM/Case/Form/Activity/ChangeCaseStatus.php b/CRM/Case/Form/Activity/ChangeCaseStatus.php index 5d1fb81ead..c00901c9ab 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStatus.php +++ b/CRM/Case/Form/Activity/ChangeCaseStatus.php @@ -205,7 +205,7 @@ class CRM_Case_Form_Activity_ChangeCaseStatus { } $params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'); $activity->status_id = $params['status_id']; - $params['priority_id'] = CRM_Core_OptionGroup::getValue('priority', 'Normal', 'name'); + $params['priority_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'priority_id', 'Normal'); $activity->priority_id = $params['priority_id']; foreach ($form->_oldCaseStatus as $statuskey => $statusval) { diff --git a/CRM/Case/Form/Activity/ChangeCaseType.php b/CRM/Case/Form/Activity/ChangeCaseType.php index 36f0deeaf2..ff2d192d53 100644 --- a/CRM/Case/Form/Activity/ChangeCaseType.php +++ b/CRM/Case/Form/Activity/ChangeCaseType.php @@ -160,7 +160,7 @@ class CRM_Case_Form_Activity_ChangeCaseType { $params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'); $activity->status_id = $params['status_id']; - $params['priority_id'] = CRM_Core_OptionGroup::getValue('priority', 'Normal', 'name'); + $params['priority_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'priority_id', 'Normal'); $activity->priority_id = $params['priority_id']; if ($activity->subject == 'null') { diff --git a/CRM/Contribute/BAO/ContributionSoft.php b/CRM/Contribute/BAO/ContributionSoft.php index c0eca72a06..e08d00ff04 100644 --- a/CRM/Contribute/BAO/ContributionSoft.php +++ b/CRM/Contribute/BAO/ContributionSoft.php @@ -85,7 +85,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio $softParams['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcp); $softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcp); $softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcp); - $softParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name'); + $softParams['soft_credit_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'pcp'); $contributionSoft = self::add($softParams); //Send notification to owner for PCP if ($contributionSoft->pcp_id && empty($pcpId)) { @@ -149,7 +149,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio $honorId = NULL; // @todo fix use of deprecated function. - $contributionSoftParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name'); + $contributionSoftParams['soft_credit_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'pcp'); //check if there is any duplicate contact // honoree should never be the donor $exceptKeys = array( -- 2.25.1