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