Merge pull request #5010 from eileenmcnaughton/rebase2
[civicrm-core.git] / api / v3 / Case.php
index 4e8790baa3d48e7c618df7176873e3c62fea4390..870e8dc5252d1f5439db5a0f51bb4da65ccdbf7f 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /*
   +--------------------------------------------------------------------+
   | CiviCRM version 4.6                                                |
@@ -24,7 +23,7 @@
   | GNU Affero General Public License or the licensing of CiviCRM,     |
   | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
   +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  * File for the CiviCRM APIv3 Case functions
  * @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 add standard timeline.
  *
- * @param  array (
+ * @param array $params
  * //REQUIRED:
  * 'case_type_id' => int OR
  * 'case_type' => str (provide one or the other)
  * 'details' => str // html format
  *
  * @throws API_Exception
- * @return array api result array
- *
- * @access public
- * {@getfields case_create}
+ * @return array
+ *   api result array
  */
 function civicrm_api3_case_create($params) {
 
@@ -128,9 +124,10 @@ function civicrm_api3_case_create($params) {
 }
 
 /**
- * Adjust Metadata for Get Action
+ * Adjust Metadata for Get Action.
  *
- * @param array $params array or parameters determined by getfields
+ * @param array $params
+ *   Parameters determined by getfields.
  */
 function _civicrm_api3_case_get_spec(&$params) {
   $params['contact_id']['api.aliases'] = array('client_id');
@@ -138,9 +135,10 @@ function _civicrm_api3_case_get_spec(&$params) {
 }
 
 /**
- * Adjust Metadata for Create Action
+ * Adjust Metadata for Create Action.
  *
- * @param array $params array or parameters determined by getfields
+ * @param array $params
+ *   Array or parameters determined by getfields.
  */
 function _civicrm_api3_case_create_spec(&$params) {
   $params['contact_id']['api.aliases'] = array('client_id');
@@ -159,9 +157,10 @@ function _civicrm_api3_case_create_spec(&$params) {
 }
 
 /**
- * Adjust Metadata for Update action
+ * Adjust Metadata for Update action.
  *
- * @param array $params array or parameters determined by getfields
+ * @param array $params
+ *   Array or parameters determined by getfields.
  */
 function _civicrm_api3_case_update_spec(&$params) {
   $params['id']['api.required'] = 1;
@@ -170,7 +169,8 @@ function _civicrm_api3_case_update_spec(&$params) {
 /**
  * Adjust Metadata for Delete action
  *
- * @param array $params array or parameters determined by getfields
+ * @param array $params
+ *   Array or parameters determined by getfields.
  */
 function _civicrm_api3_case_delete_spec(&$params) {
   $params['id']['api.required'] = 1;
@@ -181,19 +181,17 @@ function _civicrm_api3_case_delete_spec(&$params) {
  *
  * Please provide one (and only one) of the four get/search parameters:
  *
- * @param array (
- * 'id' => if set, will get all available info about a case, including contacts and activities
- *
- * // if no case_id provided, this function will use one of the following search parameters:
- * 'client_id' => finds all cases with a specific client
- * 'activity_id' => returns the case containing a specific activity
- * 'contact_id' => finds all cases associated with a contact (in any role, not just client)
+ * @param array $params
+ *   'id' => if set, will get all available info about a case, including contacts and activities
  *
- * {@getfields case_get}
+ *   // if no case_id provided, this function will use one of the following search parameters:
+ *   'client_id' => finds all cases with a specific client
+ *   'activity_id' => returns the case containing a specific activity
+ *   'contact_id' => finds all cases associated with a contact (in any role, not just client)
  *
  * @throws API_Exception
- * @return array (get mode, case_id provided): Array with case details, case roles, case activity ids, (search mode, case_id not provided): Array of cases found@access public
- * @todo Erik Hommel 16 dec 2010 check if all DB fields are returned
+ * @return array
+ *   (get mode, case_id provided): Array with case details, case roles, case activity ids, (search mode, case_id not provided): Array of cases found
  */
 function civicrm_api3_case_get($params) {
   $options = _civicrm_api3_get_options_from_params($params);
@@ -254,13 +252,13 @@ SELECT DISTINCT case_id
     $options['return'] = array('contacts' => 1, 'activities' => 1);
   }
 
-  $foundcases =  _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Case');
+  $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;
-      }
+    if ($case = _civicrm_api3_case_read($foundcase['id'], $options)) {
+      $cases[$foundcase['id']] = $case;
     }
+  }
 
   return civicrm_api3_create_success($cases, $params, 'case', 'get');
 }
@@ -282,7 +280,8 @@ function civicrm_api3_case_activity_create($params) {
 
 /**
  * @deprecated api notice
- * @return array of deprecated actions
+ * @return array
+ *   Array of deprecated actions
  */
 function _civicrm_api3_case_deprecation() {
   return array('activity_create' => 'Case api "activity_create" action is deprecated. Use the activity api instead.');
@@ -291,19 +290,19 @@ function _civicrm_api3_case_deprecation() {
 /**
  * Update a specified case.
  *
- * @param  array (
- * //REQUIRED:
- * 'case_id' => int
+ * @param array $params
+ *   //REQUIRED:
+ *   'case_id' => int
  *
- * //OPTIONAL
- * 'status_id' => int
- * 'start_date' => str datestamp
- * 'contact_id' => int // case client
+ *   //OPTIONAL
+ *   'status_id' => int
+ *   'start_date' => str datestamp
+ *   'contact_id' => int // case client
  *
  * @throws API_Exception
- * @return array api result array
+ * @return array
+ *   api result array
  *
- * @access public
  */
 function civicrm_api3_case_update($params) {
   //check parameters
@@ -359,17 +358,16 @@ function civicrm_api3_case_update($params) {
 /**
  * Delete a specified case.
  *
- * @param  array (
- * //REQUIRED:
- * 'id' => int
+ * @param array $params
+ *   //REQUIRED:
+ *   'id' => int
  *
- * //OPTIONAL
- * 'move_to_trash' => bool (defaults to false)
+ *   //OPTIONAL
+ *   'move_to_trash' => bool (defaults to false)
  *
  * @throws API_Exception
- * @return boolean: true if success, else false
- * {@getfields case_delete}
- * @access public
+ * @return bool
+ *   true if success, else false
  */
 function civicrm_api3_case_delete($params) {
   //check parameters
@@ -396,7 +394,8 @@ function civicrm_api3_case_delete($params) {
  *
  * @param $options
  *
- * @return array case object
+ * @return array
+ *   case object
  */
 function _civicrm_api3_case_read($caseId, $options) {
   $return = CRM_Utils_Array::value('return', $options, array());