Merge pull request #2714 from jitendrapurohit/CRMTestFix
[civicrm-core.git] / api / v3 / Event.php
index 359afee5d2cce46ff9b082e196eb2d5e99dac7cf..37979f81edcd9daa9a38afe5f1f8a8011373ec12 100644 (file)
@@ -233,12 +233,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 +248,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 +262,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'] .= '<br />' . $row['summary'];
+        $data['description'][] = $row['summary'];
+      }
+      foreach ($request['extra'] as $field) {
+        $data['extra'][$field] = isset($row[$field]) ? $row[$field] : NULL;
       }
       $output[] = $data;
     }