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