<?php
-// $Id$
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
*
* @package CiviCRM_APIv3
* @subpackage API_Case
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
*
*/
return civicrm_api3_create_success($values, $params, 'case', 'create', $caseBAO);
}
-/*
+/**
* Adjust Metadata for Get Action
*
* @param array $params array or parameters determined by getfields
$params['contact_id']['title'] = 'Case Client';
}
-/*
+/**
* Adjust Metadata for Create Action
*
* @param array $params array or parameters determined by getfields
$params['contact_id']['title'] = 'Case Client';
$params['contact_id']['api.required'] = 1;
$params['status_id']['api.default'] = 1;
+ $params['medium_id'] = array(
+ 'name' => 'medium_id',
+ 'title' => 'Activity Medium',
+ );
}
-/*
+/**
* Adjust Metadata for Update action
*
* @param array $params array or parameters determined by getfields
$params['id']['api.required'] = 1;
}
-/*
+/**
* Adjust Metadata for Delete action
*
* @param array $params array or parameters determined by getfields
$params['id']['api.required'] = 1;
}
-
/**
* Get details of a particular case, or search for cases, depending on 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();
return civicrm_api3_create_success($cases, $params, 'case', 'get');
}
- return civicrm_api3_create_error('Missing required parameter. Must provide case_id, contact_id, activity_id, or contact_id.');
+ // 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) {
+ if ($case = _civicrm_api3_case_read($foundcase['id'], $options)) {
+ $cases[$foundcase['id']] = $case;
+ }
+ }
+
+ return civicrm_api3_create_success($cases, $params, 'case', 'get');
}
/**
// get original contact id and creator id of case
if (!empty($params['contact_id'])) {
- $origContactIds = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($params['case_id']);
+ $origContactIds = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($params['id']);
$origContactId = $origContactIds[1];
}
}
if (!empty($mCaseId[0])) {
- $params['case_id'] = $mCaseId[0];
+ $params['id'] = $mCaseId[0];
}
$dao = new CRM_Case_BAO_Case();