ILIAS  release_8 Revision v8.24
class.ilLPListOfObjectsGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
4
28{
29 protected int $details_id = 0;
30 protected int $details_obj_id = 0;
31 protected string $details_type = '';
32 protected int $details_mode = 0;
33
34 public function __construct(int $a_mode, int $a_ref_id)
35 {
36 parent::__construct($a_mode, $a_ref_id);
37 $this->__initDetails(
38 $this->initDetailsIdFromRequest($this->getRefId())
39 );
40 }
41
42 protected function initUserDetailsIdFromQuery(): int
43 {
44 if ($this->http->wrapper()->query()->has('userdetails_id')) {
45 return $this->http->wrapper()->query()->retrieve(
46 'userdetails_id',
47 $this->refinery->kindlyTo()->int()
48 );
49 }
50 return 0;
51 }
52
53 protected function initUserIdFromRequest(): int
54 {
55 if ($this->initUserIdFromQuery()) {
56 return $this->initUserIdFromQuery();
57 }
58 if ($this->http->wrapper()->post()->has('user_id')) {
59 return $this->http->wrapper()->post()->retrieve(
60 'user_id',
61 $this->refinery->kindlyTo()->int()
62 );
63 }
64 return 0;
65 }
66
67 protected function initDetailsIdFromRequest(int $default_id): int
68 {
69 if ($this->http->wrapper()->query()->has('details_id')) {
70 return $this->http->wrapper()->query()->retrieve(
71 'details_id',
72 $this->refinery->kindlyTo()->int()
73 );
74 }
75 if ($this->http->wrapper()->post()->has('details_id')) {
76 return $this->http->wrapper()->post()->retrieve(
77 'details_id',
78 $this->refinery->kindlyTo()->int()
79 );
80 }
81 return $default_id;
82 }
83
84 public function executeCommand(): void
85 {
86 $this->ctrl->setReturn($this, "");
87
88 switch ($this->ctrl->getNextClass()) {
89 case 'iltruserobjectspropstablegui':
90 $user_id = $this->initUserIdFromQuery();
91 $this->ctrl->setParameter($this, "user_id", $user_id);
92
93 $this->ctrl->setParameter(
94 $this,
95 "details_id",
96 $this->details_id
97 );
98
99 $table_gui = new ilTrUserObjectsPropsTableGUI(
100 $this,
101 "userDetails",
102 $user_id,
103 $this->details_obj_id,
104 $this->details_id
105 );
106 $this->ctrl->forwardCommand($table_gui);
107 break;
108
109 case 'iltrsummarytablegui':
110 $cmd = "showObjectSummary";
111 if (!$this->details_id) {
112 $this->details_id = ROOT_FOLDER_ID;
113 $cmd = "show";
114 }
115 $table_gui = new ilTrSummaryTableGUI(
116 $this,
117 $cmd,
118 $this->details_id
119 );
120 $this->ctrl->forwardCommand($table_gui);
121 break;
122
123 case 'iltrmatrixtablegui':
124 $table_gui = new ilTrMatrixTableGUI(
125 $this,
126 "showUserObjectMatrix",
127 $this->details_id
128 );
129 $this->ctrl->forwardCommand($table_gui);
130 break;
131
132 case 'iltrobjectuserspropstablegui':
133 $this->ctrl->setParameter(
134 $this,
135 "details_id",
136 $this->details_id
137 );
138
139 $table_gui = new ilTrObjectUsersPropsTableGUI(
140 $this,
141 "details",
142 $this->details_obj_id,
143 $this->details_id
144 );
145 $this->ctrl->forwardCommand($table_gui);
146 break;
147
148 default:
149 $cmd = $this->__getDefaultCommand();
150 $this->$cmd();
151 }
152 }
153
154 public function updateUser()
155 {
157 if ($details_id) {
158 $parent = $this->details_id;
159 $this->__initDetails($details_id);
160 }
161
163 'edit_learning_progress',
164 $this->details_id
165 )) {
166 $this->tpl->setOnScreenMessage(
167 'failure',
168 $this->lng->txt("permission_denied"),
169 true
170 );
171 $this->ctrl->returnToParent($this);
172 }
173
174 $this->__updateUser(
175 $this->initUserIdFromRequest(),
176 $this->details_obj_id
177 );
178 $this->tpl->setOnScreenMessage(
179 'success',
180 $this->lng->txt('trac_update_edit_user'),
181 true
182 );
183
184 $this->ctrl->setParameter(
185 $this,
186 "details_id",
187 $this->details_id
188 ); // #15043
189
190 // #14993
191 if (!$details_id) {
192 $this->ctrl->redirect($this, "details");
193 } else {
194 $this->ctrl->setParameter($this, "userdetails_id", $details_id);
195 $this->ctrl->redirect($this, "userdetails");
196 }
197 }
198
199 public function editUser(): void
200 {
201 $cancel = '';
202 $parent_id = $this->details_id;
204 if ($details_id) {
205 $this->__initDetails($details_id);
206 $sub_id = $this->details_id;
207 $cancel = "userdetails";
208 } else {
209 $sub_id = null;
210 $cancel = "details";
211 }
212
214 'edit_learning_progress',
215 $this->details_id
216 )) {
217 $this->tpl->setOnScreenMessage(
218 'failure',
219 $this->lng->txt("permission_denied"),
220 true
221 );
222 $this->ctrl->returnToParent($this);
223 }
224
225 $info = new ilInfoScreenGUI($this);
226 $info->setFormAction($this->ctrl->getFormAction($this));
227 $this->__showObjectDetails($info, $this->details_obj_id);
228
229 $user_id = $this->initUserIdFromQuery();
230 $this->tpl->setVariable(
231 "ADM_CONTENT",
232 $this->__showEditUser(
233 $user_id,
234 $parent_id,
235 strlen($cancel) > 0 ? $cancel : null,
236 $sub_id ?? 0
237 ) . "<br />" . $info->getHTML()
238 );
239 }
240
241 public function details(): void
242 {
243 $this->tpl->addBlockFile(
244 'ADM_CONTENT',
245 'adm_content',
246 'tpl.lp_loo.html',
247 'Services/Tracking'
248 );
249
250 // Show back button
251 if ($this->getMode() == self::LP_CONTEXT_PERSONAL_DESKTOP or
252 $this->getMode() == self::LP_CONTEXT_ADMINISTRATION) {
253 $this->toolbar->addButton(
254 $this->lng->txt('trac_view_list'),
255 $this->ctrl->getLinkTarget($this, 'show')
256 );
257 }
258
259 $info = new ilInfoScreenGUI($this);
260 $info->setFormAction($this->ctrl->getFormAction($this));
261 if ($this->__showObjectDetails($info, $this->details_obj_id)) {
262 $this->tpl->setCurrentBlock("info");
263 $this->tpl->setVariable("INFO_TABLE", $info->getHTML());
264 $this->tpl->parseCurrentBlock();
265 }
266 $this->__showUsersList();
267 }
268
269 public function __showUsersList($a_print_view = false): void
270 {
271 if ($this->isAnonymized()) {
272 $this->tpl->setOnScreenMessage(
273 'failure',
274 $this->lng->txt('permission_denied')
275 );
276 return;
277 }
278 $this->ctrl->setParameter($this, "details_id", $this->details_id);
280 $this,
281 "details",
282 $this->details_obj_id,
283 $this->details_id,
284 $a_print_view
285 );
286
287 $this->tpl->setVariable("LP_OBJECTS", $gui->getHTML());
288 $this->tpl->setVariable("LEGEND", $this->__getLegendHTML());
289 }
290
291 public function userDetails(): void
292 {
293 if ($this->isAnonymized()) {
294 $this->tpl->setOnScreenMessage(
295 'failure',
296 $this->lng->txt('permission_denied')
297 );
298 return;
299 }
300
301 $this->ctrl->setParameter($this, "details_id", $this->details_id);
302
303 $print_view = false;
304 if ($this->http->wrapper()->query()->has('prt')) {
305 $print_view = $this->http->wrapper()->query()->retrieve(
306 'prt',
307 $this->refinery->kindlyTo()->bool()
308 );
309 }
310 if (!$print_view) {
311 // Show back button
312 $this->toolbar->addButton(
313 $this->lng->txt('trac_view_list'),
314 $this->ctrl->getLinkTarget(
315 $this,
316 'details'
317 )
318 );
319 }
320
321 $user_id = $this->initUserIdFromQuery();
322 $this->ctrl->setParameter($this, "user_id", $user_id);
323 $this->tpl->addBlockFile(
324 'ADM_CONTENT',
325 'adm_content',
326 'tpl.lp_loo.html',
327 'Services/Tracking'
328 );
329
330 $info = new ilInfoScreenGUI($this);
331 $info->setFormAction($this->ctrl->getFormAction($this));
332 $this->__showObjectDetails($info, $this->details_obj_id);
333 // $this->__appendLPDetails($info,$this->details_obj_id,$user_id);
334 $this->tpl->setVariable("INFO_TABLE", $info->getHTML());
335
336 $table = new ilTrUserObjectsPropsTableGUI(
337 $this,
338 "userDetails",
339 $user_id,
340 $this->details_obj_id,
341 $this->details_id,
342 $print_view
343 );
344 $this->tpl->setVariable('LP_OBJECTS', $table->getHTML());
345 $this->tpl->setVariable('LEGEND', $this->__getLegendHTML());
346 }
347
348 public function show(): void
349 {
350 $this->ctrl->setParameter($this, 'offset', 0);
351
352 // Show only detail of current repository item if called from repository
353 switch ($this->getMode()) {
355 $this->__initDetails($this->getRefId());
356 $this->details();
357 return;
358 }
359 $this->__listObjects();
360 }
361
362 public function __listObjects(): void
363 {
364 $this->tpl->addBlockFile(
365 'ADM_CONTENT',
366 'adm_content',
367 'tpl.lp_list_objects.html',
368 'Services/Tracking'
369 );
370
371 $lp_table = new ilTrSummaryTableGUI($this, "", ROOT_FOLDER_ID);
372
373 $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
374 if ($lp_table->isStatusShown()) {
375 $this->tpl->setVariable('LEGEND', $this->__getLegendHTML(ilLPStatusIcons::ICON_VARIANT_SHORT));
376 }
377 }
378
379 public function __initDetails(int $a_details_id): void
380 {
381 if (!$a_details_id) {
382 $a_details_id = $this->getRefId();
383 }
384 if ($a_details_id) {
385 $this->details_id = $a_details_id;
386 $this->details_obj_id = $this->ilObjectDataCache->lookupObjId(
387 $this->details_id
388 );
389 $this->details_type = $this->ilObjectDataCache->lookupType(
390 $this->details_obj_id
391 );
392
393 $olp = ilObjectLP::getInstance($this->details_obj_id);
394 $this->details_mode = $olp->getCurrentMode();
395 }
396 }
397
401 public function showObjectSummary(): void
402 {
403 $table = new ilTrSummaryTableGUI(
404 $this,
405 "showObjectSummary",
406 $this->getRefId(),
407 false
408 );
409 $content = $table->getHTML();
410 if ($table->isStatusShown()) {
412 }
413 $this->tpl->setContent($content);
414 }
415
419 public function showUserObjectMatrix(): void
420 {
421 if ($this->isAnonymized()) {
422 $this->tpl->setOnScreenMessage(
423 'failure',
424 $this->lng->txt('permission_denied')
425 );
426 return;
427 }
428 $this->tpl->addBlockFile(
429 'ADM_CONTENT',
430 'adm_content',
431 'tpl.lp_loo.html',
432 'Services/Tracking'
433 );
434 $info = new ilInfoScreenGUI($this);
435 $info->setFormAction($this->ctrl->getFormAction($this));
436 if ($this->__showObjectDetails($info, $this->details_obj_id)) {
437 $this->tpl->setCurrentBlock("info");
438 $this->tpl->setVariable("INFO_TABLE", $info->getHTML());
439 $this->tpl->parseCurrentBlock();
440 }
441
442 $table = new ilTrMatrixTableGUI(
443 $this,
444 "showUserObjectMatrix",
445 $this->getRefId()
446 );
447 $this->tpl->setVariable('LP_OBJECTS', $table->getHTML());
448 $this->tpl->setVariable('LEGEND', $this->__getLegendHTML());
449 }
450}
Class ilInfoScreenGUI.
showObjectSummary()
Show object-based summarized tracking data.
__showUsersList($a_print_view=false)
initDetailsIdFromRequest(int $default_id)
showUserObjectMatrix()
Show object user matrix.
__construct(int $a_mode, int $a_ref_id)
static checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
__getLegendHTML(int $variant=ilLPStatusIcons::ICON_VARIANT_LONG)
__showObjectDetails(ilInfoScreenGUI $info, int $item_id=0, bool $add_section=true)
show details about current object.
__showEditUser(int $a_user_id, int $a_ref_id, ?string $a_cancel=null, int $a_sub_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $obj_id)
Learning progress table: One object, rows: users, columns: properties Example: A course,...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ROOT_FOLDER_ID
Definition: constants.php:32
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc