From 9c248a4251a24f69c92d486b538045dcc70bdd69 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Thu, 14 Dec 2017 22:13:41 +0900 Subject: [PATCH] Replace CRM_Core_OptionGroup::getValue with CRM_Core_PseudoConstant::getKey for Case --- CRM/Case/BAO/Case.php | 32 +++++-------------- CRM/Case/Form/Activity.php | 4 +-- .../Form/Activity/ChangeCaseStartDate.php | 7 ++-- CRM/Case/Form/Activity/ChangeCaseStatus.php | 2 +- CRM/Case/Form/Activity/ChangeCaseType.php | 2 +- CRM/Case/Form/Activity/OpenCase.php | 5 +-- CRM/Case/Form/Case.php | 5 +-- CRM/Case/Form/CustomData.php | 7 ++-- CRM/Case/Page/AJAX.php | 8 ++--- 9 files changed, 22 insertions(+), 50 deletions(-) diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index c9f0afa622..4a9aa6e03b 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1033,14 +1033,8 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c $viewTitle = ts('View activity'); $emailActivityTypeIDs = array( - 'Email' => CRM_Core_OptionGroup::getValue('activity_type', - 'Email', - 'name' - ), - 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', - 'Inbound Email', - 'name' - ), + 'Email' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Email'), + 'Inbound Email' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Inbound Email'), ); $caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted'); @@ -1049,7 +1043,7 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c $compStatusValues = array(); $compStatusNames = array('Completed', 'Left Message', 'Cancelled', 'Unreachable', 'Not Required'); foreach ($compStatusNames as $name) { - $compStatusValues[] = CRM_Core_OptionGroup::getValue('activity_status', $name, 'name'); + $compStatusValues[] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', $name); } $contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid=", FALSE, NULL, FALSE); @@ -1496,10 +1490,7 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c $params['activity_date_time'] = $result['date']; $params['details'] = $result['body']; $params['source_contact_id'] = $result['from']['id']; - $params['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', - 'Completed', - 'name' - ); + $params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'); $details = CRM_Case_PseudoConstant::caseActivityType(); $matches = array(); @@ -1514,7 +1505,7 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c } } if (!isset($params['activity_type_id'])) { - $params['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name'); + $params['activity_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Inbound Email'); } // create activity @@ -1817,23 +1808,16 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c 'source_contact_id' => $session->get('userID'), 'subject' => $caseRelationship . ' : ' . $assigneContactName, 'activity_date_time' => date('YmdHis'), - 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'), + 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'), ); //if $relContactId is passed, role is added or modified. if (!empty($relContactId)) { $activityParams['assignee_contact_id'] = $assigneContactIds; - - $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', - 'Assign Case Role', - 'name' - ); + $activityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Assign Case Role'); } else { - $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', - 'Remove Case Role', - 'name' - ); + $activityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Remove Case Role'); } $activityParams['activity_type_id'] = $activityTypeID; diff --git a/CRM/Case/Form/Activity.php b/CRM/Case/Form/Activity.php index d8279136b3..7a0809cc8c 100644 --- a/CRM/Case/Form/Activity.php +++ b/CRM/Case/Form/Activity.php @@ -72,7 +72,7 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { $result = parent::preProcess(); - $scheduleStatusId = CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name'); + $scheduleStatusId = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Scheduled'); $this->assign('scheduleStatusId', $scheduleStatusId); if (!$this->_caseId && $this->_activityId) { @@ -258,7 +258,7 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { } // remove Open Case activity type since we're inside an existing case - $openCaseID = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name'); + $openCaseID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Open Case'); unset($aTypes[$openCaseID]); asort($aTypes); $this->_fields['followup_activity_type_id']['attributes'] = array('' => '- select activity type -') + $aTypes; diff --git a/CRM/Case/Form/Activity/ChangeCaseStartDate.php b/CRM/Case/Form/Activity/ChangeCaseStartDate.php index 8e2eead76a..bc0e25b07a 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStartDate.php +++ b/CRM/Case/Form/Activity/ChangeCaseStartDate.php @@ -62,10 +62,7 @@ class CRM_Case_Form_Activity_ChangeCaseStartDate { public static function setDefaultValues(&$form) { $defaults = array(); - $openCaseActivityType = CRM_Core_OptionGroup::getValue('activity_type', - 'Open Case', - 'name' - ); + $openCaseActivityType = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Open Case'); $caseId = CRM_Utils_Array::first($form->_caseId); $openCaseParams = array('activity_type_id' => $openCaseActivityType); $openCaseInfo = CRM_Case_BAO_Case::getCaseActivityDates($caseId, $openCaseParams, TRUE); @@ -156,7 +153,7 @@ class CRM_Case_Form_Activity_ChangeCaseStartDate { $config = CRM_Core_Config::singleton(); - $params['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'); + $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'); $activity->priority_id = $params['priority_id']; diff --git a/CRM/Case/Form/Activity/ChangeCaseStatus.php b/CRM/Case/Form/Activity/ChangeCaseStatus.php index 9cf971ea7c..8006b0c37b 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStatus.php +++ b/CRM/Case/Form/Activity/ChangeCaseStatus.php @@ -187,7 +187,7 @@ class CRM_Case_Form_Activity_ChangeCaseStatus { } } } - $params['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'); + $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'); $activity->priority_id = $params['priority_id']; diff --git a/CRM/Case/Form/Activity/ChangeCaseType.php b/CRM/Case/Form/Activity/ChangeCaseType.php index ae3894afba..946d90aae0 100644 --- a/CRM/Case/Form/Activity/ChangeCaseType.php +++ b/CRM/Case/Form/Activity/ChangeCaseType.php @@ -158,7 +158,7 @@ class CRM_Case_Form_Activity_ChangeCaseType { CRM_Core_Error::fatal('Required parameter missing for ChangeCaseType - end post processing'); } - $params['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'); + $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'); $activity->priority_id = $params['priority_id']; diff --git a/CRM/Case/Form/Activity/OpenCase.php b/CRM/Case/Form/Activity/OpenCase.php index e2edc6cca5..506b3951d0 100644 --- a/CRM/Case/Form/Activity/OpenCase.php +++ b/CRM/Case/Form/Activity/OpenCase.php @@ -53,10 +53,7 @@ class CRM_Case_Form_Activity_OpenCase { if ($form->_context == 'caseActivity') { $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $form); - $atype = CRM_Core_OptionGroup::getValue('activity_type', - 'Change Case Start Date', - 'name' - ); + $atype = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Change Case Start Date'); $caseId = CRM_Utils_Array::first($form->_caseId); $form->assign('changeStartURL', CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid=$contactID&caseid={$caseId}&atype=$atype" diff --git a/CRM/Case/Form/Case.php b/CRM/Case/Form/Case.php index 91658cee60..65532de6ff 100644 --- a/CRM/Case/Form/Case.php +++ b/CRM/Case/Form/Case.php @@ -124,10 +124,7 @@ class CRM_Case_Form_Case extends CRM_Core_Form { } if ($this->_action & CRM_Core_Action::ADD) { - $this->_activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', - 'Open Case', - 'name' - ); + $this->_activityTypeId = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Open Case'); if (!$this->_activityTypeId) { CRM_Core_Error::fatal(ts('The Open Case activity type is missing or disabled. Please have your site administrator check Administer > Option Lists > Activity Types for the CiviCase component.')); } diff --git a/CRM/Case/Form/CustomData.php b/CRM/Case/Form/CustomData.php index e7b7e139ac..ddfe9f357c 100644 --- a/CRM/Case/Form/CustomData.php +++ b/CRM/Case/Form/CustomData.php @@ -130,16 +130,13 @@ class CRM_Case_Form_CustomData extends CRM_Core_Form { $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&id={$this->_entityID}&cid={$this->_contactID}&action=view")); $session = CRM_Core_Session::singleton(); - $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Change Custom Data', 'name'); + $activityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Change Custom Data'); $activityParams = array( 'activity_type_id' => $activityTypeID, 'source_contact_id' => $session->get('userID'), 'is_auto' => TRUE, 'subject' => $this->_customTitle . " : change data", - 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', - 'Completed', - 'name' - ), + 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'), 'target_contact_id' => $this->_contactID, 'details' => json_encode($this->_defaults), 'activity_date_time' => date('YmdHis'), diff --git a/CRM/Case/Page/AJAX.php b/CRM/Case/Page/AJAX.php index 4bed5d833c..cd30c11488 100644 --- a/CRM/Case/Page/AJAX.php +++ b/CRM/Case/Page/AJAX.php @@ -77,9 +77,9 @@ class CRM_Case_Page_AJAX { $activityParams = array(); $activityParams['source_contact_id'] = $session->get('userID'); - $activityParams['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Change Case Tags', 'name'); + $activityParams['activity_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Change Case Tags'); $activityParams['activity_date_time'] = date('YmdHis'); - $activityParams['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'); + $activityParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'); $activityParams['case_id'] = $caseId; $activityParams['is_auto'] = 0; $activityParams['subject'] = 'Change Case Tags'; @@ -150,9 +150,9 @@ class CRM_Case_Page_AJAX { $activityParams = array(); $activityParams['source_contact_id'] = $session->get('userID'); - $activityParams['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Add Client To Case', 'name'); + $activityParams['activity_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Add Client To Case'); $activityParams['activity_date_time'] = date('YmdHis'); - $activityParams['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'); + $activityParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'); $activityParams['case_id'] = $caseId; $activityParams['is_auto'] = 0; $activityParams['subject'] = 'Client Added To Case'; -- 2.25.1