X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=api%2Fv3%2FEvent.php;h=0566c134f015d23b63889f7b1b6bd2fb26113c55;hb=85bb0909cffd925f4cd5c0022a68a1ff74d3ad8e;hp=359afee5d2cce46ff9b082e196eb2d5e99dac7cf;hpb=9c7c6a00156aa0b0278446bc45c4e6c8ea710417;p=civicrm-core.git diff --git a/api/v3/Event.php b/api/v3/Event.php index 359afee5d2..0566c134f0 100644 --- a/api/v3/Event.php +++ b/api/v3/Event.php @@ -2,9 +2,9 @@ /* +--------------------------------------------------------------------+ - | CiviCRM version 4.4 | + | CiviCRM version 4.5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2013 | + | Copyright CiviCRM LLC (c) 2004-2014 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -33,7 +33,7 @@ * @package CiviCRM_APIv3 * @subpackage API_Event * - * @copyright CiviCRM LLC (c) 2004-2013 + * @copyright CiviCRM LLC (c) 2004-2014 * @version $Id: Event.php 30964 2010-11-29 09:41:54Z shot $ * */ @@ -62,22 +62,10 @@ function civicrm_api3_event_create($params) { $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); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Event'); } /** @@ -154,6 +142,8 @@ function civicrm_api3_event_get($params) { // the return.is_full to deal with. // NB the std dao_to_array function should only return custom if required. $event = array(); + $options = _civicrm_api3_get_options_from_params($params); + $eventDAO->find(); while ($eventDAO->fetch()) { $event[$eventDAO->id] = array(); @@ -163,6 +153,9 @@ function civicrm_api3_event_get($params) { } _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); + if(!empty($options['return'])) { + $event[$eventDAO->id]['price_set_id'] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventDAO->id); + } } //end of the loop @@ -220,6 +213,10 @@ function civicrm_api3_event_delete($params) { * @param int $event_id Id of the event to be updated * */ +/** + * @param $event + * @param $event_id + */ function _civicrm_api3_event_getisfull(&$event, $event_id) { $eventFullResult = CRM_Event_BAO_Participant::eventFull($event_id, 1); if (!empty($eventFullResult) && is_int($eventFullResult)) { @@ -233,12 +230,13 @@ function _civicrm_api3_event_getisfull(&$event, $event_id) { /** - * Overrides _civicrm_api3_generic_getlist_params. + * @see _civicrm_api3_generic_getlist_params. * * @param $request array */ function _civicrm_api3_event_getlist_params(&$request) { - $request['params']['return'] = array('start_date', 'event_type_id', 'title', 'summary'); + $fieldsToReturn = array('start_date', 'event_type_id', 'title', 'summary'); + $request['params']['return'] = array_unique(array_merge($fieldsToReturn, $request['extra'])); $request['params']['options']['sort'] = 'start_date DESC'; $request['params'] += array( 'is_template' => 0, @@ -247,7 +245,7 @@ function _civicrm_api3_event_getlist_params(&$request) { } /** - * Overrides _civicrm_api3_generic_getlist_output + * @see _civicrm_api3_generic_getlist_output * * @param $result array * @param $request array @@ -261,13 +259,16 @@ function _civicrm_api3_event_getlist_output($result, $request) { $data = array( 'id' => $row[$request['id_field']], 'label' => $row[$request['label_field']], - 'description' => CRM_Core_Pseudoconstant::getLabel('CRM_Event_BAO_Event', 'event_type_id', $row['event_type_id']), + 'description' => array(CRM_Core_Pseudoconstant::getLabel('CRM_Event_BAO_Event', 'event_type_id', $row['event_type_id'])), ); if (!empty($row['start_date'])) { - $data['description'] .= ': ' . CRM_Utils_Date::customFormat($row['start_date']); + $data['description'][0] .= ': ' . CRM_Utils_Date::customFormat($row['start_date']); } if (!empty($row['summary'])) { - $data['description'] .= '
' . $row['summary']; + $data['description'][] = $row['summary']; + } + foreach ($request['extra'] as $field) { + $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL; } $output[] = $data; }