From: Richard Bramley Date: Tue, 19 Nov 2013 08:49:53 +0000 (+0000) Subject: Allow API get of Case by ID to use standard get method. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e01eccc00265bfa09d890d587dc513c6bca38d7d;p=civicrm-core.git Allow API get of Case by ID to use standard get method. --- diff --git a/api/v3/Case.php b/api/v3/Case.php index 30a5b13ffa..8829fbec28 100644 --- a/api/v3/Case.php +++ b/api/v3/Case.php @@ -192,25 +192,6 @@ function _civicrm_api3_case_delete_spec(&$params) { function civicrm_api3_case_get($params) { $options = _civicrm_api3_get_options_from_params($params); - // Get by id - $caseId = CRM_Utils_Array::value('id', $params); - if ($caseId) { - // Validate param - if (!is_numeric($caseId)) { - return civicrm_api3_create_error('Invalid parameter: case_id. Must provide a numeric value.'); - } - // For historic reasons we always return these when an id is provided - $options['return'] = array('contacts' => 1, 'activities' => 1); - $case = _civicrm_api3_case_read($caseId, $options); - - if ($case) { - return civicrm_api3_create_success(array($caseId => $case), $params, 'case', 'get'); - } - else { - return civicrm_api3_create_success(array(), $params, 'case', 'get'); - } - } - //search by client if (!empty($params['contact_id'])) { $ids = array(); @@ -262,6 +243,12 @@ SELECT DISTINCT case_id return civicrm_api3_create_success($cases, $params, 'case', 'get'); } + // For historic reasons we always return these when an id is provided + $caseId = CRM_Utils_Array::value('id', $params); + if ($caseId) { + $options['return'] = array('contacts' => 1, 'activities' => 1); + } + $foundcases = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Case'); $cases = array(); foreach ($foundcases['values'] as $foundcase) {