ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPListOfObjectsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
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':
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, $this->details_type);
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 'components/ILIAS/Tracking'
248 );
249
250 $info = new ilInfoScreenGUI($this);
251 $info->setFormAction($this->ctrl->getFormAction($this));
252 if ($this->__showObjectDetails($info, $this->details_obj_id, $this->details_type)) {
253 $this->tpl->setCurrentBlock("info");
254 $this->tpl->setVariable("INFO_TABLE", $info->getHTML());
255 $this->tpl->parseCurrentBlock();
256 }
257 $this->__showUsersList();
258 }
259
260 public function __showUsersList($a_print_view = false): void
261 {
262 if ($this->isAnonymized()) {
263 $this->tpl->setOnScreenMessage(
264 'failure',
265 $this->lng->txt('permission_denied')
266 );
267 return;
268 }
269 $this->ctrl->setParameter($this, "details_id", $this->details_id);
271 $this,
272 "details",
273 $this->details_obj_id,
274 $this->details_id,
275 $a_print_view
276 );
277
278 $this->tpl->setVariable("LP_OBJECTS", $gui->getHTML());
279 $this->tpl->setVariable("LEGEND", $this->__getLegendHTML());
280 }
281
282 public function userDetails(): void
283 {
284 if ($this->isAnonymized()) {
285 $this->tpl->setOnScreenMessage(
286 'failure',
287 $this->lng->txt('permission_denied')
288 );
289 return;
290 }
291
292 $this->ctrl->setParameter($this, "details_id", $this->details_id);
293
294 $print_view = false;
295 if ($this->http->wrapper()->query()->has('prt')) {
296 $print_view = $this->http->wrapper()->query()->retrieve(
297 'prt',
298 $this->refinery->kindlyTo()->bool()
299 );
300 }
301 if (!$print_view) {
302 // Show back button
303 $this->toolbar->addButton(
304 $this->lng->txt('trac_view_list'),
305 $this->ctrl->getLinkTarget(
306 $this,
307 'details'
308 )
309 );
310 }
311
312 $user_id = $this->initUserIdFromQuery();
313 $this->ctrl->setParameter($this, "user_id", $user_id);
314 $this->tpl->addBlockFile(
315 'ADM_CONTENT',
316 'adm_content',
317 'tpl.lp_loo.html',
318 'components/ILIAS/Tracking'
319 );
320
321 $info = new ilInfoScreenGUI($this);
322 $info->setFormAction($this->ctrl->getFormAction($this));
323 $this->__showObjectDetails($info, $this->details_obj_id, $this->details_type);
324 // $this->__appendLPDetails($info,$this->details_obj_id,$user_id);
325 $this->tpl->setVariable("INFO_TABLE", $info->getHTML());
326
327 $table = new ilTrUserObjectsPropsTableGUI(
328 $this,
329 "userDetails",
330 $user_id,
331 $this->details_obj_id,
332 $this->details_id,
333 $print_view
334 );
335 $this->tpl->setVariable('LP_OBJECTS', $table->getHTML());
336 $this->tpl->setVariable('LEGEND', $this->__getLegendHTML());
337 }
338
339 public function show(): void
340 {
341 $this->ctrl->setParameter($this, 'offset', 0);
342
343 // Show only detail of current repository item if called from repository
344 switch ($this->getMode()) {
346 $this->__initDetails($this->getRefId());
347 $this->details();
348 return;
349 }
350 $this->__listObjects();
351 }
352
353 public function __listObjects(): void
354 {
355 $this->tpl->addBlockFile(
356 'ADM_CONTENT',
357 'adm_content',
358 'tpl.lp_list_objects.html',
359 'components/ILIAS/Tracking'
360 );
361
362 $lp_table = new ilTrSummaryTableGUI($this, "", ROOT_FOLDER_ID);
363
364 $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
365 if ($lp_table->isStatusShown()) {
366 $this->tpl->setVariable('LEGEND', $this->__getLegendHTML(ilLPStatusIcons::ICON_VARIANT_SHORT));
367 }
368 }
369
370 public function __initDetails(int $a_details_id): void
371 {
372 if (!$a_details_id) {
373 $a_details_id = $this->getRefId();
374 }
375 if ($a_details_id) {
376 $this->details_id = $a_details_id;
377 $this->details_obj_id = $this->ilObjectDataCache->lookupObjId(
378 $this->details_id
379 );
380 $this->details_type = $this->ilObjectDataCache->lookupType(
381 $this->details_obj_id
382 );
383
384 $olp = ilObjectLP::getInstance($this->details_obj_id);
385 $this->details_mode = $olp->getCurrentMode();
386 }
387 }
388
392 public function showObjectSummary(): void
393 {
394 $table = new ilTrSummaryTableGUI(
395 $this,
396 "showObjectSummary",
397 $this->getRefId(),
398 false
399 );
400 $content = $table->getHTML();
401 if ($table->isStatusShown()) {
403 }
404 $this->tpl->setContent($content);
405 }
406
410 public function showUserObjectMatrix(): void
411 {
412 if ($this->isAnonymized()) {
413 $this->tpl->setOnScreenMessage(
414 'failure',
415 $this->lng->txt('permission_denied')
416 );
417 return;
418 }
419 $this->tpl->addBlockFile(
420 'ADM_CONTENT',
421 'adm_content',
422 'tpl.lp_loo.html',
423 'components/ILIAS/Tracking'
424 );
425 $info = new ilInfoScreenGUI($this);
426 $info->setFormAction($this->ctrl->getFormAction($this));
427 if ($this->__showObjectDetails($info, $this->details_obj_id, $this->details_type)) {
428 $this->tpl->setCurrentBlock("info");
429 $this->tpl->setVariable("INFO_TABLE", $info->getHTML());
430 $this->tpl->parseCurrentBlock();
431 }
432
433 $table = new ilTrMatrixTableGUI(
434 $this,
435 "showUserObjectMatrix",
436 $this->getRefId()
437 );
438 $this->tpl->setVariable('LP_OBJECTS', $table->getHTML());
439 $this->tpl->setVariable('LEGEND', $this->__getLegendHTML());
440 }
441}
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
__showObjectDetails(ilInfoScreenGUI $info, int $item_id=0, string $item_type='', bool $add_section=true)
show details about current object.
__getLegendHTML(int $variant=ilLPStatusIcons::ICON_VARIANT_LONG)
__showEditUser(int $a_user_id, int $a_ref_id, ?string $a_cancel=null, int $a_sub_id=0)
class ilObjectDataCache
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
$info
Definition: entry_point.php:21
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc