| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | +--------------------------------------------------------------------+ |
| 5 | | CiviCRM version 4.4 | |
| 6 | +--------------------------------------------------------------------+ |
| 7 | | Copyright CiviCRM LLC (c) 2004-2013 | |
| 8 | +--------------------------------------------------------------------+ |
| 9 | | This file is a part of CiviCRM. | |
| 10 | | | |
| 11 | | CiviCRM is free software; you can copy, modify, and distribute it | |
| 12 | | under the terms of the GNU Affero General Public License | |
| 13 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | |
| 14 | | | |
| 15 | | CiviCRM is distributed in the hope that it will be useful, but | |
| 16 | | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 18 | | See the GNU Affero General Public License for more details. | |
| 19 | | | |
| 20 | | You should have received a copy of the GNU Affero General Public | |
| 21 | | License and the CiviCRM Licensing Exception along | |
| 22 | | with this program; if not, contact CiviCRM LLC | |
| 23 | | at info[AT]civicrm[DOT]org. If you have questions about the | |
| 24 | | GNU Affero General Public License or the licensing of CiviCRM, | |
| 25 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | |
| 26 | +--------------------------------------------------------------------+ |
| 27 | */ |
| 28 | |
| 29 | /** |
| 30 | * File for the CiviCRM APIv3 participant functions |
| 31 | * |
| 32 | * @package CiviCRM_APIv3 |
| 33 | * @subpackage API_Participant |
| 34 | * |
| 35 | * @copyright CiviCRM LLC (c) 2004-2013 |
| 36 | * @version $Id: Participant.php 30486 2010-11-02 16:12:09Z shot $ |
| 37 | * |
| 38 | */ |
| 39 | |
| 40 | /** |
| 41 | * Files required for this package |
| 42 | */ |
| 43 | |
| 44 | /** |
| 45 | * Create a Event Participant Payment |
| 46 | * |
| 47 | * This API is used for creating a Participant Payment of Event. |
| 48 | * Required parameters : participant_id, contribution_id. |
| 49 | * |
| 50 | * @param array $params an associative array of name/value property values of civicrm_participant_payment |
| 51 | * @example ParticipantPaymentCreate.php |
| 52 | * {@example ParticipantPaymentCreate.php 0} |
| 53 | * |
| 54 | * @return array of newly created payment property values. |
| 55 | * {@getfields ParticipantPayment_create} |
| 56 | * @access public |
| 57 | */ |
| 58 | function civicrm_api3_participant_payment_create($params) { |
| 59 | |
| 60 | $ids = array(); |
| 61 | if (!empty($params['id'])) { |
| 62 | $ids['id'] = $params['id']; |
| 63 | } |
| 64 | $participantPayment = CRM_Event_BAO_ParticipantPayment::create($params, $ids); |
| 65 | |
| 66 | $payment = array(); |
| 67 | _civicrm_api3_object_to_array($participantPayment, $payment[$participantPayment->id]); |
| 68 | |
| 69 | return civicrm_api3_create_success($payment, $params); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Adjust Metadata for Create action |
| 74 | * |
| 75 | * The metadata is used for setting defaults, documentation & validation |
| 76 | * @param array $params array or parameters determined by getfields |
| 77 | */ |
| 78 | function _civicrm_api3_participant_payment_create_spec(&$params) { |
| 79 | $params['participant_id']['api.required'] = 1; |
| 80 | $params['contribution_id']['api.required'] = 1; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Deletes an existing Participant Payment |
| 85 | * |
| 86 | * This API is used for deleting a Participant Payment |
| 87 | * |
| 88 | * @param Int $participantPaymentID Id of the Participant Payment to be deleted |
| 89 | * |
| 90 | * @return array API result |
| 91 | * @example ParticipantPaymentDelete.php |
| 92 | * {@getfields ParticipantPayment_delete} |
| 93 | * @access public |
| 94 | */ |
| 95 | function civicrm_api3_participant_payment_delete($params) { |
| 96 | $participant = new CRM_Event_BAO_ParticipantPayment(); |
| 97 | return $participant->deleteParticipantPayment($params) ? civicrm_api3_create_success() : civicrm_api3_create_error('Error while deleting participantPayment'); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Retrieve one / all contribution(s) / participant(s) linked to a |
| 102 | * contrbution. |
| 103 | * |
| 104 | * @param array $params input parameters |
| 105 | * |
| 106 | * @return array array of properties, if error an array with an error id and error message |
| 107 | * @example ParticipantPaymentGet |
| 108 | * {@getfields ParticipantPayment_get} |
| 109 | * @access public |
| 110 | */ |
| 111 | function civicrm_api3_participant_payment_get($params) { |
| 112 | return _civicrm_api3_basic_get('CRM_Event_DAO_ParticipantPayment', $params); |
| 113 | } |
| 114 | |