ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilLPTableBaseGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
24use ILIAS\Refinery\Factory as RefineryFactory;
25use ILIAS\HTTP\Services as HttpService;
26
34{
35 public const int HIT_LIMIT = 5000;
36 protected RefineryFactory $refinery;
37 protected HttpService $http;
38
39 protected array $filter = [];
40 protected bool $anonymized = true;
46 protected ilTree $tree;
47 protected \ilGlobalTemplateInterface $main_tpl;
48 protected Profile $profile;
49
50 public function __construct(
51 ?object $a_parent_obj,
52 string $a_parent_cmd = "",
53 string $a_template_context = ""
54 ) {
55 global $DIC;
56 $this->main_tpl = $DIC->ui()->mainTemplate();
57
58 $this->objDefinition = $DIC['objDefinition'];
59 $this->ilObjDataCache = $DIC['ilObjDataCache'];
60 $this->tree = $DIC->repositoryTree();
61 $this->user = $DIC->user();
62 $this->setting = $DIC->settings();
63 $this->http = $DIC->http();
64 $this->refinery = $DIC->refinery();
65 $this->profile = $DIC['user']->getProfile();
66
67 $this->anonymized = !ilObjUserTracking::_enabledUserRelatedData();
68 if (!$this->anonymized && isset($this->obj_id) && $this->obj_id > 0) {
69 $olp = ilObjectLP::getInstance($this->obj_id);
70 $this->anonymized = $olp->isAnonymized();
71 }
72
73 /*
74 * BT 35453: parent constructor needs to be called after $this->anonymized
75 * is set, in order for getSelectableUserColumns to also properly return
76 * user defined fields (e.g. firstname, lastname, and other user data).
77 */
78 parent::__construct($a_parent_obj, $a_parent_cmd, $a_template_context);
79
80 // country names
81 $this->lng->loadLanguageModule("meta");
82 }
83
84 protected function initItemIdFromPost(): array
85 {
86 if ($this->http->wrapper()->post()->has('item_id')) {
87 return $this->http->wrapper()->post()->retrieve(
88 'item_id',
89 $this->refinery->kindlyTo()->listOf(
90 $this->refinery->kindlyTo()->int()
91 )
92 );
93 }
94 return [];
95 }
96
97 protected function initUidFromPost(): array
98 {
99 if ($this->http->wrapper()->post()->has('uid')) {
100 return $this->http->wrapper()->post()->retrieve(
101 'uid',
102 $this->refinery->kindlyTo()->listOf(
103 $this->refinery->kindlyTo()->int()
104 )
105 );
106 }
107 return [];
108 }
109
110 public function executeCommand(): bool
111 {
113 if (!$this->ctrl->getNextClass($this)) {
114 $to_hide = false;
115
116 switch ($this->ctrl->getCmd()) {
117 case "applyFilter":
118 $this->resetOffset();
119 $this->writeFilterToSession();
120 $this->storeProperty("offset", "0");
121 break;
122
123 case "resetFilter":
124 $this->resetOffset();
125 $this->resetFilter();
126 $this->storeProperty("offset", "0");
127 break;
128
129 case "hideSelected":
130 $to_hide = $this->initItemIdFromPost();
131 break;
132
133 case "hide":
134 $hide = 0;
135 if ($this->http->wrapper()->query()->has('hide')) {
136 $hide = $this->http->wrapper()->query()->retrieve(
137 'hide',
138 $this->refinery->kindlyTo()->int()
139 );
140 }
141 $to_hide = [$hide];
142 break;
143
144 case "mailselectedusers":
145 if (!$this->initUidFromPost()) {
146 $this->main_tpl->setOnScreenMessage(
147 'failure',
148 $this->lng->txt(
149 "no_checkbox"
150 ),
151 true
152 );
153 } else {
154 $this->sendMail(
155 $this->initUidFromPost(),
156 $this->parent_obj,
157 $this->parent_cmd
158 );
159 }
160 break;
161
162 case 'addToClipboard':
163 if (!$this->initUidFromPost()) {
164 $this->main_tpl->setOnScreenMessage(
165 'failure',
166 $this->lng->txt(
167 'no_checkbox'
168 ),
169 true
170 );
171 } else {
172 $this->addToClipboard();
173 }
174 break;
175
176 // page selector
177 default:
179 $this->storeNavParameter();
180 $this->storeProperty("offset", (string) $this->getOffset());
181 break;
182 }
183
184 if ($to_hide) {
185 $obj = $this->getFilterItemByPostVar("hide");
186 $value = array_unique(
187 array_merge((array) $obj->getValue(), $to_hide)
188 );
189 $obj->setValue($value);
190 $obj->writeToSession();
191 }
192
193 $this->ctrl->redirect($this->parent_obj, $this->parent_cmd);
194 } else {
195 // e.g. repository selector
196 return parent::executeCommand();
197 }
198 return true;
199 }
200
204 protected function findReferencesForObjId(int $a_obj_id): array
205 {
206 $ref_ids = array_keys(ilObject::_getAllReferences($a_obj_id));
207 sort($ref_ids, SORT_NUMERIC);
208 return $ref_ids;
209 }
210
211
212
213 protected function sendMail(
214 array $a_user_ids,
215 $a_parent_obj,
216 string $a_parent_cmd
217 ): void {
218 // see ilObjCourseGUI::sendMailToSelectedUsersObject()
219
220 $rcps = array();
221 foreach ($a_user_ids as $usr_id) {
222 $rcps[] = ilObjUser::_lookupLogin($usr_id);
223 }
224
225 $template = array();
226 $sig = null;
227
228 $ref_id = 0;
229 if ($this->http->wrapper()->query()->has('ref_id')) {
230 $ref_id = $this->http->wrapper()->query()->retrieve(
231 'ref_id',
232 $this->refinery->kindlyTo()->int()
233 );
234 }
235 // repository-object-specific
236 if ($ref_id) {
237 $obj_lp = ilObjectLP::getInstance(
239 );
240 $tmpl_id = $obj_lp->getMailTemplateId();
241
242 if ($tmpl_id) {
243 $template = array(
244 ilMailFormCall::CONTEXT_KEY => $tmpl_id,
245 'ref_id' => $ref_id,
246 'ts' => time()
247 );
248 } else {
249 $sig = ilLink::_getLink($ref_id);
250 $sig = rawurlencode(base64_encode($sig));
251 }
252 }
253
256 $a_parent_obj,
257 $a_parent_cmd,
258 array(),
259 array(
260 'type' => 'new',
261 'rcp_to' => implode(',', $rcps),
262 'sig' => $sig
263 ),
264 $template
265 )
266 );
267 }
268
272 protected function searchObjects(
273 array $filter,
274 string $permission,
275 ?array $preset_obj_ids = null,
276 bool $a_check_lp_activation = true
277 ): array {
278 $query_parser = new ilQueryParser($filter["query"] ?? '');
279 $query_parser->setMinWordLength(0);
280 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_AND);
281 $query_parser->parse();
282 if (!$query_parser->validate()) {
283 ilLoggerFactory::getLogger('trac')->notice(
284 $query_parser->getMessage()
285 );
286 // echo $query_parser->getMessage();
287 return [];
288 }
289
290 if ($filter["type"] == "lres") {
291 $filter["type"] = array('lm', 'sahs', 'htlm');
292 } else {
293 $filter["type"] = array($filter["type"]);
294 }
295
296 $object_search = new ilLikeObjectSearch($query_parser);
297 $object_search->setFilter($filter["type"]);
298 if ($preset_obj_ids) {
299 $object_search->setIdFilter($preset_obj_ids);
300 }
301 $res = $object_search->performSearch();
302
303 if ($permission) {
304 $res->setRequiredPermission($permission);
305 }
306
307 $res->setMaxHits(self::HIT_LIMIT);
308
309 if ($a_check_lp_activation) {
310 $res->addObserver($this, "searchFilterListener");
311 }
312
313 if (!$this->filter["area"]) {
314 $res->filter(ROOT_FOLDER_ID, true);
315 } else {
316 $res->filter($this->filter["area"], true);
317 }
318
319 $objects = array();
320 foreach ($res->getResults() as $obj_data) {
321 $objects[$obj_data['obj_id']][] = $obj_data['ref_id'];
322 }
323 return $objects ?: array();
324 }
325
331 public function searchFilterListener(int $a_ref_id, array $a_data): bool
332 {
333 if (is_array($this->filter["hide"]) && in_array(
334 $a_data["obj_id"],
335 $this->filter["hide"]
336 )) {
337 return false;
338 }
339 $olp = ilObjectLP::getInstance($a_data["obj_id"]);
340 if (get_class(
341 $olp
342 ) != "ilObjectLP" && // #13654 - LP could be unsupported
343 !$olp->isActive()) {
344 return false;
345 }
346 return true;
347 }
348
349 protected function isForwardingToFormDispatcher(): bool
350 {
351 return false;
352 }
353
354 protected function initRepositoryFilter(array $filter): array
355 {
357 $this->lng->txt('trac_filter_area'),
358 'effective_from',
359 false,
360 ($this->isForwardingToFormDispatcher()) ? $this : null
361 );
362 $white_list = [];
363 foreach ($this->objDefinition->getAllRepositoryTypes() as $type) {
364 if ($this->objDefinition->isContainer($type)) {
365 $white_list[] = $type;
366 }
367 }
368 $repo->getExplorerGUI()->setTypeWhiteList($white_list);
369 $this->addFilterItem($repo);
370 $repo->readFromSession();
371 $filter['area'] = (int) $repo->getValue();
372 return $filter;
373 }
374
378 public function initBaseFilter(
379 bool $a_split_learning_resources = false,
380 bool $a_include_no_status_filter = true
381 ) {
382 $this->setDisableFilterHiding(true);
383
384 // object type selection
385 $si = new ilSelectInputGUI($this->lng->txt("obj_type"), "type");
386 $si->setOptions($this->getPossibleTypes($a_split_learning_resources));
387 $this->addFilterItem($si);
388 $si->readFromSession();
389 if (!$si->getValue()) {
390 $si->setValue("crs");
391 }
392 $this->filter["type"] = $si->getValue();
393
394 // hidden items
395 $msi = new ilMultiSelectInputGUI(
396 $this->lng->txt("trac_filter_hidden"),
397 "hide"
398 );
399 $this->addFilterItem($msi);
400 $msi->readFromSession();
401 $this->filter["hide"] = $msi->getValue();
402 if ($this->filter["hide"]) {
403 // create options from current value
404 $types = $this->getCurrentFilter(true);
405 $options = [];
406 foreach ($this->filter["hide"] as $obj_id) {
407 $options[$obj_id] = $this->ilObjDataCache->lookupTitle(
408 (int) $obj_id
409 );
410 }
411 $msi->setOptions($options);
412 }
413
414 // title/description
415 $ti = new ilTextInputGUI(
416 $this->lng->txt("trac_title_description"),
417 "query"
418 );
419 $ti->setMaxLength(64);
420 $ti->setSize(20);
421 $this->addFilterItem($ti);
422 $ti->readFromSession();
423 $this->filter["query"] = $ti->getValue();
424
425 // repository area selection
427 $this->lng->txt("trac_filter_area"),
428 "area"
429 );
430 $rs->setSelectText($this->lng->txt("trac_select_area"));
431 $this->addFilterItem($rs);
432 $rs->readFromSession();
433 $this->filter["area"] = $rs->getValue();
434
435 // hide "not started yet"
436 if ($a_include_no_status_filter) {
437 $cb = new ilCheckboxInputGUI(
438 $this->lng->txt("trac_filter_has_status"),
439 "status"
440 );
441 $this->addFilterItem($cb);
442 $cb->readFromSession();
443 $this->filter["status"] = $cb->getChecked();
444 }
445 }
446
449 protected function buildPath(array $ref_ids): array
450 {
451 if (!count($ref_ids)) {
452 return [];
453 }
454 $result = [];
455 foreach ($ref_ids as $ref_id) {
456 $path = "...";
457 $counter = 0;
458 $path_full = $this->tree->getPathFull($ref_id);
459 foreach ($path_full as $data) {
460 if (++$counter < (count($path_full) - 1)) {
461 continue;
462 }
463 $path .= " &raquo; ";
464 if ($ref_id != $data['ref_id']) {
465 $path .= $data['title'];
466 } else {
467 $path .= ('<a target="_top" href="' .
468 ilLink::_getLink(
469 $data['ref_id'],
470 $data['type']
471 ) . '">' .
472 $data['title'] . '</a>');
473 }
474 }
475
476 $result[$ref_id] = $path;
477 }
478 return $result;
479 }
480
481 protected function getPossibleTypes(
482 bool $a_split_learning_resources = false,
483 bool $a_include_digilib = false,
484 bool $a_allow_undefined_lp = false
485 ): array {
486 global $DIC;
487
488 $component_repository = $DIC['component.repository'];
489
490 $options = array();
491
492 if ($a_split_learning_resources) {
493 $options['lm'] = $this->lng->txt('objs_lm');
494 $options['sahs'] = $this->lng->txt('objs_sahs');
495 $options['htlm'] = $this->lng->txt('objs_htlm');
496 } else {
497 $options['lres'] = $this->lng->txt('obj_lrss');
498 }
499
500 $options['crs'] = $this->lng->txt('objs_crs');
501 $options['grp'] = $this->lng->txt('objs_grp');
502 $options['exc'] = $this->lng->txt('objs_exc');
503 $options['file'] = $this->lng->txt('objs_file');
504 $options['mcst'] = $this->lng->txt('objs_mcst');
505 $options['svy'] = $this->lng->txt('objs_svy');
506 $options['tst'] = $this->lng->txt('objs_tst');
507 $options['prg'] = $this->lng->txt('objs_prg');
508 $options['iass'] = $this->lng->txt('objs_iass');
509 $options['copa'] = $this->lng->txt('objs_copa');
510 $options['frm'] = $this->lng->txt('objs_frm');
511 $options['cmix'] = $this->lng->txt('objs_cmix');
512 $options['lti'] = $this->lng->txt('objs_lti');
513 $options['lso'] = $this->lng->txt('objs_lso');
514 $options['dcl'] = $this->lng->txt('objs_dcl');
515
516 if ($a_allow_undefined_lp) {
517 $options['root'] = $this->lng->txt('obj_reps');
518 $options['cat'] = $this->lng->txt('objs_cat');
519 $options["webr"] = $this->lng->txt("objs_webr");
520 $options["wiki"] = $this->lng->txt("objs_wiki");
521 $options["blog"] = $this->lng->txt("objs_blog");
522 $options["prtf"] = $this->lng->txt("objs_prtf");
523 $options["prtt"] = $this->lng->txt("objs_prtt");
524 }
525
526 // repository plugins (currently only active)
527 $plugins = $component_repository->getPluginSlotById(
528 "robj"
529 )->getActivePlugins();
530 foreach ($plugins as $pl) {
531 $pl_id = $pl->getId();
534 $pl_id,
535 "objs_" . $pl_id
536 );
537 }
538 }
539
540 asort($options);
541 return $options;
542 }
543
544 protected function parseValue(
545 string $id,
546 ?string $value,
547 string $type
548 ): string {
549 // get rid of aggregation
550 $pos = strrpos($id, "_");
551 if ($pos !== false) {
552 $function = strtoupper(substr($id, $pos + 1));
553 if (in_array(
554 $function,
555 array("MIN", "MAX", "SUM", "AVG", "COUNT")
556 )) {
557 $id = substr($id, 0, $pos);
558 }
559 }
560
561 if ((trim((string) $value) == "") && $id != "status") {
562 if ($id == "title" &&
563 get_class($this) != "ilTrObjectUsersPropsTableGUI" &&
564 get_class($this) != "ilTrMatrixTableGUI") {
565 return "--" . $this->lng->txt("none") . "--";
566 }
567 return " ";
568 }
569
570 switch ($id) {
571 case "first_access":
572 case "create_date":
573 case 'status_changed':
575 new ilDateTime($value, IL_CAL_DATETIME)
576 );
577 break;
578
579 case "last_access":
581 new ilDateTime($value, IL_CAL_UNIX)
582 );
583 break;
584
585 case "birthday":
587 new ilDate($value, IL_CAL_DATE)
588 );
589 break;
590
591 case "spent_seconds":
593 $value = "-";
594 } else {
596 (int) $value,
597 ((int) $value < 3600 ? true : false)
598 ); // #14858
599 }
600 break;
601
602 case "percentage":
603 if (false /* $this->isPercentageAvailable() */) {
604 $value = "-";
605 } else {
606 $value = $value . "%";
607 }
608 break;
609
610 case "mark":
611 if (!ilObjectLP::supportsMark($type)) {
612 $value = "-";
613 }
614 break;
615
616 case "gender":
617 $value = $this->lng->txt("gender_" . $value);
618 break;
619
620 case "status":
621 $icons = ilLPStatusIcons::getInstance($this->getIconVariant());
622 $value = $icons->renderIconForStatus((int) $value);
623 break;
624
625 case "language":
626 $this->lng->loadLanguageModule("meta");
627 $value = $this->lng->txt("meta_l_" . $value);
628 break;
629
630 case "sel_country":
631 $value = $this->lng->txt("meta_c_" . $value);
632 break;
633 }
634
635 return $value ?? '';
636 }
637
638 public function getCurrentFilter(bool $as_query = false): array
639 {
640 $result = array();
641 foreach ($this->filter as $id => $value) {
642 $item = $this->getFilterItemByPostVar($id);
643 switch ($id) {
644 case "title":
645 case "gender":
646 case "city":
647 case "language":
648 case "login":
649 case "firstname":
650 case "lastname":
651 case "mark":
652 case "u_comment":
653 case "institution":
654 case "department":
655 case "street":
656 case "zipcode":
657 case "email":
658 case "matriculation":
659 case "country":
660 case "query":
661 case "type":
662 case "area":
663 if ($value) {
664 $result[$id] = $value;
665 }
666 break;
667
668 case "status":
669 if (!is_null($value) && $value !== "") {
670 $result[$id] = $value;
671 }
672 break;
673
674 case "user_total":
675 case "read_count":
676 case "percentage":
677 case "hide":
678 case "spent_seconds":
679 if (is_array($value) && implode("", $value)) {
680 $result[$id] = $value;
681 }
682 break;
683
684 case "registration":
685 case "create_date":
686 case "first_access":
687 case "last_access":
688 case 'status_changed':
689 if ($value) {
690 if ($value["from"]) {
691 $result[$id]["from"] = $value["from"]->get(
693 );
694 }
695 if ($value["to"]) {
696 $result[$id]["to"] = $value["to"]->get(
698 );
699 }
700 }
701 break;
702
703 case "birthday":
704 if ($value) {
705 if ($value["from"]) {
706 $result[$id]["from"] = $value["from"]->get(
708 );
709 $result[$id]["from"] = substr(
710 $result[$id]["from"],
711 0,
712 -8
713 ) . "00:00:00";
714 }
715 if ($value["to"]) {
716 $result[$id]["to"] = $value["to"]->get(
718 );
719 $result[$id]["to"] = substr(
720 $result[$id]["to"],
721 0,
722 -8
723 ) . "23:59:59";
724 }
725 }
726 break;
727 }
728 }
729 return $result;
730 }
731
732 protected function isPercentageAvailable(int $a_obj_id): bool
733 {
734 if ($a_obj_id === 0) {
735 return false;
736 }
737 $olp = ilObjectLP::getInstance($a_obj_id);
738 $mode = $olp->getCurrentMode();
739 if (in_array(
740 $mode,
741 [
755 ]
756 )) {
757 return true;
758 }
759 return false;
760 }
761
762 protected function parseTitle(
763 int $a_obj_id,
764 string $action,
765 int $a_user_id = 0
766 ) {
767 global $DIC;
768
769 $user = "";
770 if ($a_user_id) {
771 if ($a_user_id != $this->user->getId()) {
772 $a_user = ilObjectFactory::getInstanceByObjId($a_user_id);
773 } else {
774 $a_user = $this->user;
775 }
776 $user .= ", " . $a_user->getFullName(
777 ); // " [".$a_user->getLogin()."]";
778 }
779
780 if ($a_obj_id != ROOT_FOLDER_ID) {
781 $this->setTitle(
782 $this->lng->txt(
783 $action
784 ) . ": " . $this->ilObjDataCache->lookupTitle($a_obj_id) . $user
785 );
786
787 $olp = ilObjectLP::getInstance($a_obj_id);
788 $this->setDescription(
789 $this->lng->txt('trac_mode') . ": " . $olp->getModeText(
790 $olp->getCurrentMode()
791 )
792 );
793 } else {
794 $this->setTitle($this->lng->txt($action));
795 }
796 }
797
801 protected function getExportMeta(): array
802 {
803 global $DIC;
804
805 $ilClientIniFile = $DIC['ilClientIniFile'];
806
807 /* see spec
808 Name of installation
809 Name of the course
810 Permalink to course
811 Owner of course object
812 Date of report generation
813 Reporting period
814 Name of person who generated the report.
815 */
816
818
819 $data = array();
820 $data[$this->lng->txt(
821 "trac_name_of_installation"
822 )] = $ilClientIniFile->readVariable('client', 'name');
823
824 if ($this->obj_id) {
825 $data[$this->lng->txt(
826 "trac_object_name"
827 )] = $this->ilObjDataCache->lookupTitle((int) $this->obj_id);
828 if ($this->ref_id) {
829 $data[$this->lng->txt("trac_object_link")] = ilLink::_getLink(
830 $this->ref_id,
831 ilObject::_lookupType($this->obj_id)
832 );
833 }
834 $data[$this->lng->txt(
835 "trac_object_owner"
837 ilObject::_lookupOwner($this->obj_id)
838 );
839 }
840
841 $data[$this->lng->txt(
842 "trac_report_date"
844 new ilDateTime(
845 time(),
847 )
848 );
849 $data[$this->lng->txt("trac_report_owner")] = $this->user->getFullName(
850 );
851
852 return $data;
853 }
854
855 protected function fillMetaExcel(ilExcel $a_excel, int &$a_row): void
856 {
857 foreach ($this->getExportMeta() as $caption => $value) {
858 $a_excel->setCell($a_row, 0, $caption);
859 $a_excel->setCell($a_row, 1, $value);
860 $a_row++;
861 }
862 $a_row++;
863 }
864
865 protected function fillMetaCSV(ilCSVWriter $a_csv): void
866 {
867 foreach ($this->getExportMeta() as $caption => $value) {
868 $a_csv->addColumn(strip_tags($caption));
869 $a_csv->addColumn(strip_tags($value));
870 $a_csv->addRow();
871 }
872 $a_csv->addRow();
873 }
874
880 protected function showTimingsWarning(int $a_ref_id, int $a_user_id)
881 {
882 $timing_cache = ilTimingCache::getInstanceByRefId($a_ref_id);
883 if ($timing_cache->isWarningRequired($a_user_id)) {
884 $timings = ilTimingCache::_getTimings($a_ref_id);
885 if (
886 $timings['item']['changeable'] &&
887 ($timings['user'][$a_user_id] ?? false) &&
888 $timings['user'][$a_user_id]['end']
889 ) {
890 $end = $timings['user'][$a_user_id]['end'];
891 } elseif ($timings['item']['suggestion_end']) {
892 $end = $timings['item']['suggestion_end'];
893 } else {
894 $end = true;
895 }
896 return $end;
897 }
898 return false;
899 }
900
901 protected function formatSeconds(
902 int $seconds,
903 bool $a_shorten_zero = false
904 ): string {
905 $seconds = ($seconds > 0) ? $seconds : 0;
906 if ($a_shorten_zero && !$seconds) {
907 return "-";
908 }
909
910 $hours = floor($seconds / 3600);
911 $rest = $seconds % 3600;
912
913 $minutes = floor($rest / 60);
914 $rest = $rest % 60;
915
916 if ($rest) {
917 $minutes++;
918 }
919
920 return sprintf("%dh%02dm", $hours, $minutes);
921 }
922
928 protected function anonymizeValue($a_value, bool $a_force_number = false)
929 {
930 // currently inactive
931 return $a_value;
932 }
933
934 protected function buildValueScale(
935 int $a_max_value,
936 bool $a_anonymize = false,
937 bool $a_format_seconds = false
938 ): array {
939 $step = 0;
940 if ($a_max_value) {
941 $step = $a_max_value / 10;
942 $base = ceil(log($step, 10));
943 $fac = ceil($step / pow(10, ($base - 1)));
944 $step = pow(10, $base - 1) * $fac;
945 }
946 if ($step <= 1) {
947 $step = 1;
948 }
949 $ticks = range(0, $a_max_value + $step, $step);
950
951 $value_ticks = array(0 => 0);
952 foreach ($ticks as $tick) {
953 $value = $tvalue = $tick;
954 if ($a_anonymize) {
955 $value = $this->anonymizeValue($value, true);
956 $tvalue = $this->anonymizeValue($tvalue);
957 }
958 if ($a_format_seconds) {
959 $tvalue = $this->formatSeconds($value);
960 }
961 $value_ticks[$value] = $tvalue;
962 }
963
964 return $value_ticks;
965 }
966
967 protected function getMonthsFilter($a_short = false): array
968 {
969 $options = array();
970 for ($loop = 0; $loop < 10; $loop++) {
971 $year = date("Y") - $loop;
972 $options[$year] = $year;
973 for ($loop2 = 12; $loop2 > 0; $loop2--) {
974 $month = str_pad($loop2, 2, "0", STR_PAD_LEFT);
975 if ($year . $month <= date("Ym")) {
976 if (!$a_short) {
977 $caption = $year . " / " . $this->lng->txt(
978 "month_" . $month . "_long"
979 );
980 } else {
981 $caption = $year . "/" . $month;
982 }
983 $options[$year . "-" . $month] = $caption;
984 }
985 }
986 }
987 return $options;
988 }
989
990 protected function getMonthsYear($a_year = null, $a_short = false): array
991 {
992 if (!$a_year) {
993 $a_year = date("Y");
994 }
995
996 $all = array();
997 for ($loop = 1; $loop < 13; $loop++) {
998 $month = str_pad($loop, 2, "0", STR_PAD_LEFT);
999 if ($a_year . "-" . $month <= date("Y-m")) {
1000 if (!$a_short) {
1001 $caption = $this->lng->txt("month_" . $month . "_long");
1002 } else {
1003 $caption = $this->lng->txt("month_" . $month . "_short");
1004 }
1005 $all[$a_year . "-" . $month] = $caption;
1006 }
1007 }
1008 return $all;
1009 }
1010
1011 protected function getSelectableUserColumns(
1012 int $a_in_course = 0,
1013 int $a_in_group = 0
1014 ): array {
1015 $cols = $privacy_fields = array();
1016
1017 if ($a_in_course === 1) {
1018 $ufs = $this->profile->getVisibleFields(Context::Course, null, [AvailableSections::Interests]);
1019 } elseif ($a_in_group === 1) {
1020 $ufs = $this->profile->getVisibleFields(Context::Group, null, [AvailableSections::Interests]);
1021 } else {
1022 $ufs = $this->profile->getFields();
1023 }
1024
1025 // default fields
1026 $cols["login"] = array(
1027 "txt" => $this->lng->txt("login"),
1028 "default" => true
1029 );
1030
1031 if (!$this->anonymized) {
1032 $cols["firstname"] = array(
1033 "txt" => $this->lng->txt("firstname"),
1034 "default" => true
1035 );
1036 $cols["lastname"] = array(
1037 "txt" => $this->lng->txt("lastname"),
1038 "default" => true
1039 );
1040 }
1041
1042 // show only if extended data was activated in lp settings
1043 $tracking = new ilObjUserTracking();
1044 if ($tracking->hasExtendedData(
1046 )) {
1047 $cols["first_access"] = array(
1048 "txt" => $this->lng->txt("trac_first_access"),
1049 "default" => true
1050 );
1051 $cols["last_access"] = array(
1052 "txt" => $this->lng->txt("trac_last_access"),
1053 "default" => true
1054 );
1055 }
1056 if ($tracking->hasExtendedData(
1058 )) {
1059 $cols["read_count"] = array(
1060 "txt" => $this->lng->txt("trac_read_count"),
1061 "default" => true
1062 );
1063 }
1064 if ($tracking->hasExtendedData(
1066 ) &&
1067 ilObjectLP::supportsSpentSeconds($this->type)) {
1068 $cols["spent_seconds"] = array(
1069 "txt" => $this->lng->txt("trac_spent_seconds"),
1070 "default" => true
1071 );
1072 }
1073
1074 if ($this->isPercentageAvailable($this->obj_id)) {
1075 $cols["percentage"] = array(
1076 "txt" => $this->lng->txt("trac_percentage"),
1077 "default" => true
1078 );
1079 }
1080
1081 // do not show status if learning progress is deactivated
1082 $olp = ilObjectLP::getInstance($this->obj_id);
1083 if ($olp->isActive()) {
1084 $cols["status"] = array(
1085 "txt" => $this->lng->txt("trac_status"),
1086 "default" => true
1087 );
1088
1089 $cols['status_changed'] = array(
1090 'txt' => $this->lng->txt('trac_status_changed'),
1091 'default' => false
1092 );
1093 }
1094
1095 if (ilObjectLP::supportsMark($this->type)) {
1096 $cols["mark"] = array(
1097 "txt" => $this->lng->txt("trac_mark"),
1098 "default" => true
1099 );
1100 }
1101
1102 $cols["u_comment"] = array(
1103 "txt" => $this->lng->txt("trac_comment"),
1104 "default" => false
1105 );
1106
1107 $cols["create_date"] = array(
1108 "txt" => $this->lng->txt("create_date"),
1109 "default" => false
1110 );
1111 $cols["language"] = array(
1112 "txt" => $this->lng->txt("language"),
1113 "default" => false
1114 );
1115
1116 // add user data only if object is [part of] course
1117 if (!$this->anonymized &&
1118 ($a_in_course || $a_in_group)) {
1119 // only show if export permission is granted
1120 if (ilPrivacySettings::getInstance()->checkExportAccess(
1121 $a_in_group === 0 ? $a_in_course : $a_in_group
1122 )) {
1123 // other user profile fields
1124 foreach ($ufs as $fd) {
1125 if ($fd->isCustom()) {
1126 continue;
1127 }
1128 $f = $fd->getIdentifier();
1129 if (!isset($cols[$f]) && $f !== "username" && !$fd->hiddenInLists()) {
1130 $cols[$f] = array(
1131 "txt" => $fd->getLabel($this->lng),
1132 "default" => false
1133 );
1134 $privacy_fields[] = $f;
1135 }
1136 }
1137 }
1138 }
1139 return array($cols, $privacy_fields);
1140 }
1141
1145 protected function addToClipboard(): void
1146 {
1147 $users = $this->initUidFromPost();
1148 $clip = ilUserClipboard::getInstance($this->user->getId());
1149 $clip->add($users);
1150 $clip->save();
1151 $this->lng->loadLanguageModule('user');
1152 $this->main_tpl->setOnScreenMessage(
1153 'success',
1154 $this->lng->txt(
1155 'clipboard_user_added'
1156 ),
1157 true
1158 );
1159 }
1160
1164 public function getIconVariant(): int
1165 {
1166 return $this->icon_variant;
1167 }
1168
1172 public function setIconVariant(int $variant): void
1173 {
1174 $this->icon_variant = $variant;
1175 }
1176}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Builds data types.
Definition: Factory.php:36
Class Services.
Definition: Services.php:38
const IL_CAL_DATE
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)
This class represents a checkbox property in a property form.
static setUseRelativeDates(bool $a_status)
set use relative dates
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.
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
const LP_MODE_CMIX_COMPL_OR_PASSED_WITH_FAILED
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
TableGUI class for learning progress.
ilObjectDefinition $objDefinition
fillMetaExcel(ilExcel $a_excel, int &$a_row)
Add meta information to excel export.
sendMail(array $a_user_ids, $a_parent_obj, string $a_parent_cmd)
setIconVariant(int $variant)
Sets the variant of LP icons that is shown in the table.
addToClipboard()
Add selected users to clipboard.
fillMetaCSV(ilCSVWriter $a_csv)
Add meta information to csv export.
showTimingsWarning(int $a_ref_id, int $a_user_id)
ilObjectDataCache $ilObjDataCache
RefineryFactory $refinery
formatSeconds(int $seconds, bool $a_shorten_zero=false)
getMonthsYear($a_year=null, $a_short=false)
anonymizeValue($a_value, bool $a_force_number=false)
searchFilterListener(int $a_ref_id, array $a_data)
Listener for SearchResultFilter Checks wheather the object is hidden and mode is not LP_MODE_DEACTIVA...
initRepositoryFilter(array $filter)
getPossibleTypes(bool $a_split_learning_resources=false, bool $a_include_digilib=false, bool $a_allow_undefined_lp=false)
getIconVariant()
Gets the variant of LP icons that is shown in the table.
findReferencesForObjId(int $a_obj_id)
getCurrentFilter(bool $as_query=false)
getMonthsFilter($a_short=false)
getExportMeta()
Build export meta data.
parseValue(string $id, ?string $value, string $type)
buildValueScale(int $a_max_value, bool $a_anonymize=false, bool $a_format_seconds=false)
initBaseFilter(bool $a_split_learning_resources=false, bool $a_include_no_status_filter=true)
Init filter.
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
isPercentageAvailable(int $a_obj_id)
parseTitle(int $a_obj_id, string $action, int $a_user_id=0)
ilGlobalTemplateInterface $main_tpl
getSelectableUserColumns(int $a_in_course=0, int $a_in_group=0)
searchObjects(array $filter, string $permission, ?array $preset_obj_ids=null, bool $a_check_lp_activation=true)
Search objects that match current filters.
static getLogger(string $a_component_id)
Get component logger.
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
final const string CONTEXT_KEY
This class represents a multi selection list property in a property form.
User class.
static _lookupFullname(int $a_user_id)
static _lookupLogin(int $a_user_id)
class ilObjectDataCache
parses the objects.xml it handles the xml-description of all ilias objects
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static supportsSpentSeconds(string $obj_type)
static supportsMark(string $obj_type)
static getInstance(int $obj_id)
static lookupTxtById(string $plugin_id, string $lang_var)
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
static _lookupOwner(int $obj_id)
Lookup owner user ID for object ID.
static _getAllReferences(int $id)
get all reference ids for object ID
setMinWordLength(int $a_length)
static isTypePluginWithLP(string $a_type, bool $a_active_status=true)
This class represents a repository selector in a property form.
This class represents a selection list property in a property form.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getFilterItemByPostVar(string $a_post_var)
determineOffsetAndOrder(bool $a_omit_offset=false)
resetOffset(bool $a_in_determination=false)
storeProperty(string $type, string $value)
This class represents a text property in a property form.
static getInstanceByRefId(int $ref_id)
static _getTimings(int $a_ref_id)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static getInstance(int $a_usr_id)
static redirect(string $a_script)
const ROOT_FOLDER_ID
Definition: constants.php:32
$ref_id
Definition: ltiauth.php:66
$path
Definition: ltiservices.php:30
$res
Definition: ltiservices.php:69
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, array $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $DIC
Definition: shib_login.php:26
$counter