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(
+ civicrm_api3_verify_mandatory($params, NULL, [
'start_date',
'title',
- array('event_type_id', 'template_id'),
- ));
+ ['event_type_id', 'template_id'],
+ ]);
}
// Required fields for creating an event template
elseif (empty($params['id']) && !empty($params['is_template'])) {
- civicrm_api3_verify_mandatory($params, NULL, array(
+ civicrm_api3_verify_mandatory($params, NULL, [
'template_title',
- ));
+ ]);
}
// Clone event from template
*/
function _civicrm_api3_event_create_spec(&$params) {
$params['is_active']['api.default'] = 1;
- $params['financial_type_id']['api.aliases'] = array('contribution_type_id');
+ $params['financial_type_id']['api.aliases'] = ['contribution_type_id'];
$params['is_template']['api.default'] = 0;
}
* Array of parameters determined by getfields.
*/
function _civicrm_api3_event_get_spec(&$params) {
- $params['financial_type_id']['api.aliases'] = array('contribution_type_id');
+ $params['financial_type_id']['api.aliases'] = ['contribution_type_id'];
}
/**
$event[$event_id]['is_full'] = $event[$event_id]['available_places'] == 0 ? 1 : 0;
}
-
/**
* Get event list parameters.
*
* @param array $request
*/
function _civicrm_api3_event_getlist_params(&$request) {
- $fieldsToReturn = array('start_date', 'event_type_id', 'title', 'summary');
+ $fieldsToReturn = ['start_date', 'event_type_id', 'title', 'summary'];
$request['params']['return'] = array_unique(array_merge($fieldsToReturn, $request['extra']));
$request['params']['options']['sort'] = 'start_date DESC';
if (empty($request['params']['id'])) {
- $request['params'] += array(
+ $request['params'] += [
'is_template' => 0,
'is_active' => 1,
- );
+ ];
}
}
* @return array
*/
function _civicrm_api3_event_getlist_output($result, $request) {
- $output = array();
+ $output = [];
if (!empty($result['values'])) {
foreach ($result['values'] as $row) {
- $data = array(
+ $data = [
'id' => $row[$request['id_field']],
'label' => $row[$request['label_field']],
- 'description' => array(
- CRM_Core_Pseudoconstant::getLabel(
- 'CRM_Event_BAO_Event',
- 'event_type_id',
- $row['event_type_id']
- ),
- ),
- );
+ 'description' => [
+ CRM_Core_PseudoConstant::getLabel('CRM_Event_BAO_Event', 'event_type_id', $row['event_type_id']),
+ ],
+ ];
if (!empty($row['start_date'])) {
$data['description'][0] .= ': ' . CRM_Utils_Date::customFormat($row['start_date']);
}
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['id'], 'civicrm_event');
$data['extra']['is_recur'] = FALSE;
if ($repeat) {
- $data['suffix'] = ts('(%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
+ $data['suffix'] = ts('(%1 of %2)', [1 => $repeat[0], 2 => $repeat[1]]);
$data['extra']['is_recur'] = TRUE;
}
$output[] = $data;