Merge pull request #6553 from sudhabisht/C12658
[civicrm-core.git] / api / v3 / Case.php
index 79dd0b6bfc8dbafc24f7f56230f7c8f579ffe861..cd27ced8a517b8268fc9ccc68255e880f272687b 100644 (file)
@@ -1,9 +1,9 @@
 <?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.                                    |
   |                                                                    |
 
 
 /**
- * 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
@@ -124,7 +125,7 @@ function civicrm_api3_case_create($params) {
   $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);
 }
 
 /**
@@ -134,8 +135,11 @@ function civicrm_api3_case_create($params) {
  *   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,
+  );
 }
 
 /**
@@ -145,9 +149,12 @@ function _civicrm_api3_case_get_spec(&$params) {
  *   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';
@@ -157,6 +164,7 @@ function _civicrm_api3_case_create_spec(&$params) {
   $params['medium_id'] = array(
     'name' => 'medium_id',
     'title' => 'Activity Medium',
+    'type' => CRM_Utils_Type::T_INT,
   );
 }
 
@@ -213,7 +221,7 @@ function civicrm_api3_case_get($params) {
         $cases[$id] = $case;
       }
     }
-    return civicrm_api3_create_success($cases, $params, 'case', 'get');
+    return civicrm_api3_create_success($cases, $params, 'Case', 'get');
   }
 
   //search by activity
@@ -223,10 +231,10 @@ function civicrm_api3_case_get($params) {
     }
     $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
@@ -247,7 +255,7 @@ SELECT DISTINCT case_id
     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
@@ -264,7 +272,7 @@ SELECT DISTINCT case_id
     }
   }
 
-  return civicrm_api3_create_success($cases, $params, 'case', 'get');
+  return civicrm_api3_create_success($cases, $params, 'Case', 'get');
 }
 
 /**
@@ -359,18 +367,21 @@ function civicrm_api3_case_update($params) {
   _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
@@ -381,7 +392,7 @@ function civicrm_api3_case_delete($params) {
   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.');