ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCommonActionDispatcherGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29{
30 public const TYPE_REPOSITORY = 1;
31 public const TYPE_WORKSPACE = 2;
32
33 protected ilCtrl $ctrl;
37
38 protected int $node_type = 0;
42 protected $access_handler;
43 protected string $obj_type = "";
44 protected int $node_id = 0;
45 protected int $obj_id = 0;
46 protected int $news_id = 0;
47
48 protected ?string $sub_type = null;
49 protected ?int $sub_id = null;
50 protected bool $enable_comments_settings = false;
51 protected array $rating_callback = [];
53
54 public function __construct(
55 int $node_type,
57 string $obj_type,
58 int $node_id,
59 int $obj_id,
60 int $news_id = 0
61 ) {
62 global $DIC;
63
64 $this->ctrl = $DIC->ctrl();
65 $this->settings = $DIC->settings();
66 $this->request_wrapper = $DIC->http()->wrapper()->query();
67 $this->refinery = $DIC->refinery();
68 $this->retriever = new ilObjectRequestRetriever($DIC->http()->wrapper(), $this->refinery);
69
70 $this->node_type = $node_type;
71 $this->access_handler = $access_handler;
72 $this->obj_type = $obj_type;
73 $this->node_id = $node_id;
74 $this->obj_id = $obj_id;
75 $this->news_id = $news_id;
76 }
77
81 public function getAjaxHash(): string
82 {
84 $this->node_type,
85 $this->node_id,
86 $this->obj_type,
87 $this->obj_id,
88 $this->sub_type,
89 $this->sub_id,
90 $this->news_id
91 );
92 }
93
97 public static function buildAjaxHash(
98 int $node_type,
99 ?int $node_id,
100 string $obj_type,
101 int $obj_id,
102 ?string $sub_type = null,
103 ?int $sub_id = null,
104 int $news_id = 0
105 ): string {
106 return
107 $node_type . ";" . $node_id . ";" . $obj_type . ";" . $obj_id . ";" .
108 $sub_type . ";" . $sub_id . ";" . $news_id
109 ;
110 }
111
112 public static function removeSubObjFromAjaxHash(string $hash): string
113 {
114 $arr = explode(";", $hash);
115 if (isset($arr[4]) && isset($arr[5])) {
116 $arr[4] = "";
117 $arr[5] = "";
118 }
119 return implode(";", $arr);
120 }
121
126 {
127 global $DIC;
128
129 $ilAccess = $DIC->access();
130 $ilUser = $DIC->user();
131 $request_wrapper = $DIC->http()->wrapper()->query();
132 $refinery = $DIC->refinery();
133
134 if ($request_wrapper->has("cadh")) {
135 $parts = explode(";", $request_wrapper->retrieve("cadh", $refinery->kindlyTo()->string()));
136
137 $node_type = (int) $parts[0];
138 $node_id = (int) $parts[1];
139 $obj_type = (string) $parts[2];
140 $obj_id = (int) $parts[3];
141 $sub_type = (string) $parts[4];
142 $sub_id = (int) $parts[5];
143 $news_id = (int) $parts[6];
144
145 switch ($node_type) {
146 case self::TYPE_REPOSITORY:
147 $access_handler = $ilAccess;
148 break;
149
150 case self::TYPE_WORKSPACE:
151 $tree = new ilWorkspaceTree($ilUser->getId());
152 $access_handler = new ilWorkspaceAccessHandler($tree);
153 break;
154
155 default:
156 return null;
157 }
158
159 $dispatcher = new self($node_type, $access_handler, $obj_type, $node_id, $obj_id, $news_id);
160
161 if ($sub_type && $sub_id) {
162 $dispatcher->setSubObject($sub_type, $sub_id);
163 }
164
165 // poll comments have specific settings
166
167 if ($node_type == self::TYPE_REPOSITORY && $obj_type != "poll") {
168 $dispatcher->enableCommentsSettings(true);
169 }
170
171 return $dispatcher;
172 }
173 return null;
174 }
175
176 public function executeCommand(): void
177 {
178 // check access for object
179 if (
180 $this->node_id &&
181 !$this->access_handler->checkAccess("visible", "", $this->node_id) &&
182 !$this->access_handler->checkAccess("read", "", $this->node_id)
183 ) {
184 exit();
185 }
186
187 $next_class = $this->ctrl->getNextClass($this);
188
189 $this->ctrl->saveParameter($this, "cadh");
190
191 switch ($next_class) {
192 case "ilnotegui":
193
194 $obj_type = $this->obj_type;
195 if ($this->sub_type) {
196 $obj_type = $this->sub_type;
197 }
198
199 $note_gui = new ilNoteGUI($this->obj_id, (int) $this->sub_id, $obj_type, false, $this->news_id);
200 $note_gui->enablePrivateNotes();
201
202 $has_write = $this->access_handler->checkAccess("write", "", $this->node_id);
203 if ($has_write && $this->settings->get("comments_del_tutor", "1")) {
204 $note_gui->enablePublicNotesDeletion();
205 }
206
207 // comments cannot be turned off globally
208 if ($this->enable_comments_settings) {
209 // should only be shown if active or permission to toggle
210 if (
211 $has_write ||
212 $this->access_handler->checkAccess("edit_permissions", "", $this->node_id)
213 ) {
214 $note_gui->enableCommentsSettings();
215 }
216 }
217 /* this is different to the info screen but we need this
218 for sub-object action menus, e.g. wiki page */
219 elseif ($this->sub_id) {
220 $note_gui->enablePublicNotes();
221 }
222
223 $this->ctrl->forwardCommand($note_gui);
224 break;
225
226 case "iltagginggui":
227 $tags_gui = new ilTaggingGUI();
228 $tags_gui->setObject($this->obj_id, $this->obj_type);
229 $this->ctrl->forwardCommand($tags_gui);
230 break;
231
232 case "ilobjectactivationgui":
233 $parent_id = $this->retriever->getMaybeInt('parent_id') ?? 0;
234 $this->ctrl->setParameter($this, "parent_id", $parent_id);
235 $act_gui = new ilObjectActivationGUI($parent_id, $this->node_id);
236 $this->ctrl->forwardCommand($act_gui);
237 break;
238
239 case "ilratinggui":
240 $rating_gui = new ilRatingGUI();
241 if (
242 $this->request_wrapper->has("rnsb")
243 ) {
244 $rating_gui->setObject($this->obj_id, $this->obj_type, $this->sub_id, $this->sub_type);
245 } else {
246 // coming from headaction ignore sub-objects
247 $rating_gui->setObject($this->obj_id, $this->obj_type);
248 }
249 $this->ctrl->forwardCommand($rating_gui);
250 if ($this->rating_callback) {
251 // as rating in categories is form-based we need to redirect
252 // somewhere after saving
253 $this->ctrl->redirect($this->rating_callback[0], $this->rating_callback[1]);
254 }
255 break;
256
257 default:
258 break;
259 }
260
261 exit();
262 }
263
267 public function setSubObject(?string $sub_obj_type, ?int $sub_obj_id): void
268 {
269 $this->sub_type = $sub_obj_type;
270 $this->sub_id = $sub_obj_id;
271 }
272
276 public function enableCommentsSettings(bool $value): void
277 {
278 $this->enable_comments_settings = $value;
279 }
280
284 public function setRatingCallback(object $gui, string $cmd): void
285 {
286 $this->rating_callback = [$gui, $cmd];
287 }
288
293 {
294 // check access for object
295 if (
296 $this->node_id &&
297 !$this->access_handler->checkAccess("visible", "", $this->node_id) &&
298 !$this->access_handler->checkAccess("read", "", $this->node_id)
299 ) {
300 return null;
301 }
302
304 $this->obj_type,
305 ($this->node_type == self::TYPE_REPOSITORY) ?
307 );
308
309 // remove all currently unwanted actions
310 $header_action->enableCopy(false);
311 $header_action->enableCut(false);
312 $header_action->enableDelete(false);
313 $header_action->enableLink(false);
314 $header_action->enableInfoScreen(false);
315 $header_action->enableTimings(false);
316 $header_action->enableSubscribe($this->node_type == self::TYPE_REPOSITORY);
317
318 $header_action->initItem($this->node_id, $this->obj_id, $this->obj_type);
319 $header_action->setHeaderSubObject($this->sub_type, $this->sub_id);
320 $header_action->setAjaxHash($this->getAjaxHash());
321
322 return $header_action;
323 }
324}
Builds data types.
Definition: Factory.php:36
Class ilCommonActionDispatcherGUI.
ILIAS HTTP Wrapper RequestWrapper $request_wrapper
getAjaxHash()
Build ajax hash for current (object/node) properties.
enableCommentsSettings(bool $value)
Toggle comments settings.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
setRatingCallback(object $gui, string $cmd)
Add callback for rating gui.
static buildAjaxHash(int $node_type, ?int $node_id, string $obj_type, int $obj_id, ?string $sub_type=null, ?int $sub_id=null, int $news_id=0)
Build ajax hash.
setSubObject(?string $sub_obj_type, ?int $sub_obj_id)
Set sub object attributes.
__construct(int $node_type, $access_handler, string $obj_type, int $node_id, int $obj_id, int $news_id=0)
Class ilCtrl provides processing control methods.
@ilCtrl_Calls ilNoteGUI: ilCommentGUI
Class ilObjectActivationGUI.
static _getListGUIByType(string $type, int $context=ilObjectListGUI::CONTEXT_REPOSITORY)
Base class for all sub item list gui's.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Setting Class.
Class ilTaggingGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
exit
Interface RequestWrapper.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
global $DIC
Definition: shib_login.php:26