From: Coleman Watts Date: Wed, 1 Apr 2015 02:10:13 +0000 (-0400) Subject: CRM-16208 - Clarify repeating event search and fix fatal error X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=27d7d241b417049c4e25bfd1e1b6915d7519d56a;p=civicrm-core.git CRM-16208 - Clarify repeating event search and fix fatal error --- diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index 6652c08b5e..c27adb1358 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -542,13 +542,18 @@ class CRM_Event_BAO_Query { $form->assign('dataURLEventFee', $dataURLEventFee); - $eventId = $form->addEntityRef('event_id', ts('Event Name'), array( + $form->addEntityRef('event_id', ts('Event Name'), array( 'entity' => 'event', 'placeholder' => ts('- any -'), 'select' => array('minimumInputLength' => 0), + 'api' => array( + 'params' => array( + 'api.RecurringEntity.getcount' => array('entity_id' => "\$value.id", 'entity_table' => "civicrm_event"), + ), + ), ) ); - $eventType = $form->addEntityRef('event_type_id', ts('Event Type'), array( + $form->addEntityRef('event_type_id', ts('Event Type'), array( 'entity' => 'option_value', 'placeholder' => ts('- any -'), 'select' => array('minimumInputLength' => 0), @@ -560,7 +565,8 @@ class CRM_Event_BAO_Query { $form->add('text', 'participant_fee_id', ts('Fee Level'), array('class' => 'big crm-ajax-select')); CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE); - $eventIncludeRepeatingEvents = &$form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include Repeating Events?')); + + $form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include participants from all events in the %1 series', array(1 => '%1'))); $form->addSelect('participant_status_id', array('entity' => 'participant', 'label' => ts('Participant Status'), 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')) diff --git a/api/v3/Activity.php b/api/v3/Activity.php index 946c631100..efa238d10a 100644 --- a/api/v3/Activity.php +++ b/api/v3/Activity.php @@ -483,9 +483,6 @@ function _civicrm_api3_activity_getlist_output($result, $request) { 1 => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['source_contact_id'], 'display_name'), )); } - foreach ($request['extra'] as $field) { - $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL; - } $output[] = $data; } } diff --git a/api/v3/Contact.php b/api/v3/Contact.php index aa4a693ed4..de305dd331 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -1133,9 +1133,6 @@ function _civicrm_api3_contact_getlist_output($result, $request) { else { $data['icon_class'] = $row['contact_type']; } - foreach ($request['extra'] as $field) { - $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL; - } $output[] = $data; } } diff --git a/api/v3/Event.php b/api/v3/Event.php index abff8e836b..79993cda4b 100644 --- a/api/v3/Event.php +++ b/api/v3/Event.php @@ -259,9 +259,6 @@ function _civicrm_api3_event_getlist_output($result, $request) { if (!empty($row['summary'])) { $data['description'][] = $row['summary']; } - foreach ($request['extra'] as $field) { - $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL; - } $output[] = $data; } } diff --git a/api/v3/Generic/Getlist.php b/api/v3/Generic/Getlist.php index 1774036773..8582f1515e 100644 --- a/api/v3/Generic/Getlist.php +++ b/api/v3/Generic/Getlist.php @@ -58,6 +58,8 @@ function civicrm_api3_generic_getList($apiRequest) { $fnName = function_exists($fnName) ? $fnName : '_civicrm_api3_generic_getlist_output'; $values = $fnName($result, $request); + _civicrm_api3_generic_getlist_postprocess($result, $request, $values); + $output = array('page_num' => $request['page_num']); // Limit is set for searching but not fetching by id @@ -176,15 +178,38 @@ function _civicrm_api3_generic_getlist_output($result, $request) { if (!empty($request['image_field'])) { $data['image'] = isset($row[$request['image_field']]) ? $row[$request['image_field']] : ''; } - foreach ($request['extra'] as $field) { - $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL; - } $output[] = $data; } } return $output; } +/** + * Common postprocess for getlist output + * + * @param $result + * @param $request + * @param $values + */ +function _civicrm_api3_generic_getlist_postprocess($result, $request, &$values) { + $chains = array(); + foreach ($request['params'] as $field => $param) { + if (substr($field, 0, 4) === 'api.') { + $chains[] = $field; + } + } + if (!empty($result['values'])) { + foreach (array_values($result['values']) as $num => $row) { + foreach ($request['extra'] as $field) { + $values[$num]['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL; + } + foreach ($chains as $chain) { + $values[$num][$chain] = isset($row[$chain]) ? $row[$chain] : NULL; + } + } + } +} + /** * Provide metadata for this api * diff --git a/api/v3/RecurringEntity.php b/api/v3/RecurringEntity.php new file mode 100644 index 0000000000..9ee0b572c0 --- /dev/null +++ b/api/v3/RecurringEntity.php @@ -0,0 +1,96 @@ + 'civicrm_event', + 'civicrm_activity' => 'civicrm_activity', + ); +} + +/** + * Add or update a recurring entity. + * + * @param array $params + * + * @return array + */ +function civicrm_api3_recurring_entity_create($params) { + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); +} + +/** + * Adjust Metadata for Create action. + * + * The metadata is used for setting defaults, documentation & validation. + * + * @param array $params + * Array of parameters determined by getfields. + */ +function _civicrm_api3_recurring_entity_create_spec(&$params) { + $params['entity_table']['options'] = array( + 'civicrm_event' => 'civicrm_event', + 'civicrm_activity' => 'civicrm_activity', + ); +} + +/** + * Deletes an existing ReportInstance. + * + * @param array $params + * + * @return array + */ +function civicrm_api3_recurring_entity_delete($params) { + return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); +} diff --git a/templates/CRM/Event/Form/Search/Common.tpl b/templates/CRM/Event/Form/Search/Common.tpl index 7d8e360778..47beaf83e0 100644 --- a/templates/CRM/Event/Form/Search/Common.tpl +++ b/templates/CRM/Event/Form/Search/Common.tpl @@ -25,8 +25,10 @@ *} - {$form.event_id.label}
{$form.event_id.html|crmAddClass:huge}
- {$form.event_include_repeating_events.label}  {$form.event_include_repeating_events.html} + {$form.event_id.label}
{$form.event_id.html|crmAddClass:huge} +
+ {$form.event_include_repeating_events.label}  {$form.event_include_repeating_events.html} +
{$form.event_type_id.label}
{$form.event_type_id.html} @@ -81,6 +83,18 @@ campaignTrClass='' campaignTdClass='crm-event-form-block-participant_campaign_id {literal}