Merge pull request #16052 from eileenmcnaughton/desc
[civicrm-core.git] / CRM / Event / Form / Task / Cancel.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 * $Id$
17 *
18 */
19
20 /**
21 * This class provides the functionality for cancel registration for event participations
22 */
23 class CRM_Event_Form_Task_Cancel extends CRM_Event_Form_Task {
24
25 /**
26 * Variable to store redirect path.
27 * @var string
28 */
29 protected $_userContext;
30
31 /**
32 * Build all the data structures needed to build the form.
33 *
34 * @return void
35 */
36 public function preProcess() {
37 // initialize the task and row fields
38 parent::preProcess();
39
40 $session = CRM_Core_Session::singleton();
41 $this->_userContext = $session->readUserContext();
42 }
43
44 /**
45 * Build the form object.
46 *
47 *
48 * @return void
49 */
50 public function buildQuickForm() {
51 CRM_Utils_System::setTitle(ts('Cancel Registration for Event Participation'));
52 $session = CRM_Core_Session::singleton();
53 $this->addDefaultButtons(ts('Cancel Registrations'), 'done');
54 }
55
56 /**
57 * Process the form after the input has been submitted and validated.
58 *
59 *
60 * @return void
61 */
62 public function postProcess() {
63 $params = $this->exportValues();
64 $value = [];
65
66 foreach ($this->_participantIds as $participantId) {
67 $value['id'] = $participantId;
68
69 // Cancelled status id = 4
70 $value['status_id'] = 4;
71 CRM_Event_BAO_Participant::create($value);
72 }
73 }
74
75 }