Merge pull request #16161 from civicrm/5.21
[civicrm-core.git] / CRM / Event / Form / Task / Cancel.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 * $Id$
17 *
18 */
19
20/**
21 * This class provides the functionality for cancel registration for event participations
22 */
23class CRM_Event_Form_Task_Cancel extends CRM_Event_Form_Task {
24
25 /**
66f9e52b 26 * Variable to store redirect path.
90b461f1 27 * @var string
6a488035
TO
28 */
29 protected $_userContext;
30
31 /**
66f9e52b 32 * Build all the data structures needed to build the form.
6a488035
TO
33 *
34 * @return void
6a488035 35 */
00be9182 36 public function preProcess() {
c490a46a 37 // initialize the task and row fields
6a488035
TO
38 parent::preProcess();
39
40 $session = CRM_Core_Session::singleton();
41 $this->_userContext = $session->readUserContext();
42 }
43
44 /**
66f9e52b 45 * Build the form object.
6a488035 46 *
6a488035
TO
47 *
48 * @return void
49 */
00be9182 50 public function buildQuickForm() {
6a488035
TO
51 CRM_Utils_System::setTitle(ts('Cancel Registration for Event Participation'));
52 $session = CRM_Core_Session::singleton();
6b671aca 53 $this->addDefaultButtons(ts('Cancel Registrations'), 'done');
6a488035
TO
54 }
55
56 /**
66f9e52b 57 * Process the form after the input has been submitted and validated.
6a488035 58 *
6a488035 59 *
355ba699 60 * @return void
6a488035
TO
61 */
62 public function postProcess() {
63 $params = $this->exportValues();
be2fb01f 64 $value = [];
6a488035
TO
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 }
96025800 74
6a488035 75}