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