Ejemplo n.º 1
0
/**
 * Create a Event
 *
 * This API is used for creating a Event
 *
 * @param  array   $params   input parameters
 * Allowed @params array keys are:
 * {@getfields event_create}
 *
 * @return array API result Array.
 * @access public
 */
function civicrm_api3_event_create($params)
{
    civicrm_api3_verify_one_mandatory($params, NULL, array('event_type_id', 'template_id'));
    // Clone event from template
    if (!empty($params['template_id']) && empty($params['id'])) {
        $copy = CRM_Event_BAO_Event::copy($params['template_id']);
        $params['id'] = $copy->id;
        unset($params['template_id']);
    }
    _civicrm_api3_event_create_legacy_support_42($params);
    return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Event');
}
Ejemplo n.º 2
0
/**
 * Create a Event
 *
 * This API is used for creating a Event
 *
 * @param  array   $params   input parameters
 * Allowed @params array keys are:
 * {@getfields event_create}
 *
 * @return array API result Array.
 * @access public
 */
function civicrm_api3_event_create($params)
{
    _civicrm_api3_event_create_legacy_support_42($params);
    //format custom fields so they can be added
    $value = array();
    _civicrm_api3_custom_format_params($params, $values, 'Event');
    $params = array_merge($values, $params);
    require_once 'CRM/Event/BAO/Event.php';
    $eventBAO = CRM_Event_BAO_Event::create($params);
    $event = array();
    _civicrm_api3_object_to_array($eventBAO, $event[$eventBAO->id]);
    return civicrm_api3_create_success($event, $params);
}
Ejemplo n.º 3
0
/**
 * Create a Event.
 *
 * @param array $params
 *   Input parameters.
 *
 * @return array
 *   API result Array.
 */
function civicrm_api3_event_create($params)
{
    // Required fields for creating an event
    if (empty($params['id']) && empty($params['is_template'])) {
        civicrm_api3_verify_mandatory($params, NULL, array('start_date', 'title', array('event_type_id', 'template_id')));
    } elseif (empty($params['id']) && !empty($params['is_template'])) {
        civicrm_api3_verify_mandatory($params, NULL, array('template_title'));
    }
    // Clone event from template
    if (!empty($params['template_id']) && empty($params['id'])) {
        $copy = CRM_Event_BAO_Event::copy($params['template_id']);
        $params['id'] = $copy->id;
        unset($params['template_id']);
    }
    _civicrm_api3_event_create_legacy_support_42($params);
    return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Event');
}
Ejemplo n.º 4
0
/**
 * Create a Event
 *
 * This API is used for creating a Event
 *
 * @param  array   $params   input parameters
 * Allowed @params array keys are:
 * {@getfields event_create}
 *
 * @return array API result Array.
 * @access public
 */
function civicrm_api3_event_create($params)
{
    civicrm_api3_verify_one_mandatory($params, NULL, array('event_type_id', 'template_id'));
    // Clone event from template
    if (!empty($params['template_id']) && empty($params['id'])) {
        $copy = CRM_Event_BAO_Event::copy($params['template_id']);
        $params['id'] = $copy->id;
        unset($params['template_id']);
        if (empty($params['is_template'])) {
            $params['is_template'] = 0;
        }
    }
    _civicrm_api3_event_create_legacy_support_42($params);
    //format custom fields so they can be added
    $values = array();
    _civicrm_api3_custom_format_params($params, $values, 'Event');
    $params = array_merge($values, $params);
    $eventBAO = CRM_Event_BAO_Event::create($params);
    $event = array();
    _civicrm_api3_object_to_array($eventBAO, $event[$eventBAO->id]);
    return civicrm_api3_create_success($event, $params);
}