Merge pull request #6345 from pradpnayak/CRM-15187
[civicrm-core.git] / api / v3 / Event.php
index df09a5767dc8d64dd87d5c21e1c15d68ccd1b6d5..4728270b45361f3c8dcc16dd2cae943839d67647 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -27,7 +27,7 @@
 
 /**
  *
- * This api exposes CiviCRM event.
+ * This api exposes CiviCRM Event.
  *
  * @package CiviCRM_APIv3
  */
@@ -115,7 +115,7 @@ function civicrm_api3_event_get($params) {
   }
 
   $eventDAO = new CRM_Event_BAO_Event();
-  _civicrm_api3_dao_set_filter($eventDAO, $params, TRUE, 'Event');
+  _civicrm_api3_dao_set_filter($eventDAO, $params, TRUE);
 
   if (!empty($params['isCurrent'])) {
     $eventDAO->whereAdd('(start_date >= CURDATE() || end_date >= CURDATE())');
@@ -141,7 +141,7 @@ function civicrm_api3_event_get($params) {
     }
   }
 
-  return civicrm_api3_create_success($event, $params, 'event', 'get', $eventDAO);
+  return civicrm_api3_create_success($event, $params, 'Event', 'get', $eventDAO);
 }
 
 /**
@@ -176,9 +176,9 @@ function _civicrm_api3_event_get_legacy_support_42(&$event, $event_id) {
 }
 
 /**
- * Delete an existing event.
+ * Delete an existing Event.
  *
- * This API is used for deleting a event.
+ * This API is used for deleting a event given its id.
  *
  * @param array $params
  *
@@ -259,8 +259,12 @@ 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;
+      // Add repeating info
+      $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['extra']['is_recur'] = TRUE;
       }
       $output[] = $data;
     }