/** * Create an Event Participant. * * @param array $params * An associative array of name/value property values of civicrm_participant. * * @return array * API result array */ function civicrm_api3_participant_create($params) { // Check that event id is not an template - should be done @ BAO layer. if (!empty($params['event_id'])) { $isTemplate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'is_template'); if (!empty($isTemplate)) { return civicrm_api3_create_error(ts('Event templates are not meant to be registered.')); } } $values = $participant = array(); _civicrm_api3_custom_format_params($params, $values, 'Participant'); $params = array_merge($values, $params); $participantBAO = CRM_Event_BAO_Participant::create($params); if (empty($params['price_set_id']) && empty($params['id']) && !empty($params['fee_level'])) { _civicrm_api3_participant_createlineitem($params, $participantBAO); } _civicrm_api3_object_to_array($participantBAO, $participant[$participantBAO->id]); return civicrm_api3_create_success($participant, $params, 'Participant', 'create', $participantBAO); }
/** * Create an Event Participant * * This API is used for creating a participants in an event. * Required parameters : event_id AND contact_id for new creation * : participant as name/value with participantid for edit * * @param array $params an associative array of name/value property values of civicrm_participant * * @return array apiresult * {@getfields participant_create} * @access public */ function civicrm_api3_participant_create($params) { //check that event id is not an template // note that check duplicate check was removed as it wasn't actually being called. //check contact exists removed as belongs @ wrapper layer if (CRM_Utils_Array::value('event_id', $params)) { $isTemplate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'is_template'); if (!empty($isTemplate)) { return civicrm_api3_create_error(ts('Event templates are not meant to be registered')); } } $value = array(); _civicrm_api3_custom_format_params($params, $values, 'Participant'); $params = array_merge($values, $params); require_once 'CRM/Event/BAO/Participant.php'; $participantBAO = CRM_Event_BAO_Participant::create($params); if (empty($params['price_set_id']) && empty($params['id']) && CRM_Utils_Array::value('fee_level', $params)) { _civicrm_api3_participant_createlineitem($params, $participantBAO); } _civicrm_api3_object_to_array($participantBAO, $participant[$participantBAO->id]); return civicrm_api3_create_success($participant, $params, 'participant', 'create', $participantBAO); }