Merge pull request #17568 from agileware/CIVICRM-1496
[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 */
17
18/**
19 * This class provides the functionality for cancel registration for event participations
20 */
21class CRM_Event_Form_Task_Cancel extends CRM_Event_Form_Task {
22
23 /**
66f9e52b 24 * Variable to store redirect path.
90b461f1 25 * @var string
6a488035
TO
26 */
27 protected $_userContext;
28
29 /**
66f9e52b 30 * Build all the data structures needed to build the form.
6a488035
TO
31 *
32 * @return void
6a488035 33 */
00be9182 34 public function preProcess() {
c490a46a 35 // initialize the task and row fields
6a488035
TO
36 parent::preProcess();
37
38 $session = CRM_Core_Session::singleton();
39 $this->_userContext = $session->readUserContext();
40 }
41
42 /**
66f9e52b 43 * Build the form object.
6a488035 44 *
6a488035
TO
45 *
46 * @return void
47 */
00be9182 48 public function buildQuickForm() {
6a488035
TO
49 CRM_Utils_System::setTitle(ts('Cancel Registration for Event Participation'));
50 $session = CRM_Core_Session::singleton();
6b671aca 51 $this->addDefaultButtons(ts('Cancel Registrations'), 'done');
6a488035
TO
52 }
53
54 /**
66f9e52b 55 * Process the form after the input has been submitted and validated.
6a488035 56 *
6a488035 57 *
355ba699 58 * @return void
6a488035
TO
59 */
60 public function postProcess() {
61 $params = $this->exportValues();
be2fb01f 62 $value = [];
6a488035
TO
63
64 foreach ($this->_participantIds as $participantId) {
65 $value['id'] = $participantId;
66
67 // Cancelled status id = 4
68 $value['status_id'] = 4;
69 CRM_Event_BAO_Participant::create($value);
70 }
71 }
96025800 72
6a488035 73}