/** * Get Event record. * * * @param array $params an associative array of name/value property values of civicrm_event * {@getfields event_get} * * @return Array of all found event property values. * @access public * */ function civicrm_api3_event_get($params) { //legacy support for $params['return.sort'] if (!empty($params['return.sort'])) { $params['options']['sort'] = $params['return.sort']; unset($params['return.sort']); } //legacy support for $params['return.offset'] if (!empty($params['return.offset'])) { $params['options']['offset'] = $params['return.offset']; unset($params['return.offset']); } //legacy support for $params['return.max_results'] if (!empty($params['return.max_results'])) { $params['options']['limit'] = $params['return.max_results']; unset($params['return.max_results']); } $eventDAO = new CRM_Event_BAO_Event(); _civicrm_api3_dao_set_filter($eventDAO, $params, TRUE, 'Event'); if (!empty($params['is_template'])) { $eventDAO->whereAdd('( is_template = 1 )'); } elseif (empty($eventDAO->id)) { $eventDAO->whereAdd('( is_template IS NULL ) OR ( is_template = 0 )'); } if (!empty($params['isCurrent'])) { $eventDAO->whereAdd('(start_date >= CURDATE() || end_date >= CURDATE())'); } // @todo should replace all this with _civicrm_api3_dao_to_array($bao, $params, FALSE, $entity) - but we still have // the return.is_full to deal with. // NB the std dao_to_array function should only return custom if required. $event = array(); $eventDAO->find(); while ($eventDAO->fetch()) { $event[$eventDAO->id] = array(); CRM_Core_DAO::storeValues($eventDAO, $event[$eventDAO->id]); if (!empty($params['return.is_full'])) { _civicrm_api3_event_getisfull($event, $eventDAO->id); } _civicrm_api3_event_get_legacy_support_42($event, $eventDAO->id); _civicrm_api3_custom_data_get($event[$eventDAO->id], 'Event', $eventDAO->id, NULL, $eventDAO->event_type_id); } //end of the loop return civicrm_api3_create_success($event, $params, 'event', 'get', $eventDAO); }
/** * Get Event record. * * @param array $params * * @return array * Array of all found event property values. */ function civicrm_api3_event_get($params) { //legacy support for $params['return.sort'] if (!empty($params['return.sort'])) { $params['options']['sort'] = $params['return.sort']; unset($params['return.sort']); } //legacy support for $params['return.offset'] if (!empty($params['return.offset'])) { $params['options']['offset'] = $params['return.offset']; unset($params['return.offset']); } //legacy support for $params['return.max_results'] if (!empty($params['return.max_results'])) { $params['options']['limit'] = $params['return.max_results']; unset($params['return.max_results']); } $sql = CRM_Utils_SQL_Select::fragment(); if (!empty($params['isCurrent'])) { $sql->where('(start_date >= CURDATE() || end_date >= CURDATE())'); } $events = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Event', $sql, TRUE); $options = _civicrm_api3_get_options_from_params($params); if ($options['is_count']) { return civicrm_api3_create_success($events, $params, 'Event', 'get'); } foreach ($events as $id => $event) { if (!empty($params['return.is_full'])) { _civicrm_api3_event_getisfull($events, $id); } _civicrm_api3_event_get_legacy_support_42($events, $id); if (!empty($options['return'])) { $events[$id]['price_set_id'] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $id); } } return civicrm_api3_create_success($events, $params, 'Event', 'get'); }