X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FActionSchedule.php;h=46b7cef59d3b0225763a243d3c1abb956509a6c1;hb=b5e8537ad99104f37a433de51d5d2abcebb5977c;hp=1e32f917d1602ad4e7edbf492fdc13b7b544c55d;hpb=39e14733f1d71bf49d9ee83ce3c0425fefde2227;p=civicrm-core.git diff --git a/api/v3/ActionSchedule.php b/api/v3/ActionSchedule.php index 1e32f917d1..46b7cef59d 100644 --- a/api/v3/ActionSchedule.php +++ b/api/v3/ActionSchedule.php @@ -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 +} + +