ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLPTableBaseGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5include_once './Services/Search/classes/class.ilSearchSettings.php';
6require_once('./Services/Repository/classes/class.ilObjectPlugin.php');
7
17{
18 const HIT_LIMIT = 5000;
19
20 protected $filter; // array
21 protected $anonymized; // [bool]
23
24 public function __construct($a_parent_obj, $a_parent_cmd = "", $a_template_context = "")
25 {
26 parent::__construct($a_parent_obj, $a_parent_cmd, $a_template_context);
27
28 // country names
29 $this->lng->loadLanguageModule("meta");
30
31 include_once("./Services/Object/classes/class.ilObjectLP.php");
32
33 $this->anonymized = (bool) !ilObjUserTracking::_enabledUserRelatedData();
34 if (!$this->anonymized && $this->obj_id) {
35 include_once "Services/Object/classes/class.ilObjectLP.php";
36 $olp = ilObjectLP::getInstance($this->obj_id);
37 $this->anonymized = $olp->isAnonymized();
38 }
39 }
40
41 public function executeCommand()
42 {
43 global $DIC;
44
45 $ilCtrl = $DIC['ilCtrl'];
46 $lng = $DIC['lng'];
47
49
50 if (!$ilCtrl->getNextClass($this)) {
51 $to_hide = false;
52
53 switch ($ilCtrl->getCmd()) {
54 case "applyFilter":
55 $this->resetOffset();
56 $this->writeFilterToSession();
57 break;
58
59 case "resetFilter":
60 $this->resetOffset();
61 $this->resetFilter();
62 break;
63
64 case "hideSelected":
65 $to_hide = $_POST["item_id"];
66 break;
67
68 case "hide":
69 $to_hide = array((int) $_GET["hide"]);
70 break;
71
72 case "mailselectedusers":
73 if (!sizeof($_POST["uid"])) {
74 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
75 } else {
76 $this->sendMail($_POST["uid"], $this->parent_obj, $this->parent_cmd);
77 }
78 break;
79
80 case 'addToClipboard':
81 if (!sizeof($_POST['uid'])) {
82 ilUtil::sendFailure($lng->txt('no_checkbox'), true);
83 } else {
84 $this->addToClipboard();
85 }
86 break;
87
88 // page selector
89 default:
91 $this->storeNavParameter();
92 break;
93 }
94
95 if ($to_hide) {
96 $obj = $this->getFilterItemByPostVar("hide");
97 $value = array_unique(array_merge((array) $obj->getValue(), $to_hide));
98 $obj->setValue($value);
99 $obj->writeToSession();
100 }
101
102 if (isset($_REQUEST["tbltplcrt"])) {
103 $ilCtrl->setParameter($this->parent_obj, "tbltplcrt", $_REQUEST["tbltplcrt"]);
104 }
105 if (isset($_REQUEST["tbltpldel"])) {
106 $ilCtrl->setParameter($this->parent_obj, "tbltpldel", $_REQUEST["tbltpldel"]);
107 }
108
109 $ilCtrl->redirect($this->parent_obj, $this->parent_cmd);
110 } else {
111 // e.g. repository selector
112 return parent::executeCommand();
113 }
114 }
115
116 protected function sendMail(array $a_user_ids, $a_parent_obj, $a_parent_cmd)
117 {
118 // see ilObjCourseGUI::sendMailToSelectedUsersObject()
119
120 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
121
122 $rcps = array();
123 foreach ($a_user_ids as $usr_id) {
124 $rcps[] = ilObjUser::_lookupLogin($usr_id);
125 }
126
127 $template = array();
128 $sig = null;
129
130 // repository-object-specific
131 $ref_id = (int) $_REQUEST["ref_id"];
132 if ($ref_id) {
134 $tmpl_id = $obj_lp->getMailTemplateId();
135
136 if ($tmpl_id) {
137 $template = array(
138 ilMailFormCall::CONTEXT_KEY => $tmpl_id,
139 'ref_id' => $ref_id,
140 'ts' => time()
141 );
142 } else {
143 include_once './Services/Link/classes/class.ilLink.php';
144 $sig = ilLink::_getLink($ref_id);
145 $sig = rawurlencode(base64_encode($sig));
146 }
147 }
148
151 $a_parent_obj,
152 $a_parent_cmd,
153 array(),
154 array(
155 'type' => 'new',
156 'rcp_to' => implode(',', $rcps),
157 'sig' => $sig
158 ),
159 $template
160 )
161 );
162 }
163
173 protected function searchObjects(array $filter, $permission, array $preset_obj_ids = null, $a_check_lp_activation = true)
174 {
175 global $DIC;
176
177 $ilObjDataCache = $DIC['ilObjDataCache'];
178
179 include_once './Services/Search/classes/class.ilQueryParser.php';
180
181 $query_parser = new ilQueryParser($filter["query"]);
182 $query_parser->setMinWordLength(0);
183 $query_parser->setCombination(QP_COMBINATION_AND);
184 $query_parser->parse();
185 if (!$query_parser->validate()) {
186 ilLoggerFactory::getLogger('trac')->notice($query_parser->getMessage());
187 // echo $query_parser->getMessage();
188 return false;
189 }
190
191 if ($filter["type"] == "lres") {
192 $filter["type"] = array('lm','sahs','htlm');
193 } else {
194 $filter["type"] = array($filter["type"]);
195 }
196
197 include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
198 $object_search = new ilLikeObjectSearch($query_parser);
199 $object_search->setFilter($filter["type"]);
200 if ($preset_obj_ids) {
201 $object_search->setIdFilter($preset_obj_ids);
202 }
203 $res = $object_search->performSearch();
204
205 if ($permission) {
206 $res->setRequiredPermission($permission);
207 }
208
209 $res->setMaxHits(self::HIT_LIMIT);
210
211 if ($a_check_lp_activation) {
212 $res->addObserver($this, "searchFilterListener");
213 }
214
215 if (!$this->filter["area"]) {
216 $res->filter(ROOT_FOLDER_ID, false);
217 } else {
218 $res->filter($this->filter["area"], false);
219 }
220
221 $objects = array();
222 foreach ($res->getResults() as $obj_data) {
223 $objects[$obj_data['obj_id']][] = $obj_data['ref_id'];
224 }
225 return $objects ? $objects : array();
226 }
227
233 public function searchFilterListener($a_ref_id, $a_data)
234 {
235 if (is_array($this->filter["hide"]) && in_array($a_data["obj_id"], $this->filter["hide"])) {
236 return false;
237 }
238 $olp = ilObjectLP::getInstance($a_data["obj_id"]);
239 if (get_class($olp) != "ilObjectLP" && // #13654 - LP could be unsupported
240 !$olp->isActive()) {
241 return false;
242 }
243 return true;
244 }
245
251 public function initBaseFilter($a_split_learning_resources = false, $a_include_no_status_filter = true)
252 {
253 global $DIC;
254
255 $lng = $DIC['lng'];
256 $ilObjDataCache = $DIC['ilObjDataCache'];
257
258 $this->setDisableFilterHiding(true);
259
260 // object type selection
261 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
262 $si = new ilSelectInputGUI($this->lng->txt("obj_type"), "type");
263 $si->setOptions($this->getPossibleTypes($a_split_learning_resources));
264 $this->addFilterItem($si);
265 $si->readFromSession();
266 if (!$si->getValue()) {
267 $si->setValue("crs");
268 }
269 $this->filter["type"] = $si->getValue();
270
271 // hidden items
272 include_once("./Services/Form/classes/class.ilMultiSelectInputGUI.php");
273 $msi = new ilMultiSelectInputGUI($lng->txt("trac_filter_hidden"), "hide");
274 $this->addFilterItem($msi);
275 $msi->readFromSession();
276 $this->filter["hide"] = $msi->getValue();
277 if ($this->filter["hide"]) {
278 // create options from current value
279 $types = $this->getCurrentFilter(true);
280 $type = $types["type"];
281 $options = array();
282 if ($type == 'lres') {
283 $type = array('lm','sahs','htlm');
284 } else {
285 $type = array($type);
286 }
287 foreach ($this->filter["hide"] as $obj_id) {
288 if (in_array($ilObjDataCache->lookupType($obj_id), $type)) {
289 $options[$obj_id] = $ilObjDataCache->lookupTitle($obj_id);
290 }
291 }
292 $msi->setOptions($options);
293 }
294
295 // title/description
296 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
297 $ti = new ilTextInputGUI($lng->txt("trac_title_description"), "query");
298 $ti->setMaxLength(64);
299 $ti->setSize(20);
300 $this->addFilterItem($ti);
301 $ti->readFromSession();
302 $this->filter["query"] = $ti->getValue();
303
304 // repository area selection
305 include_once("./Services/Form/classes/class.ilRepositorySelectorInputGUI.php");
306 $rs = new ilRepositorySelectorInputGUI($lng->txt("trac_filter_area"), "area");
307 $rs->setSelectText($lng->txt("trac_select_area"));
308 $this->addFilterItem($rs);
309 $rs->readFromSession();
310 $this->filter["area"] = $rs->getValue();
311
312 // hide "not started yet"
313 if ($a_include_no_status_filter) {
314 include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
315 $cb = new ilCheckboxInputGUI($lng->txt("trac_filter_has_status"), "status");
316 $this->addFilterItem($cb);
317 $cb->readFromSession();
318 $this->filter["status"] = $cb->getChecked();
319 }
320 }
321
328 protected function buildPath($ref_ids)
329 {
330 global $DIC;
331
332 $tree = $DIC['tree'];
333 $ilCtrl = $DIC['ilCtrl'];
334
335 include_once './Services/Link/classes/class.ilLink.php';
336
337 if (!count($ref_ids)) {
338 return false;
339 }
340 foreach ($ref_ids as $ref_id) {
341 $path = "...";
342 $counter = 0;
343 $path_full = $tree->getPathFull($ref_id);
344 foreach ($path_full as $data) {
345 if (++$counter < (count($path_full) - 1)) {
346 continue;
347 }
348 $path .= " &raquo; ";
349 if ($ref_id != $data['ref_id']) {
350 $path .= $data['title'];
351 } else {
352 $path .= ('<a target="_top" href="' .
353 ilLink::_getLink($data['ref_id'], $data['type']) . '">' .
354 $data['title'] . '</a>');
355 }
356 }
357
358 $result[$ref_id] = $path;
359 }
360 return $result;
361 }
362
370 protected function getPossibleTypes($a_split_learning_resources = false, $a_include_digilib = false, $a_allow_undefined_lp = false)
371 {
372 global $DIC;
373
374 $lng = $DIC['lng'];
375 $ilPluginAdmin = $DIC['ilPluginAdmin'];
376
377 $options = array();
378
379 if ($a_split_learning_resources) {
380 $options['lm'] = $lng->txt('objs_lm');
381 $options['sahs'] = $lng->txt('objs_sahs');
382 $options['htlm'] = $lng->txt('objs_htlm');
383 } else {
384 $options['lres'] = $lng->txt('obj_lrss');
385 }
386
387 $options['crs'] = $lng->txt('objs_crs');
388 $options['grp'] = $lng->txt('objs_grp');
389 $options['exc'] = $lng->txt('objs_exc');
390 $options['file'] = $lng->txt('objs_file');
391 $options['mcst'] = $lng->txt('objs_mcst');
392 $options['svy'] = $lng->txt('objs_svy');
393 $options['tst'] = $lng->txt('objs_tst');
394 $options['prg'] = $lng->txt('objs_prg');
395 $options['iass'] = $lng->txt('objs_iass');
396 $options['copa'] = $lng->txt('objs_copa');
397 $options['cmix'] = $lng->txt('objs_cmix');
398 $options['lti'] = $lng->txt('objs_lti');
399 $options['lso'] = $lng->txt('objs_lso');
400
401 if ($a_allow_undefined_lp) {
402 $options['root'] = $lng->txt('obj_reps');
403 $options['cat'] = $lng->txt('objs_cat');
404 $options["webr"] = $lng->txt("objs_webr");
405 $options["wiki"] = $lng->txt("objs_wiki");
406 $options["blog"] = $lng->txt("objs_blog");
407 $options["prtf"] = $lng->txt("objs_prtf");
408 $options["prtt"] = $lng->txt("objs_prtt");
409 }
410
411 // repository plugins (currently only active)
412 include_once 'Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php';
413 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Repository", "robj");
414 foreach ($pl_names as $pl) {
415 $pl_id = $ilPluginAdmin->getId(IL_COMP_SERVICE, "Repository", "robj", $pl);
417 $options[$pl_id] = ilObjectPlugin::lookupTxtById($pl_id, "objs_" . $pl_id);
418 }
419 }
420
421 asort($options);
422 return $options;
423 }
424
425 protected function parseValue($id, $value, $type)
426 {
427 global $DIC;
428
429 $lng = $DIC['lng'];
430
431 // get rid of aggregation
432 $pos = strrpos($id, "_");
433 if ($pos !== false) {
434 $function = strtoupper(substr($id, $pos + 1));
435 if (in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT"))) {
436 $id = substr($id, 0, $pos);
437 }
438 }
439
440 if (trim($value) == "" && $id != "status") {
441 if ($id == "title" &&
442 get_class($this) != "ilTrObjectUsersPropsTableGUI" &&
443 get_class($this) != "ilTrMatrixTableGUI") {
444 return "--" . $lng->txt("none") . "--";
445 }
446 return " ";
447 }
448
449 switch ($id) {
450 case "first_access":
451 case "create_date":
452 case 'status_changed':
454 break;
455
456 case "last_access":
458 break;
459
460 case "birthday":
462 break;
463
464 case "spent_seconds":
466 $value = "-";
467 } else {
468 $value = ilDatePresentation::secondsToString($value, ($value < 3600 ? true : false)); // #14858
469 }
470 break;
471
472 case "percentage":
473 if (false /* $this->isPercentageAvailable() */) {
474 $value = "-";
475 } else {
476 $value = $value . "%";
477 }
478 break;
479
480 case "mark":
482 $value = "-";
483 }
484 break;
485
486 case "gender":
487 $value = $lng->txt("gender_" . $value);
488 break;
489
490 case "status":
492 $value = $icons->renderIconForStatus((int) $value);
493 break;
494
495 case "language":
496 $lng->loadLanguageModule("meta");
497 $value = $lng->txt("meta_l_" . $value);
498 break;
499
500 case "sel_country":
501 $value = $lng->txt("meta_c_" . $value);
502 break;
503 }
504
505 return $value;
506 }
507
508 public function getCurrentFilter($as_query = false)
509 {
510 $result = array();
511 foreach ((array) $this->filter as $id => $value) {
512 $item = $this->getFilterItemByPostVar($id);
513 switch ($id) {
514 case "title":
515 case "country":
516 case "gender":
517 case "city":
518 case "language":
519 case "login":
520 case "firstname":
521 case "lastname":
522 case "mark":
523 case "u_comment":
524 case "institution":
525 case "department":
526 case "title":
527 case "street":
528 case "zipcode":
529 case "email":
530 case "matriculation":
531 case "sel_country":
532 case "query":
533 case "type":
534 case "area":
535 if ($value) {
536 $result[$id] = $value;
537 }
538 break;
539
540 case "status":
541 if ($value !== false) {
542 $result[$id] = $value;
543 }
544 break;
545
546 case "user_total":
547 case "read_count":
548 case "percentage":
549 case "hide":
550 case "spent_seconds":
551 if (is_array($value) && implode("", $value)) {
552 $result[$id] = $value;
553 }
554 break;
555
556 case "registration":
557 case "create_date":
558 case "first_access":
559 case "last_access":
560 case 'status_changed':
561 if ($value) {
562 if ($value["from"]) {
563 $result[$id]["from"] = $value["from"]->get(IL_CAL_DATETIME);
564 }
565 if ($value["to"]) {
566 $result[$id]["to"] = $value["to"]->get(IL_CAL_DATETIME);
567 }
568 }
569 break;
570
571 case "birthday":
572 if ($value) {
573 if ($value["from"]) {
574 $result[$id]["from"] = $value["from"]->get(IL_CAL_DATETIME);
575 $result[$id]["from"] = substr($result[$id]["from"], 0, -8) . "00:00:00";
576 }
577 if ($value["to"]) {
578 $result[$id]["to"] = $value["to"]->get(IL_CAL_DATETIME);
579 $result[$id]["to"] = substr($result[$id]["to"], 0, -8) . "23:59:59";
580 }
581 }
582 break;
583 }
584 }
585
586 return $result;
587 }
588
589 protected function isPercentageAvailable($a_obj_id)
590 {
591 // :TODO:
592 $olp = ilObjectLP::getInstance($a_obj_id);
593 $mode = $olp->getCurrentMode();
594 if (in_array($mode, array(ilLPObjSettings::LP_MODE_TLT,
606 return true;
607 }
608 return false;
609 }
610
611 protected function parseTitle($a_obj_id, $action, $a_user_id = false)
612 {
613 global $DIC;
614
615 $lng = $DIC['lng'];
616 $ilObjDataCache = $DIC['ilObjDataCache'];
617 $ilUser = $DIC['ilUser'];
618
619 $user = "";
620 if ($a_user_id) {
621 if ($a_user_id != $ilUser->getId()) {
622 $a_user = ilObjectFactory::getInstanceByObjId($a_user_id);
623 } else {
624 $a_user = $ilUser;
625 }
626 $user .= ", " . $a_user->getFullName(); // " [".$a_user->getLogin()."]";
627 }
628
629 if ($a_obj_id != ROOT_FOLDER_ID) {
630 $this->setTitle($lng->txt($action) . ": " . $ilObjDataCache->lookupTitle($a_obj_id) . $user);
631
632 $olp = ilObjectLP::getInstance($a_obj_id);
633 $this->setDescription($this->lng->txt('trac_mode') . ": " . $olp->getModeText($olp->getCurrentMode()));
634 } else {
635 $this->setTitle($lng->txt($action));
636 }
637 }
638
644 protected function getExportMeta()
645 {
646 global $DIC;
647
648 $lng = $DIC['lng'];
649 $ilObjDataCache = $DIC['ilObjDataCache'];
650 $ilUser = $DIC['ilUser'];
651 $ilClientIniFile = $DIC['ilClientIniFile'];
652
653 /* see spec
654 Name of installation
655 Name of the course
656 Permalink to course
657 Owner of course object
658 Date of report generation
659 Reporting period
660 Name of person who generated the report.
661 */
662
664 include_once './Services/Link/classes/class.ilLink.php';
665
666 $data = array();
667 $data[$lng->txt("trac_name_of_installation")] = $ilClientIniFile->readVariable('client', 'name');
668
669 if ($this->obj_id) {
670 $data[$lng->txt("trac_object_name")] = $ilObjDataCache->lookupTitle($this->obj_id);
671 if ($this->ref_id) {
672 $data[$lng->txt("trac_object_link")] = ilLink::_getLink($this->ref_id, ilObject::_lookupType($this->obj_id));
673 }
674 $data[$lng->txt("trac_object_owner")] = ilObjUser::_lookupFullname(ilObject::_lookupOwner($this->obj_id));
675 }
676
677 $data[$lng->txt("trac_report_date")] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX));
678 $data[$lng->txt("trac_report_owner")] = $ilUser->getFullName();
679
680 return $data;
681 }
682
683 protected function fillMetaExcel(ilExcel $a_excel, &$a_row)
684 {
685 foreach ($this->getExportMeta() as $caption => $value) {
686 $a_excel->setCell($a_row, 0, $caption);
687 $a_excel->setCell($a_row, 1, $value);
688 $a_row++;
689 }
690 $a_row++;
691 }
692
693 protected function fillMetaCSV($a_csv)
694 {
695 foreach ($this->getExportMeta() as $caption => $value) {
696 $a_csv->addColumn(strip_tags($caption));
697 $a_csv->addColumn(strip_tags($value));
698 $a_csv->addRow();
699 }
700 $a_csv->addRow();
701 }
702
703 protected function showTimingsWarning($a_ref_id, $a_user_id)
704 {
705 $timing_cache = ilTimingCache::getInstanceByRefId($a_ref_id);
706 if ($timing_cache->isWarningRequired($a_user_id)) {
707 $timings = ilTimingCache::_getTimings($a_ref_id);
708 if ($timings['item']['changeable'] && $timings['user'][$a_user_id]['end']) {
709 $end = $timings['user'][$a_user_id]['end'];
710 } elseif ($timings['item']['suggestion_end']) {
711 $end = $timings['item']['suggestion_end'];
712 } else {
713 $end = true;
714 }
715 return $end;
716 }
717 }
718
719 protected function formatSeconds($seconds, $a_shorten_zero = false)
720 {
721 $seconds = ((int) $seconds > 0) ? $seconds : 0;
722 if ($a_shorten_zero && !$seconds) {
723 return "-";
724 }
725
726 $hours = floor($seconds / 3600);
727 $rest = $seconds % 3600;
728
729 $minutes = floor($rest / 60);
730 $rest = $rest % 60;
731
732 if ($rest) {
733 $minutes++;
734 }
735
736 return sprintf("%dh%02dm", $hours, $minutes);
737 }
738
739 protected function anonymizeValue($a_value, $a_force_number = false)
740 {
741 // currently inactive
742 return $a_value;
743
744 if (is_numeric($a_value)) {
745 $threshold = 3;
746 $a_value = (int) $a_value;
747 if ($a_value <= $threshold) {
748 if (!$a_force_number) {
749 return "0-" . $threshold;
750 } else {
751 return $threshold;
752 }
753 }
754 }
755 return $a_value;
756 }
757
758 protected function buildValueScale($a_max_value, $a_anonymize = false, $a_format_seconds = false)
759 {
760 $step = 0;
761 if ($a_max_value) {
762 $step = $a_max_value / 10;
763 $base = ceil(log($step, 10));
764 $fac = ceil($step / pow(10, ($base - 1)));
765 $step = pow(10, $base - 1) * $fac;
766 }
767 if ($step <= 1) {
768 $step = 1;
769 }
770 $ticks = range(0, $a_max_value + $step, $step);
771
772 $value_ticks = array(0 => 0);
773 foreach ($ticks as $tick) {
774 $value = $tvalue = $tick;
775 if ($a_anonymize) {
776 $value = $this->anonymizeValue($value, true);
777 $tvalue = $this->anonymizeValue($tvalue);
778 }
779 if ($a_format_seconds) {
780 $tvalue = $this->formatSeconds($value);
781 }
782 $value_ticks[$value] = $tvalue;
783 }
784
785 return $value_ticks;
786 }
787
788 protected function getMonthsFilter($a_short = false)
789 {
790 global $DIC;
791
792 $lng = $DIC['lng'];
793
794 $options = array();
795 for ($loop = 0; $loop < 10; $loop++) {
796 $year = date("Y") - $loop;
797 $options[$year] = $year;
798 for ($loop2 = 12; $loop2 > 0; $loop2--) {
799 $month = str_pad($loop2, 2, "0", STR_PAD_LEFT);
800 if ($year . $month <= date("Ym")) {
801 if (!$a_short) {
802 $caption = $year . " / " . $lng->txt("month_" . $month . "_long");
803 } else {
804 $caption = $year . "/" . $month;
805 }
806 $options[$year . "-" . $month] = $caption;
807 }
808 }
809 }
810 return $options;
811 }
812
813 protected function getMonthsYear($a_year = null, $a_short = false)
814 {
815 global $DIC;
816
817 $lng = $DIC['lng'];
818
819 if (!$a_year) {
820 $a_year = date("Y");
821 }
822
823 $all = array();
824 for ($loop = 1; $loop < 13; $loop++) {
825 $month = str_pad($loop, 2, "0", STR_PAD_LEFT);
826 if ($a_year . "-" . $month <= date("Y-m")) {
827 if (!$a_short) {
828 $caption = $lng->txt("month_" . $month . "_long");
829 } else {
830 $caption = $lng->txt("month_" . $month . "_short");
831 }
832 $all[$a_year . "-" . $month] = $caption;
833 }
834 }
835 return $all;
836 }
837
838 protected function getSelectableUserColumns($a_in_course = false, $a_in_group = false)
839 {
840 global $DIC;
841
842 $lng = $DIC['lng'];
843 $ilSetting = $DIC['ilSetting'];
844
845 $cols = $privacy_fields = array();
846
847 include_once("./Services/User/classes/class.ilUserProfile.php");
848 $up = new ilUserProfile();
849 $up->skipGroup("preferences");
850 $up->skipGroup("settings");
851 $up->skipGroup("interests");
852 $ufs = $up->getStandardFields();
853
854 // default fields
855 $cols["login"] = array(
856 "txt" => $lng->txt("login"),
857 "default" => true);
858
859 if (!$this->anonymized) {
860 $cols["firstname"] = array(
861 "txt" => $lng->txt("firstname"),
862 "default" => true);
863 $cols["lastname"] = array(
864 "txt" => $lng->txt("lastname"),
865 "default" => true);
866 }
867
868 // show only if extended data was activated in lp settings
869 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
870 $tracking = new ilObjUserTracking();
871 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
872 $cols["first_access"] = array(
873 "txt" => $lng->txt("trac_first_access"),
874 "default" => true);
875 $cols["last_access"] = array(
876 "txt" => $lng->txt("trac_last_access"),
877 "default" => true);
878 }
879 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) {
880 $cols["read_count"] = array(
881 "txt" => $lng->txt("trac_read_count"),
882 "default" => true);
883 }
884 if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS) &&
886 $cols["spent_seconds"] = array(
887 "txt" => $lng->txt("trac_spent_seconds"),
888 "default" => true);
889 }
890
891 if ($this->isPercentageAvailable($this->obj_id)) {
892 $cols["percentage"] = array(
893 "txt" => $lng->txt("trac_percentage"),
894 "default" => true);
895 }
896
897 // do not show status if learning progress is deactivated
898 $olp = ilObjectLP::getInstance($this->obj_id);
899 if ($olp->isActive()) {
900 $cols["status"] = array(
901 "txt" => $lng->txt("trac_status"),
902 "default" => true);
903
904 $cols['status_changed'] = array(
905 'txt' => $lng->txt('trac_status_changed'),
906 'default' => false);
907 }
908
909 if (ilObjectLP::supportsMark($this->type)) {
910 $cols["mark"] = array(
911 "txt" => $lng->txt("trac_mark"),
912 "default" => true);
913 }
914
915 $cols["u_comment"] = array(
916 "txt" => $lng->txt("trac_comment"),
917 "default" => false);
918
919 $cols["create_date"] = array(
920 "txt" => $lng->txt("create_date"),
921 "default" => false);
922 $cols["language"] = array(
923 "txt" => $lng->txt("language"),
924 "default" => false);
925
926 // add user data only if object is [part of] course
927 if (!$this->anonymized &&
928 ($a_in_course || $a_in_group)) {
929 // only show if export permission is granted
930 include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
931 if (ilPrivacySettings::_getInstance()->checkExportAccess($this->ref_id)) {
932 // other user profile fields
933 foreach ($ufs as $f => $fd) {
934 if (!isset($cols[$f]) && $f != "username" && !$fd["lists_hide"]) {
935 if ($a_in_course &&
936 !($fd["course_export_fix_value"] || $ilSetting->get("usr_settings_course_export_" . $f))) {
937 continue;
938 }
939 if ($a_in_group &&
940 !($fd["group_export_fix_value"] || $ilSetting->get("usr_settings_group_export_" . $f))) {
941 continue;
942 }
943
944 $cols[$f] = array(
945 "txt" => $lng->txt($f),
946 "default" => false);
947
948 $privacy_fields[] = $f;
949 }
950 }
951
952 // additional defined user data fields
953 include_once './Services/User/classes/class.ilUserDefinedFields.php';
954 $user_defined_fields = ilUserDefinedFields::_getInstance();
955 if ($a_in_course) {
956 $user_defined_fields = $user_defined_fields->getCourseExportableFields();
957 } else {
958 $user_defined_fields = $user_defined_fields->getGroupExportableFields();
959 }
960 foreach ($user_defined_fields as $definition) {
961 if ($definition["field_type"] != UDF_TYPE_WYSIWYG) {
962 $f = "udf_" . $definition["field_id"];
963 $cols[$f] = array(
964 "txt" => $definition["field_name"],
965 "default" => false);
966
967 $privacy_fields[] = $f;
968 }
969 }
970 }
971 }
972
973 return array($cols, $privacy_fields);
974 }
975
979 protected function addToClipboard()
980 {
981 $users = (array) $_POST['uid'];
982 include_once './Services/User/classes/class.ilUserClipboard.php';
983 $clip = ilUserClipboard::getInstance($GLOBALS['DIC']['ilUser']->getId());
984 $clip->add($users);
985 $clip->save();
986
987 $GLOBALS['DIC']['lng']->loadLanguageModule('user');
988 ilUtil::sendSuccess($this->lng->txt('clipboard_user_added'), true);
989 }
990
994 public function getIconVariant() : int
995 {
996 return $this->icon_variant;
997 }
998
1002 public function setIconVariant(int $variant) : void
1003 {
1004 $this->icon_variant = $variant;
1005 }
1006}
$result
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_COMP_SERVICE
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
const QP_COMBINATION_AND
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const UDF_TYPE_WYSIWYG
This class represents a checkbox property in a property form.
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
@classDescription Date and time handling
Class for single dates.
setCell($a_row, $a_col, $a_value, $a_datatype=null)
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.
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
ilTable2GUI constructor.
formatSeconds($seconds, $a_shorten_zero=false)
initBaseFilter($a_split_learning_resources=false, $a_include_no_status_filter=true)
Init filter.
setIconVariant(int $variant)
Sets the variant of LP icons that is shown in the table.
addToClipboard()
Add selected users to clipboard.
parseValue($id, $value, $type)
getCurrentFilter($as_query=false)
showTimingsWarning($a_ref_id, $a_user_id)
getMonthsYear($a_year=null, $a_short=false)
getSelectableUserColumns($a_in_course=false, $a_in_group=false)
fillMetaExcel(ilExcel $a_excel, &$a_row)
Add meta information to excel export.
buildValueScale($a_max_value, $a_anonymize=false, $a_format_seconds=false)
sendMail(array $a_user_ids, $a_parent_obj, $a_parent_cmd)
parseTitle($a_obj_id, $action, $a_user_id=false)
getIconVariant()
Gets the variant of LP icons that is shown in the table.
anonymizeValue($a_value, $a_force_number=false)
getMonthsFilter($a_short=false)
getExportMeta()
Build export meta data.
buildPath($ref_ids)
Build path with deep-link.
fillMetaCSV($a_csv)
Add meta information to csv export.
getPossibleTypes($a_split_learning_resources=false, $a_include_digilib=false, $a_allow_undefined_lp=false)
Get possible subtypes.
executeCommand()
Execute command.
searchObjects(array $filter, $permission, array $preset_obj_ids=null, $a_check_lp_activation=true)
Search objects that match current filters.
searchFilterListener($a_ref_id, $a_data)
Listener for SearchResultFilter Checks wheather the object is hidden and mode is not LP_MODE_DEACTIVA...
static getLogger($a_component_id)
Get component logger.
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
const CONTEXT_KEY
Session parameter for the context.
This class represents a multi selection list property in a property form.
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
static _lookupLogin($a_user_id)
lookup login
static _lookupFullname($a_user_id)
Lookup Full Name.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static supportsMark($a_obj_type)
static supportsSpentSeconds($a_obj_type)
static getInstance($a_obj_id)
static lookupTxtById($plugin_id, $lang_var)
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupOwner($a_id)
lookup object owner
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getInstance()
Get instance of ilPrivacySettings.
static isTypePluginWithLP($a_type, $a_active_status=true)
Check whether a repository type is a plugin which has active learning progress.
This class represents a repository selector in a property form.
This class represents a selection list property in a property form.
Class ilTable2GUI.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
getId()
Get element id.
resetOffset($a_in_determination=false)
Reset offset.
getFilterItemByPostVar($a_post_var)
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
resetFilter()
Reset filter.
writeFilterToSession()
Write filter values to session.
setDescription($a_val)
Set description.
determineSelectedFilters()
Determine selected filters.
This class represents a text property in a property form.
static getInstanceByRefId($ref_id)
static & _getTimings($a_ref_id)
static getInstance($a_usr_id)
Get singelton instance.
static _getInstance()
Get instance.
Class ilUserProfile.
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const ROOT_FOLDER_ID
Definition: constants.php:30
filter()
Definition: filter.php:2
global $DIC
Definition: goto.php:24
$rest
Definition: goto.php:48
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
$type
foreach($_POST as $key=> $value) $res
$cols
Definition: xhr_table.php:11