X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FActionSchedule.php;h=5d1e145013d1384fa3229a6a330cc1c0bf942ecf;hb=ba4d65467bdf14b7ac4d5efce468f5e4867129f9;hp=ab92a06b2ff21eaf5241d4cb74cb1a4fc2c110c1;hpb=5bd361934f5dd97d2e3ef40d15f0946541e546cb;p=civicrm-core.git diff --git a/api/v3/ActionSchedule.php b/api/v3/ActionSchedule.php index ab92a06b2f..5d1e145013 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,22 +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']); + } + $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); } @@ -99,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 +} + +