Merge pull request #6378 from johanv/CRM-15991-permission_delete_relationship
[civicrm-core.git] / api / v3 / Event.php
index ae02240f4af5874436380a5b8d90b9bf209474bd..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.                                    |
  |                                                                    |
 
 /**
  *
- * File for the CiviCRM APIv3 event functions
+ * This api exposes CiviCRM Event.
  *
  * @package CiviCRM_APIv3
- * @subpackage API_Event
- *
- * @copyright CiviCRM LLC (c) 2004-2014
- * @version $Id: Event.php 30964 2010-11-29 09:41:54Z shot $
  */
 
 /**
@@ -65,7 +61,7 @@ function civicrm_api3_event_create($params) {
  * The metadata is used for setting defaults, documentation & validation.
  *
  * @param array $params
- *   Array or parameters determined by getfields.
+ *   Array of parameters determined by getfields.
  */
 function _civicrm_api3_event_create_spec(&$params) {
   $params['start_date']['api.required'] = 1;
@@ -119,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())');
@@ -145,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);
 }
 
 /**
@@ -154,7 +150,7 @@ function civicrm_api3_event_get($params) {
  * The metadata is used for setting defaults, documentation & validation.
  *
  * @param array $params
- *   Array or parameters determined by getfields.
+ *   Array of parameters determined by getfields.
  */
 function _civicrm_api3_event_get_spec(&$params) {
   $params['financial_type_id']['api.aliases'] = array('contribution_type_id');
@@ -180,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
  *
@@ -263,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;
     }