Merge pull request #2674 from deepak-srivastava/CRM-12467-soft-credit-search
[civicrm-core.git] / api / v3 / Participant.php
index 6a18be78b0a98a45d82da63f4a692a0a8c8e4d33..aa1daa8af1ca8f8b4fe7e95ebebddf6031bb70f1 100644 (file)
@@ -1,9 +1,8 @@
 <?php
-// $Id$
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -57,7 +56,7 @@
  */
 function civicrm_api3_participant_create($params) {
   //check that event id is not an template - should be done @ BAO layer
-  if (CRM_Utils_Array::value('event_id', $params)) {
+  if (!empty($params['event_id'])) {
     $isTemplate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'is_template');
     if (!empty($isTemplate)) {
       return civicrm_api3_create_error(ts('Event templates are not meant to be registered'));
@@ -70,7 +69,7 @@ function civicrm_api3_participant_create($params) {
 
   $participantBAO = CRM_Event_BAO_Participant::create($params);
 
-  if(empty($params['price_set_id']) && empty($params['id']) && CRM_Utils_Array::value('fee_level', $params)){
+  if(empty($params['price_set_id']) && empty($params['id']) && !empty($params['fee_level'])){
     _civicrm_api3_participant_createlineitem($params, $participantBAO);
   }
   _civicrm_api3_object_to_array($participantBAO, $participant[$participantBAO->id]);
@@ -78,7 +77,7 @@ function civicrm_api3_participant_create($params) {
   return civicrm_api3_create_success($participant, $params, 'participant', 'create', $participantBAO);
 }
 
-/*
+/**
  * Create a default participant line item
  */
 function _civicrm_api3_participant_createlineitem(&$params, $participant){
@@ -111,7 +110,7 @@ where ps.id is not null
 }
 
 
-/*
+/**
  * Adjust Metadata for Create action
  *
  * The metadata is used for setting defaults, documentation & validation
@@ -122,6 +121,9 @@ function _civicrm_api3_participant_create_spec(&$params) {
   $params['register_date']['api.default'] = "now";
   $params['event_id']['api.required'] = 1;
   $params['contact_id']['api.required'] = 1;
+  // These are for the sake of search builder options - can be removed if that is fixed
+  $params['role_id']['api.aliases'] = array('participant_role');
+  $params['status_id']['api.aliases'] = array('participant_status');
 }
 
 /**
@@ -171,7 +173,7 @@ function civicrm_api3_participant_get($params) {
   return civicrm_api3_create_success($participant, $params, 'participant', 'get', $dao);
 }
 
-/*
+/**
  * Adjust Metadata for Get action
  *
  * The metadata is used for setting defaults, documentation & validation