ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilBTControllerGUI.php
Go to the documentation of this file.
1<?php
2
4use ILIAS\Modules\OrgUnit\ARHelper\DIC;
5
13{
14 use DIC;
15 const FROM_URL = 'from_url';
16 const OBSERVER_ID = 'observer_id';
17 const SELECTED_OPTION = 'selected_option';
18 const REPLACE_SIGNAL = 'replaceSignal';
19 const CMD_ABORT = 'abortBucket';
20 const CMD_REMOVE = 'abortBucket';
21 const CMD_GET_POPOVER_CONTENT = 'getPopoverContent';
22 const CMD_USER_INTERACTION = 'userInteraction';
23
24
25 public function executeCommand()
26 {
27 switch ($this->ctrl()->getCmdClass()) {
28 default:
29 $this->performCommand();
30 }
31 }
32
33
34 protected function performCommand()
35 {
36 $cmd = $this->ctrl()->getCmd();
37 switch ($cmd) {
40 case self::CMD_ABORT:
42 $this->$cmd();
43 }
44 }
45
46
47 protected function userInteraction()
48 {
49 $observer_id = (int) $this->http()->request()->getQueryParams()[self::OBSERVER_ID];
50 $selected_option = $this->http()->request()->getQueryParams()[self::SELECTED_OPTION];
51 $from_url = $this->getFromURL();
52
53 $observer = $this->dic()->backgroundTasks()->persistence()->loadBucket($observer_id);
54 $option = new UserInteractionOption("", $selected_option);
55 $this->dic()->backgroundTasks()->taskManager()->continueTask($observer, $option);
56 $this->ctrl()->redirectToURL($from_url);
57 }
58
59
60 protected function abortBucket()
61 {
62 $observer_id = (int) $this->http()->request()->getQueryParams()[self::OBSERVER_ID];
63 $from_url = $this->getFromURL();
64
65 $bucket = $this->dic()->backgroundTasks()->persistence()->loadBucket($observer_id);
66
67 $this->dic()->backgroundTasks()->taskManager()->quitBucket($bucket);
68
69 $this->ctrl()->redirectToURL($from_url);
70 }
71
72
73 protected function getPopoverContent()
74 {
76 $gui = $this->dic()->backgroundTasks()->injector()->createInstance(ilBTPopOverGUI::class);
77 $signal_id = $this->http()->request()->getQueryParams()[self::REPLACE_SIGNAL];
78
79 $this->ctrl()
80 ->setParameterByClass(ilBTControllerGUI::class, self::REPLACE_SIGNAL, $signal_id);
81
82 $replace_url = $this->ctrl()
83 ->getLinkTargetByClass([ ilBTControllerGUI::class ], self::CMD_GET_POPOVER_CONTENT, "", true);
84
85 echo $this->ui()->renderer()->renderAsync($gui->getPopOverContent($this->user()
86 ->getId(), $this->getFromURL(), $replace_url));
87 }
88
89
93 protected function getFromURL()
94 {
95 $from_url = self::unhash($this->http()->request()->getQueryParams()[self::FROM_URL]);
96
97 return $from_url;
98 }
99
100
106 public static function hash($url)
107 {
108 return base64_encode($url);
109 }
110
111
117 public static function unhash($url)
118 {
119 return base64_decode($url);
120 }
121}
An exception for terminatinating execution or to throw for unit testing.
Class ilBTControllerGUI.
static http()
Fetches the global http state from ILIAS.
$url