CRM-14108 add scheduled reminder id as a params on scheduled job
[civicrm-core.git] / api / v3 / ActionSchedule.php
index 1e32f917d1602ad4e7edbf492fdc13b7b544c55d..46b7cef59d3b0225763a243d3c1abb956509a6c1 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 (!CRM_Utils_Array::value('id', $params)) {
+    // 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
+}
+
+