Merge pull request #18449 from colemanw/multiValueAutocomplete
[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 */
17
18 /**
19 * This class provides the functionality for cancel registration for event participations
20 */
21 class CRM_Event_Form_Task_Cancel extends CRM_Event_Form_Task {
22
23 /**
24 * Variable to store redirect path.
25 * @var string
26 */
27 protected $_userContext;
28
29 /**
30 * Build all the data structures needed to build the form.
31 *
32 * @return void
33 */
34 public function preProcess() {
35 // initialize the task and row fields
36 parent::preProcess();
37
38 $session = CRM_Core_Session::singleton();
39 $this->_userContext = $session->readUserContext();
40 }
41
42 /**
43 * Build the form object.
44 *
45 *
46 * @return void
47 */
48 public function buildQuickForm() {
49 CRM_Utils_System::setTitle(ts('Cancel Registration for Event Participation'));
50 $session = CRM_Core_Session::singleton();
51 $this->addDefaultButtons(ts('Cancel Registrations'), 'done');
52 }
53
54 /**
55 * Process the form after the input has been submitted and validated.
56 *
57 *
58 * @return void
59 */
60 public function postProcess() {
61 $params = $this->exportValues();
62 $value = [];
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 }
72
73 }