3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
32 * @copyright CiviCRM LLC (c) 2004-2014
36 class CRM_Event_BAO_ParticipantPayment
extends CRM_Event_DAO_ParticipantPayment
{
39 * Creates or updates a participant payment record
41 * @param $params array of values to initialize the record with
42 * @param $ids array with one values of id for this participantPayment record (for update)
44 * @return object the partcipant payment record
47 static function &create(&$params, &$ids) {
48 if (isset($ids['id'])) {
49 CRM_Utils_Hook
::pre('edit', 'ParticipantPayment', $ids['id'], $params);
52 CRM_Utils_Hook
::pre('create', 'ParticipantPayment', NULL, $params);
55 $participantPayment = new CRM_Event_BAO_ParticipantPayment();
56 $participantPayment->copyValues($params);
57 if (isset($ids['id'])) {
58 $participantPayment->id
= CRM_Utils_Array
::value('id', $ids);
61 $participantPayment->find(TRUE);
63 $participantPayment->save();
65 if (isset($ids['id'])) {
66 CRM_Utils_Hook
::post('edit', 'ParticipantPayment', $ids['id'], $participantPayment);
69 CRM_Utils_Hook
::post('create', 'ParticipantPayment', NULL, $participantPayment);
72 return $participantPayment;
76 * Delete the record that are associated with this ParticipantPayment
77 * Also deletes the associated contribution for this participant
79 * @param array $params associative array whose values match the record to be deleted
81 * @return boolean true if deleted false otherwise
85 static function deleteParticipantPayment($params) {
86 $participantPayment = new CRM_Event_DAO_ParticipantPayment();
89 foreach ($params as $field => $value) {
91 $participantPayment->$field = $value;
97 CRM_Core_Error
::fatal();
100 if ($participantPayment->find(TRUE)) {
101 CRM_Utils_Hook
::pre('delete', 'ParticipantPayment', $participantPayment->id
, $params);
102 CRM_Contribute_BAO_Contribution
::deleteContribution($participantPayment->contribution_id
);
103 $participantPayment->delete();
104 CRM_Utils_Hook
::post('delete', 'ParticipantPayment', $participantPayment->id
, $participantPayment);
105 return $participantPayment;