ILIAS  release_8 Revision v8.24
class.ilCommonActionDispatcherGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
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 $arr = explode(";", $hash);
114 if (isset($arr[4]) && isset($arr[5])) {
115 $arr[4] = "";
116 $arr[5] = "";
117 }
118 return implode(";", $arr);
119 }
120
125 {
126 global $DIC;
127
128 $ilAccess = $DIC->access();
129 $ilUser = $DIC->user();
130 $request_wrapper = $DIC->http()->wrapper()->query();
131 $refinery = $DIC->refinery();
132
133 if ($request_wrapper->has("cadh")) {
134 $parts = explode(";", $request_wrapper->retrieve("cadh", $refinery->kindlyTo()->string()));
135
136 $node_type = (int) $parts[0];
137 $node_id = (int) $parts[1];
138 $obj_type = (string) $parts[2];
139 $obj_id = (int) $parts[3];
140 $sub_type = (string) $parts[4];
141 $sub_id = (int) $parts[5];
142 $news_id = (int) $parts[6];
143
144 switch ($node_type) {
145 case self::TYPE_REPOSITORY:
146 $access_handler = $ilAccess;
147 break;
148
149 case self::TYPE_WORKSPACE:
150 $tree = new ilWorkspaceTree($ilUser->getId());
151 $access_handler = new ilWorkspaceAccessHandler($tree);
152 break;
153
154 default:
155 return null;
156 }
157
158 $dispatcher = new self($node_type, $access_handler, $obj_type, $node_id, $obj_id, $news_id);
159
160 if ($sub_type && $sub_id) {
161 $dispatcher->setSubObject($sub_type, $sub_id);
162 }
163
164 // poll comments have specific settings
165
166 if ($node_type == self::TYPE_REPOSITORY && $obj_type != "poll") {
167 $dispatcher->enableCommentsSettings(true);
168 }
169
170 return $dispatcher;
171 }
172 return null;
173 }
174
175 public function executeCommand(): void
176 {
177 // check access for object
178 if (
179 $this->node_id &&
180 !$this->access_handler->checkAccess("visible", "", $this->node_id) &&
181 !$this->access_handler->checkAccess("read", "", $this->node_id)
182 ) {
183 exit();
184 }
185
186 $next_class = $this->ctrl->getNextClass($this);
187
188 $this->ctrl->saveParameter($this, "cadh");
189
190 switch ($next_class) {
191 case "ilnotegui":
192
193 $obj_type = $this->obj_type;
194 if ($this->sub_type) {
195 $obj_type = $this->sub_type;
196 }
197
198 $note_gui = new ilNoteGUI($this->obj_id, (int) $this->sub_id, $obj_type, false, $this->news_id);
199 $note_gui->enablePrivateNotes();
200
201 $has_write = $this->access_handler->checkAccess("write", "", $this->node_id);
202 if ($has_write && $this->settings->get("comments_del_tutor", "1")) {
203 $note_gui->enablePublicNotesDeletion();
204 }
205
206 // comments cannot be turned off globally
207 if ($this->enable_comments_settings) {
208 // should only be shown if active or permission to toggle
209 if (
210 $has_write ||
211 $this->access_handler->checkAccess("edit_permissions", "", $this->node_id)
212 ) {
213 $note_gui->enableCommentsSettings();
214 }
215 }
216 /* this is different to the info screen but we need this
217 for sub-object action menus, e.g. wiki page */
218 elseif ($this->sub_id) {
219 $note_gui->enablePublicNotes();
220 }
221
222 $this->ctrl->forwardCommand($note_gui);
223 break;
224
225 case "iltagginggui":
226 $tags_gui = new ilTaggingGUI();
227 $tags_gui->setObject($this->obj_id, $this->obj_type);
228 $this->ctrl->forwardCommand($tags_gui);
229 break;
230
231 case "ilobjectactivationgui":
232 $parent_id = $this->retriever->getMaybeInt('parent_id') ?? 0;
233 $this->ctrl->setParameter($this, "parent_id", $parent_id);
234 $act_gui = new ilObjectActivationGUI($parent_id, $this->node_id);
235 $this->ctrl->forwardCommand($act_gui);
236 break;
237
238 case "ilratinggui":
239 $rating_gui = new ilRatingGUI();
240 if (
241 $this->request_wrapper->has("rnsb")
242 ) {
243 $rating_gui->setObject($this->obj_id, $this->obj_type, $this->sub_id, $this->sub_type);
244 } else {
245 // coming from headaction ignore sub-objects
246 $rating_gui->setObject($this->obj_id, $this->obj_type);
247 }
248 $this->ctrl->forwardCommand($rating_gui);
249 if ($this->rating_callback) {
250 // as rating in categories is form-based we need to redirect
251 // somewhere after saving
252 $this->ctrl->redirect($this->rating_callback[0], $this->rating_callback[1]);
253 }
254 break;
255
256 default:
257 break;
258 }
259
260 exit();
261 }
262
266 public function setSubObject(?string $sub_obj_type, ?int $sub_obj_id): void
267 {
268 $this->sub_type = $sub_obj_type;
269 $this->sub_id = $sub_obj_id;
270 }
271
275 public function enableCommentsSettings(bool $value): void
276 {
277 $this->enable_comments_settings = $value;
278 }
279
283 public function setRatingCallback(object $gui, string $cmd): void
284 {
285 $this->rating_callback = array($gui, $cmd);
286 }
287
292 {
293 // check access for object
294 if (
295 $this->node_id &&
296 !$this->access_handler->checkAccess("visible", "", $this->node_id) &&
297 !$this->access_handler->checkAccess("read", "", $this->node_id)
298 ) {
299 return null;
300 }
301
303 $this->obj_type,
304 ($this->node_type == self::TYPE_REPOSITORY) ?
306 );
307
308 // remove all currently unwanted actions
309 $header_action->enableCopy(false);
310 $header_action->enableCut(false);
311 $header_action->enableDelete(false);
312 $header_action->enableLink(false);
313 $header_action->enableInfoScreen(false);
314 $header_action->enableTimings(false);
315 $header_action->enableSubscribe($this->node_type == self::TYPE_REPOSITORY);
316
317 $header_action->initItem($this->node_id, $this->obj_id, $this->obj_type);
318 $header_action->setHeaderSubObject($this->sub_type, $this->sub_id);
319 $header_action->setAjaxHash($this->getAjaxHash());
320
321 return $header_action;
322 }
323}
Builds data types.
Definition: Factory.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS HTTP Wrapper RequestWrapper $request_wrapper
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.
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.
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.
Notes GUI class.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
Interface RequestWrapper.
exit
Definition: login.php:28
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
Refinery Factory $refinery