ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTrUserObjectsPropsTableGUI.php
Go to the documentation of this file.
1<?php
26{
27 protected string $type;
28 protected int $ref_id;
29 protected int $obj_id;
30 protected int $user_id;
31
34
38 public function __construct(
39 ?object $a_parent_obj,
40 string $a_parent_cmd,
41 int $a_user_id,
42 int $a_obj_id,
43 int $a_ref_id,
44 bool $a_print_view = false
45 ) {
46 global $DIC;
47
48 $this->setId("truop");
49 $this->user_id = $a_user_id;
50 $this->obj_id = $a_obj_id;
51 $this->type = ilObject::_lookupType($this->obj_id);
52 $this->ref_id = $a_ref_id;
53
54 parent::__construct($a_parent_obj, $a_parent_cmd);
55 $this->setLimit(9999);
56
57 $this->parseTitle($this->obj_id, "details", $this->user_id);
58
59 if ($a_print_view) {
60 $this->setPrintMode(true);
61 }
62
63 $this->addColumn($this->lng->txt("title"), "title");
64
65 foreach ($this->getSelectedColumns() as $c) {
66 $l = $c;
67 if (in_array(
68 $l,
69 array("last_access",
70 "first_access",
71 "read_count",
72 "spent_seconds",
73 "mark",
74 "status",
75 "percentage"
76 )
77 )) {
78 $l = "trac_" . $l;
79 }
80 if ($l == "u_comment") {
81 $l = "trac_comment";
82 }
83 $this->addColumn($this->lng->txt($l), $c);
84 }
85
86 if (!$this->getPrintMode()) {
87 $this->addColumn($this->lng->txt("actions"), "");
88 }
89
90 $this->setExternalSorting(true);
91 $this->setExternalSegmentation(true);
92 $this->setEnableHeader(true);
93 $this->setFormAction(
94 $this->ctrl->getFormActionByClass(get_class($this))
95 );
96 $this->setRowTemplate(
97 "tpl.user_objects_props_row.html",
98 "components/ILIAS/Tracking"
99 );
100 $this->setEnableTitle(true);
101 $this->setDefaultOrderField("title");
102 $this->setDefaultOrderDirection("asc");
103 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
104 $this->initFilter();
105 $this->getItems();
106 }
107
108 public function getSelectableColumns(): array
109 {
110 // default fields
111 $cols = array();
112
113 $tracking = new ilObjUserTracking();
114 if ($tracking->hasExtendedData(
116 )) {
117 $cols["first_access"] = array(
118 "txt" => $this->lng->txt("trac_first_access"),
119 "default" => true
120 );
121 $cols["last_access"] = array(
122 "txt" => $this->lng->txt("trac_last_access"),
123 "default" => true
124 );
125 }
126 if ($tracking->hasExtendedData(
128 )) {
129 $cols["read_count"] = array(
130 "txt" => $this->lng->txt("trac_read_count"),
131 "default" => true
132 );
133 }
134 if ($tracking->hasExtendedData(
136 )) {
137 $cols["spent_seconds"] = array(
138 "txt" => $this->lng->txt("trac_spent_seconds"),
139 "default" => true
140 );
141 }
142
143 // #15334 - parent object does not matter, sub-objects may have percentage
144 $cols["percentage"] = array(
145 "txt" => $this->lng->txt("trac_percentage"),
146 "default" => true
147 );
148
149 $cols["status"] = array(
150 "txt" => $this->lng->txt("trac_status"),
151 "default" => true
152 );
153 $cols["mark"] = array(
154 "txt" => $this->lng->txt("trac_mark"),
155 "default" => true
156 );
157 $cols["u_comment"] = array(
158 "txt" => $this->lng->txt("trac_comment"),
159 "default" => false
160 );
161
162 return $cols;
163 }
164
165 public function getItems()
166 {
168 $additional_fields = $this->getSelectedColumns();
169
171 $this->user_id,
172 $this->obj_id,
173 $this->ref_id,
178 $this->filter,
179 $additional_fields,
180 $this->filter["view_mode"] ?? false
181 );
182
183 if (count($tr_data["set"]) == 0 && $this->getOffset() > 0) {
184 $this->resetOffset();
186 $this->user_id,
187 $this->obj_id,
188 $this->ref_id,
193 $this->filter,
194 $additional_fields,
195 $this->filter["view_mode"] ?? false
196 );
197 }
198
199 // #13807
200 foreach ($tr_data["set"] as $idx => $row) {
201 if (($row["ref_id"] ?? 0) &&
203 'read_learning_progress',
204 $row['ref_id']
205 )) {
206 foreach (array_keys($row) as $col_id) {
207 if (!in_array(
208 $col_id,
209 array("type",
210 "obj_id",
211 "ref_id",
212 "title",
213 "sort_title"
214 )
215 )) {
216 $tr_data["set"][$idx][$col_id] = null;
217 }
218 }
219 $tr_data["set"][$idx]["privacy_conflict"] = true;
220 }
221 }
222
223 $this->setMaxCount($tr_data["cnt"]);
224
225 if ($this->getOrderField() == "title") {
226 // sort alphabetically, move parent object to 1st position
227 $set = array();
228 $parent = false;
229 foreach ($tr_data["set"] as $idx => $row) {
230 if ($row['obj_id'] == $this->obj_id) {
231 $parent = $row;
232 } elseif (isset($row["sort_title"])) {
233 $set[strtolower($row["sort_title"]) . "__" . $idx] = $row;
234 } else {
235 $set[strtolower($row["title"]) . "__" . $idx] = $row;
236 }
237 }
238 unset($tr_data["set"]);
239 if ($this->getOrderDirection() == "asc") {
240 ksort($set);
241 } else {
242 krsort($set);
243 }
244 $set = array_values($set);
245 if ($parent) {
246 array_unshift($set, $parent);
247 }
248
249 $this->setData($set);
250 } else {
251 $this->setData($tr_data["set"]);
252 }
253 }
254
255 public function initFilter(): void
256 {
257 // for scorm and objectives this filter does not make sense / is not implemented
258 $olp = ilObjectLP::getInstance($this->obj_id);
259 $collection = $olp->getCollectionInstance();
260 if ($collection instanceof ilLPCollectionOfRepositoryObjects) {
261 // show collection only/all
262 $ti = new ilRadioGroupInputGUI(
263 $this->lng->txt("trac_view_mode"),
264 "view_mode"
265 );
266 $ti->addOption(
267 new ilRadioOption($this->lng->txt("trac_view_mode_all"), "")
268 );
269 $ti->addOption(
270 new ilRadioOption(
271 $this->lng->txt("trac_view_mode_collection"),
272 "coll"
273 )
274 );
275 $this->addFilterItem($ti);
276 $ti->readFromSession();
277 $this->filter["view_mode"] = $ti->getValue();
278 }
279 }
280
281 protected function fillRow(array $a_set): void
282 {
283 global $DIC;
285
286 if (!$this->isPercentageAvailable($a_set["obj_id"])) {
287 $a_set["percentage"] = null;
288 }
289
290 foreach ($this->getSelectedColumns() as $c) {
291 if (!(bool) ($a_set["privacy_conflict"] ?? null)) {
292 $val = (trim(($a_set[$c] ?? '')) == "")
293 ? " "
294 : $a_set[$c];
295
296 if (($a_set[$c] ?? '') != "" || $c == "status") {
297 switch ($c) {
298 case "first_access":
300 new ilDateTime(
301 $a_set[$c],
303 )
304 );
305 break;
306
307 case "last_access":
309 new ilDateTime($a_set[$c], IL_CAL_UNIX)
310 );
311 break;
312
313 case "status":
314 $val = $icons->renderIconForStatus($a_set[$c] ?? ilLPStatusIcons::ICON_VARIANT_LONG);
315
316 if (($a_set["ref_id"] ?? 0) &&
317 $a_set["type"] != "lobj" &&
318 $a_set["type"] != "sco" &&
319 $a_set["type"] != "st" &&
320 $a_set["type"] != "mob") {
321 $timing = $this->showTimingsWarning(
322 $a_set["ref_id"],
323 $this->user_id
324 );
325 if ($timing) {
326 if ($timing !== true) {
327 $timing = ": " . ilDatePresentation::formatDate(
328 new ilDate(
329 $timing,
331 )
332 );
333 } else {
334 $timing = "";
335 }
336 $this->tpl->setCurrentBlock('warning_img');
337 $this->tpl->setVariable(
338 'WARNING_IMG',
340 'media/time_warn.svg'
341 )
342 );
343 $this->tpl->setVariable(
344 'WARNING_ALT',
345 $this->lng->txt(
346 'trac_time_passed'
347 ) . $timing
348 );
349 $this->tpl->parseCurrentBlock();
350 }
351 }
352 break;
353
354 case "spent_seconds":
356 $a_set["type"]
357 )) {
358 $val = "-";
359 } else {
361 $a_set[$c],
362 ($a_set[$c] < 3600 ? true : false)
363 ); // #14858
364 }
365 break;
366
367 case "percentage":
368 $val = $a_set[$c] . "%";
369 break;
370 }
371 }
372 if ($c == "mark" &&
373 !ilObjectLP::supportsMark($this->type)) {
374 $val = "-";
375 }
376 if ($c == "spent_seconds" &&
377 !ilObjectLP::supportsSpentSeconds($this->type)) {
378 $val = "-";
379 }
380 if ($c == "percentage" &&
381 !$this->isPercentageAvailable($a_set["obj_id"])) {
382 $val = "-";
383 }
384 } else {
385 $val = "&nbsp;";
386 }
387
388 $this->tpl->setCurrentBlock("user_field");
389 $this->tpl->setVariable("VAL_UF", $val);
390 $this->tpl->parseCurrentBlock();
391 }
392
393 if ($a_set["privacy_conflict"] ?? null) {
394 $this->tpl->setCurrentBlock("permission_bl");
395 $this->tpl->setVariable(
396 "TXT_NO_PERMISSION",
397 $this->lng->txt("status_no_permission")
398 );
399 $this->tpl->parseCurrentBlock();
400 }
401
402 if ($a_set["title"] == "") {
403 $a_set["title"] = "--" . $this->lng->txt("none") . "--";
404 }
405
406 $this->tpl->setVariable(
407 "ICON",
408 ilObject::_getIcon(0, "tiny", $a_set["type"])
409 );
410 $this->tpl->setVariable("ICON_ALT", $this->lng->txt($a_set["type"]));
411
412 if (in_array(
413 $a_set['type'],
414 array('fold', 'grp')
415 ) && $a_set['obj_id'] != $this->obj_id) {
416 if ($a_set['type'] == 'fold') {
417 $object_gui = 'ilobjfoldergui';
418 } else {
419 $object_gui = 'ilobjgroupgui';
420 }
421 $this->tpl->setCurrentBlock('title_linked');
422
423 $base_class = '';
424 if ($this->http->wrapper()->query()->has('baseClass')) {
425 $base_class = $this->http->wrapper()->query()->retrieve(
426 'baseClass',
427 $this->refinery->kindlyTo()->string()
428 );
429 }
430 // link structure gets too complicated
431 if ($base_class != "ilDashboardGUI" && $base_class != "ilAdministrationGUI") {
432 $old = $this->ctrl->getParameterArrayByClass(
433 'illplistofobjectsgui'
434 );
435 $this->ctrl->setParameterByClass(
436 'illplistofobjectsgui',
437 'ref_id',
438 $a_set["ref_id"]
439 );
440 $this->ctrl->setParameterByClass(
441 'illplistofobjectsgui',
442 'details_id',
443 $a_set["ref_id"]
444 );
445 $this->ctrl->setParameterByClass(
446 'illplistofobjectsgui',
447 'user_id',
448 $this->user_id
449 );
450 $url = $this->ctrl->getLinkTargetByClass(
451 array('ilrepositorygui',
452 $object_gui,
453 'illearningprogressgui',
454 'illplistofobjectsgui'
455 ),
456 'userdetails'
457 );
458 $this->ctrl->setParameterByClass(
459 'illplistofobjectsgui',
460 'ref_id',
461 $old["ref_id"] ?? null
462 );
463 $this->ctrl->setParameterByClass(
464 'illplistofobjectsgui',
465 'details_id',
466 $old["details_id"]
467 );
468 $this->ctrl->setParameterByClass(
469 'illplistofobjectsgui',
470 'user_id',
471 $old["user_id"]
472 );
473 } else {
474 $url = "#";
475 }
476
477 $this->tpl->setVariable("URL_TITLE", $url);
478 $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
479 $this->tpl->parseCurrentBlock();
480 } else {
481 $this->tpl->setCurrentBlock('title_plain');
482 $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
483 $this->tpl->parseCurrentBlock();
484 }
485
486 // #16453 / #17163
487 if (($a_set['ref_id'] ?? 0)) {
488 $path = new ilPathGUI();
489 $path = $path->getPath($this->ref_id, $a_set['ref_id']);
490 if ($path) {
491 $this->tpl->setVariable(
492 'COLL_PATH',
493 $this->lng->txt('path') . ': ' . $path
494 );
495 }
496 }
497
498 // #13807 / #17069
499 if (($a_set["ref_id"] ?? 0) &&
501 'edit_learning_progress',
502 $a_set['ref_id']
503 )) {
504 if (!in_array(
505 $a_set["type"],
506 array("sco", "lobj")
507 ) && !$this->getPrintMode()) {
508 $this->tpl->setCurrentBlock("item_command");
509 $this->ctrl->setParameterByClass(
510 "illplistofobjectsgui",
511 "userdetails_id",
512 $a_set["ref_id"]
513 );
514 $this->tpl->setVariable(
515 "HREF_COMMAND",
516 $this->ctrl->getLinkTargetByClass(
517 "illplistofobjectsgui",
518 'edituser'
519 )
520 );
521 $this->tpl->setVariable("TXT_COMMAND", $this->lng->txt('edit'));
522 $this->ctrl->setParameterByClass(
523 "illplistofobjectsgui",
524 "userdetails_id",
525 ""
526 );
527 $this->tpl->parseCurrentBlock();
528 }
529 }
530 }
531
532 protected function fillHeaderExcel(ilExcel $a_excel, int &$a_row): void
533 {
534 $a_excel->setCell($a_row, 0, $this->lng->txt("type"));
535 $a_excel->setCell($a_row, 1, $this->lng->txt("title"));
536
537 $labels = $this->getSelectableColumns();
538 $cnt = 2;
539 foreach ($this->getSelectedColumns() as $c) {
540 $a_excel->setCell($a_row, $cnt++, $labels[$c]["txt"]);
541 }
542
543 $a_excel->setBold(
544 "A" . $a_row . ":" . $a_excel->getColumnCoord($cnt - 1) . $a_row
545 );
546 }
547
548 protected function fillRowExcel(
549 ilExcel $a_excel,
550 int &$a_row,
551 array $a_set
552 ): void {
553 $a_excel->setCell($a_row, 0, $this->lng->txt($a_set["type"]));
554 $a_excel->setCell($a_row, 1, $a_set["title"]);
555
556 $cnt = 2;
557 foreach ($this->getSelectedColumns() as $c) {
558 if ($c != 'status') {
559 $val = $this->parseValue($c, $a_set[$c], $this->type);
560 } else {
562 (int) $a_set[$c]
563 );
564 }
565 $a_excel->setCell($a_row, $cnt++, $val);
566 }
567 }
568
569 protected function fillHeaderCSV(ilCSVWriter $a_csv): void
570 {
571 $a_csv->addColumn($this->lng->txt("type"));
572 $a_csv->addColumn($this->lng->txt("title"));
573
574 $labels = $this->getSelectableColumns();
575 foreach ($this->getSelectedColumns() as $c) {
576 $a_csv->addColumn($labels[$c]["txt"]);
577 }
578
579 $a_csv->addRow();
580 }
581
582 protected function fillRowCSV(ilCSVWriter $a_csv, array $a_set): void
583 {
584 $a_csv->addColumn($this->lng->txt($a_set["type"]));
585 $a_csv->addColumn($a_set["title"]);
586
587 foreach ($this->getSelectedColumns() as $c) {
588 if ($c != 'status') {
589 $val = $this->parseValue($c, $a_set[$c], $this->type);
590 } else {
592 (int) $a_set[$c]
593 );
594 }
595 $a_csv->addColumn($val);
596 }
597
598 $a_csv->addRow();
599 }
600}
const IL_CAL_UNIX
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addColumn(string $a_col)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
@classDescription Date and time handling
Class for single dates.
setBold(string $a_coords)
Set cell(s) to bold.
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
getColumnCoord(int $a_col)
Get column "name" from number.
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
TableGUI class for learning progress.
showTimingsWarning(int $a_ref_id, int $a_user_id)
parseValue(string $id, ?string $value, string $type)
isPercentageAvailable(int $a_obj_id)
parseTitle(int $a_obj_id, string $action, int $a_user_id=0)
static checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
static _getStatusText(int $a_status, ?ilLanguage $a_lng=null)
Get status alt text.
static supportsSpentSeconds(string $obj_type)
static supportsMark(string $obj_type)
static getInstance(int $obj_id)
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
This class represents a property in a property form.
This class represents an option in a radio group.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
determineOffsetAndOrder(bool $a_omit_offset=false)
setExportFormats(array $formats)
Set available export formats.
setExternalSegmentation(bool $a_val)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setEnableTitle(bool $a_enabletitle)
setFormAction(string $a_form_action, bool $a_multipart=false)
resetOffset(bool $a_in_determination=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setPrintMode(bool $a_value=false)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
setMaxCount(int $a_max_count)
set max.
static getObjectsDataForUser(int $a_user_id, int $a_parent_obj_id, int $a_parent_ref_id, string $a_order_field="", string $a_order_dir="", int $a_offset=0, int $a_limit=9999, ?array $a_filters=null, ?array $a_additional_fields=null, bool $use_collection=true)
Get all object-based tracking data for user and parent object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillHeaderCSV(ilCSVWriter $a_csv)
CSV Version of Fill Header.
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
CSV Version of Fill Row.
__construct(?object $a_parent_obj, string $a_parent_cmd, int $a_user_id, int $a_obj_id, int $a_ref_id, bool $a_print_view=false)
Constructor.
fillRow(array $a_set)
Standard Version of Fill Row.
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
Excel Version of Fill Row.
fillHeaderExcel(ilExcel $a_excel, int &$a_row)
Excel Version of Fill Header.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
$c
Definition: deliver.php:25
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$path
Definition: ltiservices.php:30
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68