Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-02-18-07-54-54
[civicrm-core.git] / api / v3 / ActionSchedule.php
index 1e32f917d1602ad4e7edbf492fdc13b7b544c55d..5d1e145013d1384fa3229a6a330cc1c0bf942ecf 100644 (file)
@@ -39,7 +39,7 @@
 /**
  * Get CiviCRM Action Schedule details
  * {@getfields action_schedule_create}
- * 
+ *
  */
 function civicrm_api3_action_schedule_get($params) {
   $bao = new CRM_Core_BAO_ActionSchedule();
@@ -56,26 +56,36 @@ function civicrm_api3_action_schedule_get($params) {
  * @param array $params
  *
  * @return array
- * 
+ *
  * {@getfields action_schedule_create}
  */
 function civicrm_api3_action_schedule_create($params) {
+  if (empty($params['id'])) {
+    // an update does not require any mandatory parameters
+    civicrm_api3_verify_one_mandatory($params,
+      NULL,
+      array(
+        'title','mapping_id', 'entity_status', 'entity_value',
+      )
+    );
+  }
+
   $ids = array();
   if (isset($params['id']) && !CRM_Utils_Rule::integer($params['id'])) {
     return civicrm_api3_create_error('Invalid value for ID');
   }
-  
+
   if (!array_key_exists('name', $params) && !array_key_exists('id', $params)) {
-       $params['name'] = CRM_Utils_String::munge($params['title']);
-  }    
-  
+    $params['name'] = CRM_Utils_String::munge($params['title']);
+  }
+
   $actionSchedule = new CRM_Core_BAO_ActionSchedule();
   $actionSchedule = CRM_Core_BAO_ActionSchedule::add($params, $ids);
-       
+
   $actSchedule = array();
-       
+
   _civicrm_api3_object_to_array($actionSchedule, $actSchedule[$actionSchedule->id]);
-       
+
   return civicrm_api3_create_success($actSchedule, $params, 'action_schedule', 'create', $actionSchedule);
 }
 
@@ -103,4 +113,6 @@ function _civicrm_api3_action_schedule_create_spec(&$params) {
  */
 function civicrm_api3_action_schedule_delete($params) {
   return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
-}
\ No newline at end of file
+}
+
+