<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
*/
/**
- * File for the CiviCRM APIv3 Case functions
+ * This api exposes CiviCRM Case objects.
* Developed by woolman.org
*
* @package CiviCRM_APIv3
- * @subpackage API_Case
- * @copyright CiviCRM LLC (c) 2004-2014
*/
/**
- * Open a new case, add client and manager roles, and add standard timeline.
+ * Open a new case, add client and manager roles, and standard timeline.
*
* @param array $params
+ *
+ * @code
* //REQUIRED:
* 'case_type_id' => int OR
* 'case_type' => str (provide one or the other)
* 'start_date' => str datestamp // defaults to: date('YmdHis')
* 'duration' => int // in minutes
* 'details' => str // html format
+ * @endcode
*
* @throws API_Exception
* @return array
$values = array();
_civicrm_api3_object_to_array($caseBAO, $values[$caseBAO->id]);
- return civicrm_api3_create_success($values, $params, 'case', 'create', $caseBAO);
+ return civicrm_api3_create_success($values, $params, 'Case', 'create', $caseBAO);
}
/**
* Parameters determined by getfields.
*/
function _civicrm_api3_case_get_spec(&$params) {
- $params['contact_id']['api.aliases'] = array('client_id');
- $params['contact_id']['title'] = 'Case Client';
+ $params['contact_id'] = array(
+ 'api.aliases' => array('client_id'),
+ 'title' => 'Case Client',
+ 'type' => CRM_Utils_Type::T_INT,
+ );
}
/**
* Adjust Metadata for Create Action.
*
* @param array $params
- * Array or parameters determined by getfields.
+ * Array of parameters determined by getfields.
*/
function _civicrm_api3_case_create_spec(&$params) {
- $params['contact_id']['api.aliases'] = array('client_id');
- $params['contact_id']['title'] = 'Case Client';
- $params['contact_id']['api.required'] = 1;
+ $params['contact_id'] = array(
+ 'api.aliases' => array('client_id'),
+ 'title' => 'Case Client',
+ 'api.required' => 1,
+ 'type' => CRM_Utils_Type::T_INT,
+ );
$params['status_id']['api.default'] = 1;
$params['status_id']['api.aliases'] = array('case_status');
$params['creator_id']['api.default'] = 'user_contact_id';
$params['medium_id'] = array(
'name' => 'medium_id',
'title' => 'Activity Medium',
+ 'type' => CRM_Utils_Type::T_INT,
);
}
* Adjust Metadata for Update action.
*
* @param array $params
- * Array or parameters determined by getfields.
+ * Array of parameters determined by getfields.
*/
function _civicrm_api3_case_update_spec(&$params) {
$params['id']['api.required'] = 1;
* Adjust Metadata for Delete action.
*
* @param array $params
- * Array or parameters determined by getfields.
+ * Array of parameters determined by getfields.
*/
function _civicrm_api3_case_delete_spec(&$params) {
$params['id']['api.required'] = 1;
$cases[$id] = $case;
}
}
- return civicrm_api3_create_success($cases, $params, 'case', 'get');
+ return civicrm_api3_create_success($cases, $params, 'Case', 'get');
}
//search by activity
}
$caseId = CRM_Case_BAO_Case::getCaseIdByActivityId($params['activity_id']);
if (!$caseId) {
- return civicrm_api3_create_success(array(), $params, 'case', 'get');
+ return civicrm_api3_create_success(array(), $params, 'Case', 'get');
}
$case = array($caseId => _civicrm_api3_case_read($caseId, $options));
- return civicrm_api3_create_success($case, $params, 'case', 'get');
+ return civicrm_api3_create_success($case, $params, 'Case', 'get');
}
//search by contacts
while ($dao->fetch()) {
$cases[$dao->case_id] = _civicrm_api3_case_read($dao->case_id, $options);
}
- return civicrm_api3_create_success($cases, $params, 'case', 'get');
+ return civicrm_api3_create_success($cases, $params, 'Case', 'get');
}
// For historic reasons we always return these when an id is provided
}
}
- return civicrm_api3_create_success($cases, $params, 'case', 'get');
+ return civicrm_api3_create_success($cases, $params, 'Case', 'get');
}
/**
- * Deprecated. Use activity API instead
+ * Deprecated API.
+ *
+ * Use activity API instead.
*
* @param array $params
*
}
/**
+ * Declare deprecated api functions.
+ *
* @deprecated api notice
* @return array
* Array of deprecated actions
_civicrm_api3_object_to_array($dao, $case);
$values[$dao->id] = $case;
- return civicrm_api3_create_success($values, $params, 'case', 'update', $dao);
+ return civicrm_api3_create_success($values, $params, 'Case', 'update', $dao);
}
/**
* Delete a specified case.
*
* @param array $params
+ *
+ * @code
* //REQUIRED:
* 'id' => int
*
* //OPTIONAL
* 'move_to_trash' => bool (defaults to false)
+ * @endcode
*
* @throws API_Exception
* @return bool
civicrm_api3_verify_mandatory($params, NULL, array('id'));
if (CRM_Case_BAO_Case::deleteCase($params['id'], CRM_Utils_Array::value('move_to_trash', $params, FALSE))) {
- return civicrm_api3_create_success($params, $params, 'case', 'delete');
+ return civicrm_api3_create_success($params, $params, 'Case', 'delete');
}
else {
throw new API_Exception('Could not delete case.');
}
}
-/***********************************/
-/* */
-/* INTERNAL FUNCTIONS */
-/* */
-/***********************************/
-
/**
* Internal function to retrieve a case.
*
}
/**
- * Internal function to format create params for processing
+ * Internal function to format create params for processing.
*
* @param array $params
*/
if (!$params['case_type_id']) {
$caseTypeLabels = CRM_Case_PseudoConstant::caseType('title', FALSE);
$params['case_type_id'] = array_search($params['case_type'], $caseTypeLabels);
- $params['case_type'] = $caseTypes[$params['case_type_id']]; // label => name
+ $params['case_type'] = $caseTypes[$params['case_type_id']];
}
}
elseif (empty($params['case_type'])) {