Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-01-26-14-28-00
[civicrm-core.git] / api / v3 / Participant.php
index 790b3d16f09c25bdd66dce741242b36f2d0315bb..2d4742bddede9071969218929d1cb53b3e35039c 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  *
  */
 
-/**
- * Files required for this package
- */
-
 /**
  * Create an Event Participant
  *
@@ -51,9 +46,9 @@
  * @param array $params
  *   An associative array of name/value property values of civicrm_participant.
  *
- * @return array apiresult
- * {@getfields participant_create}
- * @access public
+ * @return array
+ *   apiresult
+ *   {@getfields participant_create}
  */
 function civicrm_api3_participant_create($params) {
   //check that event id is not an template - should be done @ BAO layer
@@ -64,7 +59,7 @@ function civicrm_api3_participant_create($params) {
     }
   }
 
-  $value = array();
+  $values = $participant = array();
   _civicrm_api3_custom_format_params($params, $values, 'Participant');
   $params = array_merge($values, $params);
 
@@ -79,7 +74,11 @@ function civicrm_api3_participant_create($params) {
 }
 
 /**
+ * @todo this should be done in the BAO not the api
  * Create a default participant line item
+ * @param array $params
+ * @param $participant
+ * @throws \CiviCRM_API3_Exception
  */
 function _civicrm_api3_participant_createlineitem(&$params, $participant) {
   // it is possible that a fee level contains information about multiple
@@ -119,7 +118,7 @@ function _civicrm_api3_participant_createlineitem(&$params, $participant) {
 
     $dao = CRM_Core_DAO::executeQuery($sql, $qParams);
     if ($dao->fetch()) {
-      $lineItemparams = array(
+      $lineItemParams = array(
         'price_field_id' => $dao->priceFieldID,
         'price_field_value_id' => $dao->priceFieldValueID,
         'entity_table' => 'civicrm_participant',
@@ -129,9 +128,8 @@ function _civicrm_api3_participant_createlineitem(&$params, $participant) {
         'participant_count' => 0,
         'unit_price' => $dao->amount,
         'line_total' => $qty * $dao->amount,
-        'version' => 3,
       );
-      civicrm_api('line_item', 'create', $lineItemparams);
+      civicrm_api3('line_item', 'create', $lineItemParams);
     }
 
   }
@@ -163,9 +161,9 @@ function _civicrm_api3_participant_create_spec(&$params) {
  * @param array $params
  *   (reference ) input parameters.
  *
- * @return array (reference )        array of properties, if error an array with an error id and error message
- * {@getfields participant_get}
- * @access public
+ * @return array
+ *   (reference )        array of properties, if error an array with an error id and error message
+ *   {@getfields participant_get}
  */
 function civicrm_api3_participant_get($params) {
   $mode = CRM_Contact_BAO_Query::MODE_EVENT;
@@ -206,7 +204,6 @@ function _civicrm_api3_participant_get_spec(&$params) {
  * {@getfields participant_delete}
  * @throws Exception
  * @return array
- * @access public
  */
 function civicrm_api3_participant_delete($params) {