3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * This class provides the functionality to delete a group of
38 * participations. This class provides functionality for the actual
41 class CRM_Event_Form_Task_Delete
extends CRM_Event_Form_Task
{
44 * Are we operating in "single mode", i.e. deleting one
45 * specific participation?
49 protected $_single = FALSE;
52 * Build all the data structures needed to build the form
56 public function preProcess() {
59 if (!CRM_Core_Permission
::checkActionPermission('CiviEvent', CRM_Core_Action
::DELETE
)) {
60 CRM_Core_Error
::fatal(ts('You do not have permission to access this page.'));
63 foreach ($this->_participantIds
as $participantId) {
64 if (CRM_Event_BAO_Participant
::isPrimaryParticipant($participantId)) {
65 $this->assign('additionalParticipants', TRUE);
71 * Build the form object
76 public function buildQuickForm() {
77 $deleteParticipants = array(
78 1 => ts('Delete this participant record along with associated participant record(s).'),
79 2 => ts('Delete only this participant record.'),
83 $this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />');
84 $this->setDefaults(array('delete_participant' => 1));
86 $this->addDefaultButtons(ts('Delete Participations'), 'done');
90 * Process the form after the input has been submitted and validated
95 public function postProcess() {
96 $params = $this->controller
->exportValues($this->_name
);
98 if (CRM_Utils_Array
::value('delete_participant', $params) == 2) {
100 foreach ($this->_participantIds
as $participantId) {
101 $additionalId = (CRM_Event_BAO_Participant
::getAdditionalParticipantIds($participantId));
102 $participantLinks = (CRM_Event_BAO_Participant
::getAdditionalParticipantUrl($additionalId));
105 $deletedParticipants = $additionalCount = 0;
106 foreach ($this->_participantIds
as $participantId) {
107 if (CRM_Utils_Array
::value('delete_participant', $params) == 1) {
108 if (CRM_Event_BAO_Participant
::isPrimaryParticipant($participantId)) {
109 $additionalIds = (CRM_Event_BAO_Participant
::getAdditionalParticipantIds($participantId));
110 $additionalCount = count($additionalIds);
111 foreach ($additionalIds as $value) {
112 CRM_Event_BAO_Participant
::deleteParticipant($value);
114 CRM_Event_BAO_Participant
::deleteParticipant($participantId);
116 $deletedParticipants++
;
119 CRM_Event_BAO_Participant
::deleteParticipant($participantId);
120 $deletedParticipants++
;
123 if ($additionalCount) {
124 $deletedParticipants +
= $additionalCount;
128 ts('Participant(s) Deleted: %1 (Total Selected: %2)', array(
129 1 => $deletedParticipants,
130 2 => count($this->_participantIds
)
133 if (!empty($participantLinks)) {
134 $status[] = ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') . '<br/>' . $participantLinks;
136 foreach ($status as $text) {
137 CRM_Core_Session
::setStatus($text, '', 'info');