ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 require_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  {
33  include_once "Services/Object/classes/class.ilObjectLP.php";
34  $olp = ilObjectLP::getInstance($this->obj_id);
35  $this->anonymized = $olp->isAnonymized();
36  }
37  }
38 
39  public function executeCommand()
40  {
41  global $ilCtrl, $lng;
42 
43  $this->determineSelectedFilters();
44 
45  if(!$ilCtrl->getNextClass($this))
46  {
47  $to_hide = false;
48 
49  switch($ilCtrl->getCmd())
50  {
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  {
72  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
73  }
74  else
75  {
76  $this->sendMail($_POST["uid"], $this->parent_obj, $this->parent_cmd);
77  }
78  break;
79 
80  case 'addToClipboard':
81  if(!sizeof($_POST['uid']))
82  {
83  ilUtil::sendFailure($lng->txt('no_checkbox'), true);
84  }
85  else
86  {
87  $this->addToClipboard();
88  }
89  break;
90 
91  // page selector
92  default:
93  $this->determineOffsetAndOrder();
94  $this->storeNavParameter();
95  break;
96  }
97 
98  if($to_hide)
99  {
100  $obj = $this->getFilterItemByPostVar("hide");
101  $value = array_unique(array_merge((array)$obj->getValue(), $to_hide));
102  $obj->setValue($value);
103  $obj->writeToSession();
104  }
105 
106  if(isset($_REQUEST["tbltplcrt"]))
107  {
108  $ilCtrl->setParameter($this->parent_obj, "tbltplcrt", $_REQUEST["tbltplcrt"]);
109  }
110  if(isset($_REQUEST["tbltpldel"]))
111  {
112  $ilCtrl->setParameter($this->parent_obj, "tbltpldel", $_REQUEST["tbltpldel"]);
113  }
114 
115  $ilCtrl->redirect($this->parent_obj, $this->parent_cmd);
116  }
117  else
118  {
119  // e.g. repository selector
120  return parent::executeCommand();
121  }
122  }
123 
124  protected function sendMail(array $a_user_ids, $a_parent_obj, $a_parent_cmd)
125  {
126  // see ilObjCourseGUI::sendMailToSelectedUsersObject()
127 
128  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
129 
130  $rcps = array();
131  foreach($a_user_ids as $usr_id)
132  {
133  $rcps[] = ilObjUser::_lookupLogin($usr_id);
134  }
135 
136  $template = array();
137  $sig = null;
138 
139  // repository-object-specific
140  $ref_id = (int)$_REQUEST["ref_id"];
141  if($ref_id)
142  {
144  $tmpl_id = $obj_lp->getMailTemplateId();
145 
146  if($tmpl_id)
147  {
148  $template = array(
149  ilMailFormCall::CONTEXT_KEY => $tmpl_id,
150  'ref_id' => $ref_id,
151  'ts' => time()
152  );
153  }
154  else
155  {
156  include_once './Services/Link/classes/class.ilLink.php';
157  $sig = ilLink::_getLink($ref_id);
158  $sig = rawurlencode(base64_encode($sig));
159  }
160  }
161 
164  $a_parent_obj,
165  $a_parent_cmd,
166  array(),
167  array(
168  'type' => 'new',
169  'rcp_to' => implode(',', $rcps),
170  'sig' => $sig
171  ),
172  $template
173  )
174  );
175  }
176 
186  protected function searchObjects(array $filter, $permission, array $preset_obj_ids = null, $a_check_lp_activation = true)
187  {
188  global $ilObjDataCache;
189 
190  include_once './Services/Search/classes/class.ilQueryParser.php';
191 
192  $query_parser = new ilQueryParser($filter["query"]);
193  $query_parser->setMinWordLength(0);
194  $query_parser->setCombination(QP_COMBINATION_AND);
195  $query_parser->parse();
196  if(!$query_parser->validate())
197  {
198  ilLoggerFactory::getLogger('trac')->notice($query_parser->getMessage());
199  // echo $query_parser->getMessage();
200  return false;
201  }
202 
203  if($filter["type"] == "lres")
204  {
205  $filter["type"] = array('lm','sahs','htlm');
206  }
207  else
208  {
209  $filter["type"] = array($filter["type"]);
210  }
211 
212  include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
213  $object_search = new ilLikeObjectSearch($query_parser);
214  $object_search->setFilter($filter["type"]);
215  if($preset_obj_ids)
216  {
217  $object_search->setIdFilter($preset_obj_ids);
218  }
219  $res =& $object_search->performSearch();
220 
221  if($permission)
222  {
223  $res->setRequiredPermission($permission);
224  }
225 
226  $res->setMaxHits(1000);
227 
228  if($a_check_lp_activation)
229  {
230  $res->addObserver($this, "searchFilterListener");
231  }
232 
233  if(!$this->filter["area"])
234  {
235  $res->filter(ROOT_FOLDER_ID, false);
236  }
237  else
238  {
239  $res->filter($this->filter["area"], false);
240  }
241 
242  $objects = array();
243  foreach($res->getResults() as $obj_data)
244  {
245  $objects[$obj_data['obj_id']][] = $obj_data['ref_id'];
246  }
247 
248  // Check if search max hits is reached
249  if($res->isLimitReached())
250  {
251  $this->lng->loadLanguageModule("search");
252  ilUtil::sendFailure(sprintf($this->lng->txt("search_limit_reached"), 1000));
253  }
254 
255  return $objects ? $objects : array();
256  }
257 
263  public function searchFilterListener($a_ref_id, $a_data)
264  {
265  if(is_array($this->filter["hide"]) && in_array($a_data["obj_id"], $this->filter["hide"]))
266  {
267  return false;
268  }
269  $olp = ilObjectLP::getInstance($a_data["obj_id"]);
270  if(get_class($olp) != "ilObjectLP" && // #13654 - LP could be unsupported
271  !$olp->isActive())
272  {
273  return false;
274  }
275  return true;
276  }
277 
283  public function initBaseFilter($a_split_learning_resources = false, $a_include_no_status_filter = true)
284  {
285  global $lng, $ilObjDataCache;
286 
287  $this->setDisableFilterHiding(true);
288 
289  // object type selection
290  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
291  $si = new ilSelectInputGUI($this->lng->txt("obj_type"), "type");
292  $si->setOptions($this->getPossibleTypes($a_split_learning_resources));
293  $this->addFilterItem($si);
294  $si->readFromSession();
295  if(!$si->getValue())
296  {
297  $si->setValue("crs");
298  }
299  $this->filter["type"] = $si->getValue();
300 
301  // hidden items
302  include_once("./Services/Form/classes/class.ilMultiSelectInputGUI.php");
303  $msi = new ilMultiSelectInputGUI($lng->txt("trac_filter_hidden"), "hide");
304  $this->addFilterItem($msi);
305  $msi->readFromSession();
306  $this->filter["hide"] = $msi->getValue();
307  if($this->filter["hide"])
308  {
309  // create options from current value
310  $types = $this->getCurrentFilter(true);
311  $type = $types["type"];
312  $options = array();
313  if($type == 'lres')
314  {
315  $type = array('lm','sahs','htlm');
316  }
317  else
318  {
319  $type = array($type);
320  }
321  foreach($this->filter["hide"] as $obj_id)
322  {
323  if(in_array($ilObjDataCache->lookupType($obj_id), $type))
324  {
325  $options[$obj_id] = $ilObjDataCache->lookupTitle($obj_id);
326  }
327  }
328  $msi->setOptions($options);
329  }
330 
331  // title/description
332  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
333  $ti = new ilTextInputGUI($lng->txt("trac_title_description"), "query");
334  $ti->setMaxLength(64);
335  $ti->setSize(20);
336  $this->addFilterItem($ti);
337  $ti->readFromSession();
338  $this->filter["query"] = $ti->getValue();
339 
340  // repository area selection
341  include_once("./Services/Form/classes/class.ilRepositorySelectorInputGUI.php");
342  $rs = new ilRepositorySelectorInputGUI($lng->txt("trac_filter_area"), "area");
343  $rs->setSelectText($lng->txt("trac_select_area"));
344  $this->addFilterItem($rs);
345  $rs->readFromSession();
346  $this->filter["area"] = $rs->getValue();
347 
348  // hide "not started yet"
349  if($a_include_no_status_filter)
350  {
351  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
352  $cb = new ilCheckboxInputGUI($lng->txt("trac_filter_has_status"), "status");
353  $this->addFilterItem($cb);
354  $cb->readFromSession();
355  $this->filter["status"] = $cb->getChecked();
356  }
357  }
358 
365  protected function buildPath($ref_ids)
366  {
367  global $tree, $ilCtrl;
368 
369  include_once './Services/Link/classes/class.ilLink.php';
370 
371  if(!count($ref_ids))
372  {
373  return false;
374  }
375  foreach($ref_ids as $ref_id)
376  {
377  $path = "...";
378  $counter = 0;
379  $path_full = $tree->getPathFull($ref_id);
380  foreach($path_full as $data)
381  {
382  if(++$counter < (count($path_full)-1))
383  {
384  continue;
385  }
386  $path .= " &raquo; ";
387  if($ref_id != $data['ref_id'])
388  {
389  $path .= $data['title'];
390  }
391  else
392  {
393  $path .= ('<a target="_top" href="'.
394  ilLink::_getLink($data['ref_id'],$data['type']).'">'.
395  $data['title'].'</a>');
396  }
397  }
398 
399  $result[$ref_id] = $path;
400  }
401  return $result;
402  }
403 
411  protected function getPossibleTypes($a_split_learning_resources = false, $a_include_digilib = false, $a_allow_undefined_lp = false)
412  {
413  global $lng, $ilPluginAdmin;
414 
415  $options = array();
416 
417  if($a_split_learning_resources)
418  {
419  $options['lm'] = $lng->txt('objs_lm');
420  $options['sahs'] = $lng->txt('objs_sahs');
421  $options['htlm'] = $lng->txt('objs_htlm');
422  }
423  else
424  {
425  $options['lres'] = $lng->txt('learning_resources');
426  }
427 
428  $options['crs'] = $lng->txt('objs_crs');
429  $options['grp'] = $lng->txt('objs_grp');
430  $options['exc'] = $lng->txt('objs_exc');
431  $options['file'] = $lng->txt('objs_file');
432  $options['mcst'] = $lng->txt('objs_mcst');
433  $options['svy'] = $lng->txt('objs_svy');
434  $options['tst'] = $lng->txt('objs_tst');
435  $options['prg'] = $lng->txt('objs_prg');
436  $options['iass'] = $lng->txt('objs_iass');
437 
438  if($a_allow_undefined_lp)
439  {
440  $options["webr"] = $lng->txt("objs_webr");
441  $options["wiki"] = $lng->txt("objs_wiki");
442  $options["blog"] = $lng->txt("objs_blog");
443  $options["prtf"] = $lng->txt("objs_prtf");
444  $options["prtt"] = $lng->txt("objs_prtt");
445  }
446 
447  // repository plugins (currently only active)
448  include_once 'Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php';
449  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Repository", "robj");
450  foreach ($pl_names as $pl)
451  {
452  $pl_id = $ilPluginAdmin->getId(IL_COMP_SERVICE, "Repository", "robj", $pl);
454  {
455  $options[$pl_id] = ilObjectPlugin::lookupTxtById($pl_id, "objs_".$pl_id);
456  }
457  }
458 
459  asort($options);
460  return $options;
461  }
462 
463  protected function parseValue($id, $value, $type)
464  {
465  global $lng;
466 
467  // get rid of aggregation
468  $pos = strrpos($id, "_");
469  if($pos !== false)
470  {
471  $function = strtoupper(substr($id, $pos+1));
472  if(in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT")))
473  {
474  $id = substr($id, 0, $pos);
475  }
476  }
477 
478  if(trim($value) == "" && $id != "status")
479  {
480  if($id == "title" &&
481  get_class($this) != "ilTrObjectUsersPropsTableGUI" &&
482  get_class($this) != "ilTrMatrixTableGUI")
483  {
484  return "--".$lng->txt("none")."--";
485  }
486  return " ";
487  }
488 
489  switch($id)
490  {
491  case "first_access":
492  case "create_date":
493  case 'status_changed':
495  break;
496 
497  case "last_access":
499  break;
500 
501  case "birthday":
502  $value = ilDatePresentation::formatDate(new ilDate($value, IL_CAL_DATE));
503  break;
504 
505  case "spent_seconds":
507  {
508  $value = "-";
509  }
510  else
511  {
512  $value = ilDatePresentation::secondsToString($value, ($value < 3600 ? true : false)); // #14858
513  }
514  break;
515 
516  case "percentage":
517  if(false /* $this->isPercentageAvailable() */)
518  {
519  $value = "-";
520  }
521  else
522  {
523  $value = $value."%";
524  }
525  break;
526 
527  case "mark":
528  if(!ilObjectLP::supportsMark($type))
529  {
530  $value = "-";
531  }
532  break;
533 
534  case "gender":
535  $value = $lng->txt("gender_".$value);
536  break;
537 
538  case "status":
539  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
542  $value = ilUtil::img($path, $text);
543  break;
544 
545  case "language":
546  $lng->loadLanguageModule("meta");
547  $value = $lng->txt("meta_l_".$value);
548  break;
549 
550  case "sel_country":
551  $value = $lng->txt("meta_c_".$value);
552  break;
553  }
554 
555  return $value;
556  }
557 
558  public function getCurrentFilter($as_query = false)
559  {
560  $result = array();
561  foreach((array)$this->filter as $id => $value)
562  {
563  $item = $this->getFilterItemByPostVar($id);
564  switch($id)
565  {
566  case "title":
567  case "country":
568  case "gender":
569  case "city":
570  case "language":
571  case "login":
572  case "firstname":
573  case "lastname":
574  case "mark":
575  case "u_comment":
576  case "institution":
577  case "department":
578  case "title":
579  case "street":
580  case "zipcode":
581  case "email":
582  case "matriculation":
583  case "sel_country":
584  case "query":
585  case "type":
586  case "area":
587  if($value)
588  {
589  $result[$id] = $value;
590  }
591  break;
592 
593  case "status":
594  if($value !== false)
595  {
596  $result[$id] = $value;
597  }
598  break;
599 
600  case "user_total":
601  case "read_count":
602  case "percentage":
603  case "hide":
604  case "spent_seconds":
605  if(is_array($value) && implode("", $value))
606  {
607  $result[$id] = $value;
608  }
609  break;
610 
611  case "registration":
612  case "create_date":
613  case "first_access":
614  case "last_access":
615  case 'status_changed':
616  if($value)
617  {
618  if($value["from"])
619  {
620  $result[$id]["from"] = $value["from"]->get(IL_CAL_DATETIME);
621  }
622  if($value["to"])
623  {
624  $result[$id]["to"] = $value["to"]->get(IL_CAL_DATETIME);
625  }
626  }
627  break;
628 
629  case "birthday":
630  if($value)
631  {
632  if($value["from"])
633  {
634  $result[$id]["from"] = $value["from"]->get(IL_CAL_DATETIME);
635  $result[$id]["from"] = substr($result[$id]["from"], 0, -8)."00:00:00";
636  }
637  if($value["to"])
638  {
639  $result[$id]["to"] = $value["to"]->get(IL_CAL_DATETIME);
640  $result[$id]["to"] = substr($result[$id]["to"], 0, -8)."23:59:59";
641  }
642  }
643  break;
644  }
645  }
646 
647  return $result;
648  }
649 
650  protected function isPercentageAvailable($a_obj_id)
651  {
652  // :TODO:
653  $olp = ilObjectLP::getInstance($a_obj_id);
654  $mode = $olp->getCurrentMode();
655  if(in_array($mode, array(ilLPObjSettings::LP_MODE_TLT,
657  // ilLPObjSettings::LP_MODE_OBJECTIVES,
661  {
662  return true;
663  }
664  return false;
665  }
666 
667  protected function parseTitle($a_obj_id, $action, $a_user_id = false)
668  {
669  global $lng, $ilObjDataCache, $ilUser;
670 
671  $user = "";
672  if($a_user_id)
673  {
674  if($a_user_id != $ilUser->getId())
675  {
676  $a_user = ilObjectFactory::getInstanceByObjId($a_user_id);
677  }
678  else
679  {
680  $a_user = $ilUser;
681  }
682  $user .= ", ".$a_user->getFullName(); // " [".$a_user->getLogin()."]";
683  }
684 
685  if($a_obj_id != ROOT_FOLDER_ID)
686  {
687  $this->setTitle($lng->txt($action).": ".$ilObjDataCache->lookupTitle($a_obj_id).$user);
688 
689  $olp = ilObjectLP::getInstance($a_obj_id);
690  $this->setDescription($this->lng->txt('trac_mode').": ".$olp->getModeText($olp->getCurrentMode()));
691  }
692  else
693  {
694  $this->setTitle($lng->txt($action));
695  }
696  }
697 
703  protected function getExportMeta()
704  {
705  global $lng, $ilObjDataCache, $ilUser, $ilClientIniFile;
706 
707  /* see spec
708  Name of installation
709  Name of the course
710  Permalink to course
711  Owner of course object
712  Date of report generation
713  Reporting period
714  Name of person who generated the report.
715  */
716 
718  include_once './Services/Link/classes/class.ilLink.php';
719 
720  $data = array();
721  $data[$lng->txt("trac_name_of_installation")] = $ilClientIniFile->readVariable('client', 'name');
722 
723  if($this->obj_id)
724  {
725  $data[$lng->txt("trac_object_name")] = $ilObjDataCache->lookupTitle($this->obj_id);
726  if($this->ref_id)
727  {
728  $data[$lng->txt("trac_object_link")] = ilLink::_getLink($this->ref_id, ilObject::_lookupType($this->obj_id));
729  }
730  $data[$lng->txt("trac_object_owner")] = ilObjUser::_lookupFullname(ilObject::_lookupOwner($this->obj_id));
731  }
732 
733  $data[$lng->txt("trac_report_date")] =
735  $data[$lng->txt("trac_report_owner")] = $ilUser->getFullName();
736 
737  return $data;
738  }
739 
740  protected function fillMetaExcel(ilExcel $a_excel, &$a_row)
741  {
742  foreach($this->getExportMeta() as $caption => $value)
743  {
744  $a_excel->setCell($a_row, 0, $caption);
745  $a_excel->setCell($a_row, 1, $value);
746  $a_row++;
747  }
748  $a_row++;
749  }
750 
751  protected function fillMetaCSV($a_csv)
752  {
753  foreach($this->getExportMeta() as $caption => $value)
754  {
755  $a_csv->addColumn(strip_tags($caption));
756  $a_csv->addColumn(strip_tags($value));
757  $a_csv->addRow();
758  }
759  $a_csv->addRow();
760  }
761 
762  protected function showTimingsWarning($a_ref_id, $a_user_id)
763  {
764  include_once 'Modules/Course/classes/Timings/class.ilTimingCache.php';
765  if(ilTimingCache::_showWarning($a_ref_id, $a_user_id))
766  {
767  $timings = ilTimingCache::_getTimings($a_ref_id);
768  if($timings['item']['changeable'] && $timings['user'][$a_user_id]['end'])
769  {
770  $end = $timings['user'][$a_user_id]['end'];
771  }
772  else if ($timings['item']['suggestion_end'])
773  {
774  $end = $timings['item']['suggestion_end'];
775  }
776  else
777  {
778  $end = true;
779  }
780  return $end;
781  }
782  }
783 
784  protected function formatSeconds($seconds, $a_shorten_zero = false)
785  {
786  $seconds = ((int)$seconds > 0) ? $seconds : 0;
787  if($a_shorten_zero && !$seconds)
788  {
789  return "-";
790  }
791 
792  $hours = floor($seconds / 3600);
793  $rest = $seconds % 3600;
794 
795  $minutes = floor($rest / 60);
796  $rest = $rest % 60;
797 
798  if($rest)
799  {
800  $minutes++;
801  }
802 
803  return sprintf("%dh%02dm",$hours,$minutes);
804  }
805 
806  protected function anonymizeValue($a_value, $a_force_number = false)
807  {
808  // currently inactive
809  return $a_value;
810 
811  if(is_numeric($a_value))
812  {
813  $threshold = 3;
814  $a_value = (int)$a_value;
815  if($a_value <= $threshold)
816  {
817  if(!$a_force_number)
818  {
819  return "0-".$threshold;
820  }
821  else
822  {
823  return $threshold;
824  }
825  }
826  }
827  return $a_value;
828  }
829 
830  protected function buildValueScale($a_max_value, $a_anonymize = false, $a_format_seconds = false)
831  {
832  $step = 0;
833  if($a_max_value)
834  {
835  $step = $a_max_value / 10;
836  $base = ceil(log($step, 10));
837  $fac = ceil($step / pow(10, ($base - 1)));
838  $step = pow(10, $base - 1) * $fac;
839  }
840  if ($step <= 1)
841  {
842  $step = 1;
843  }
844  $ticks = range(0, $a_max_value+$step, $step);
845 
846  $value_ticks = array(0 => 0);
847  foreach($ticks as $tick)
848  {
849  $value = $tvalue = $tick;
850  if($a_anonymize)
851  {
852  $value = $this->anonymizeValue($value, true);
853  $tvalue = $this->anonymizeValue($tvalue);
854  }
855  if($a_format_seconds)
856  {
857  $tvalue = $this->formatSeconds($value);
858  }
859  $value_ticks[$value] = $tvalue;
860  }
861 
862  return $value_ticks;
863  }
864 
865  protected function getMonthsFilter($a_short = false)
866  {
867  global $lng;
868 
869  $options = array();
870  for($loop = 0; $loop < 10; $loop++)
871  {
872  $year = date("Y")-$loop;
873  $options[$year] = $year;
874  for($loop2 = 12; $loop2 > 0; $loop2--)
875  {
876  $month = str_pad($loop2, 2, "0", STR_PAD_LEFT);
877  if($year.$month <= date("Ym"))
878  {
879  if(!$a_short)
880  {
881  $caption = $year." / ".$lng->txt("month_".$month."_long");
882  }
883  else
884  {
885  $caption = $year."/".$month;
886  }
887  $options[$year."-".$month] = $caption;
888  }
889  }
890  }
891  return $options;
892  }
893 
894  protected function getMonthsYear($a_year = null, $a_short = false)
895  {
896  global $lng;
897 
898  if(!$a_year)
899  {
900  $a_year = date("Y");
901  }
902 
903  $all = array();
904  for($loop = 1; $loop<13; $loop++)
905  {
906  $month = str_pad($loop, 2, "0", STR_PAD_LEFT);
907  if($a_year."-".$month <= date("Y-m"))
908  {
909  if(!$a_short)
910  {
911  $caption = $lng->txt("month_".$month."_long");
912  }
913  else
914  {
915  $caption = $lng->txt("month_".$month."_short");
916  }
917  $all[$a_year."-".$month] = $caption;
918  }
919  }
920  return $all;
921  }
922 
923  protected function getSelectableUserColumns($a_in_course = false, $a_in_group = false)
924  {
925  global $lng, $ilSetting;
926 
927  $cols = $privacy_fields = array();
928 
929  include_once("./Services/User/classes/class.ilUserProfile.php");
930  $up = new ilUserProfile();
931  $up->skipGroup("preferences");
932  $up->skipGroup("settings");
933  $up->skipGroup("interests");
934  $ufs = $up->getStandardFields();
935 
936  // default fields
937  $cols["login"] = array(
938  "txt" => $lng->txt("login"),
939  "default" => true);
940 
941  if(!$this->anonymized)
942  {
943  $cols["firstname"] = array(
944  "txt" => $lng->txt("firstname"),
945  "default" => true);
946  $cols["lastname"] = array(
947  "txt" => $lng->txt("lastname"),
948  "default" => true);
949  }
950 
951  // show only if extended data was activated in lp settings
952  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
953  $tracking = new ilObjUserTracking();
954  if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS))
955  {
956  $cols["first_access"] = array(
957  "txt" => $lng->txt("trac_first_access"),
958  "default" => true);
959  $cols["last_access"] = array(
960  "txt" => $lng->txt("trac_last_access"),
961  "default" => true);
962  }
963  if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT))
964  {
965  $cols["read_count"] = array(
966  "txt" => $lng->txt("trac_read_count"),
967  "default" => true);
968  }
969  if($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS) &&
971  {
972  $cols["spent_seconds"] = array(
973  "txt" => $lng->txt("trac_spent_seconds"),
974  "default" => true);
975  }
976 
977  if($this->isPercentageAvailable($this->obj_id))
978  {
979  $cols["percentage"] = array(
980  "txt" => $lng->txt("trac_percentage"),
981  "default" => true);
982  }
983 
984  // do not show status if learning progress is deactivated
985  $olp = ilObjectLP::getInstance($this->obj_id);
986  if($olp->isActive())
987  {
988  $cols["status"] = array(
989  "txt" => $lng->txt("trac_status"),
990  "default" => true);
991 
992  $cols['status_changed'] = array(
993  'txt' => $lng->txt('trac_status_changed'),
994  'default' => false);
995  }
996 
997  if(ilObjectLP::supportsMark($this->type))
998  {
999  $cols["mark"] = array(
1000  "txt" => $lng->txt("trac_mark"),
1001  "default" => true);
1002  }
1003 
1004  $cols["u_comment"] = array(
1005  "txt" => $lng->txt("trac_comment"),
1006  "default" => false);
1007 
1008  $cols["create_date"] = array(
1009  "txt" => $lng->txt("create_date"),
1010  "default" => false);
1011  $cols["language"] = array(
1012  "txt" => $lng->txt("language"),
1013  "default" => false);
1014 
1015  // add user data only if object is [part of] course
1016  if(!$this->anonymized &&
1017  ($a_in_course || $a_in_group))
1018  {
1019  // only show if export permission is granted
1020  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
1021  if(ilPrivacySettings::_getInstance()->checkExportAccess($this->ref_id))
1022  {
1023  // other user profile fields
1024  foreach ($ufs as $f => $fd)
1025  {
1026  if (!isset($cols[$f]) && $f != "username" && !$fd["lists_hide"])
1027  {
1028  if($a_in_course &&
1029  !($fd["course_export_fix_value"] || $ilSetting->get("usr_settings_course_export_".$f)))
1030  {
1031  continue;
1032  }
1033  if($a_in_group &&
1034  !($fd["group_export_fix_value"] || $ilSetting->get("usr_settings_group_export_".$f)))
1035  {
1036  continue;
1037  }
1038 
1039  $cols[$f] = array(
1040  "txt" => $lng->txt($f),
1041  "default" => false);
1042 
1043  $privacy_fields[] = $f;
1044  }
1045  }
1046 
1047  // additional defined user data fields
1048  include_once './Services/User/classes/class.ilUserDefinedFields.php';
1049  $user_defined_fields = ilUserDefinedFields::_getInstance();
1050  if($a_in_course)
1051  {
1052  $user_defined_fields = $user_defined_fields->getCourseExportableFields();
1053  }
1054  else
1055  {
1056  $user_defined_fields = $user_defined_fields->getGroupExportableFields();
1057  }
1058  foreach($user_defined_fields as $definition)
1059  {
1060  if($definition["field_type"] != UDF_TYPE_WYSIWYG)
1061  {
1062  $f = "udf_".$definition["field_id"];
1063  $cols[$f] = array(
1064  "txt" => $definition["field_name"],
1065  "default" => false);
1066 
1067  $privacy_fields[] = $f;
1068  }
1069  }
1070  }
1071  }
1072 
1073  return array($cols, $privacy_fields);
1074  }
1075 
1079  protected function addToClipboard()
1080  {
1081  $users = (array) $_POST['uid'];
1082  include_once './Services/User/classes/class.ilUserClipboard.php';
1083  $clip = ilUserClipboard::getInstance($GLOBALS['ilUser']->getId());
1084  $clip->add($users);
1085  $clip->save();
1086 
1087  $GLOBALS['lng']->loadLanguageModule('user');
1088  ilUtil::sendSuccess($this->lng->txt('clipboard_user_added'),true);
1089 
1090  }
1091 }
1092 
1093 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _lookupLogin($a_user_id)
lookup login
anonymizeValue($a_value, $a_force_number=false)
setDescription($a_val)
Set description.
buildPath($ref_ids)
Build path with deep-link.
getSelectableUserColumns($a_in_course=false, $a_in_group=false)
$path
Definition: aliased.php:25
$rest
Definition: goto.php:48
static isTypePluginWithLP($a_type, $a_active_status=true)
Check whether a repository type is a plugin which has active learning progress.
const IL_CAL_DATETIME
static _getInstance()
Get instance.
static lookupTxtById($plugin_id, $lang_var)
static getInstance($a_usr_id)
Get singelton instance.
This class represents a selection list property in a property form.
$result
static _getImagePathForStatus($a_status)
Get image path for status.
$_GET["client_id"]
static _lookupFullname($a_user_id)
Lookup Full Name.
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
getMonthsYear($a_year=null, $a_short=false)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
searchObjects(array $filter, $permission, array $preset_obj_ids=null, $a_check_lp_activation=true)
Search objects that match current filters.
resetOffset($a_in_determination=false)
Reset offset.
getFilterItemByPostVar($a_post_var)
Class ilUserProfile.
This class represents a checkbox property in a property form.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
static setUseRelativeDates($a_status)
set use relative dates
parseTitle($a_obj_id, $action, $a_user_id=false)
getPossibleTypes($a_split_learning_resources=false, $a_include_digilib=false, $a_allow_undefined_lp=false)
Get possible subtypes.
const IL_CAL_UNIX
parseValue($id, $value, $type)
Resolve range
addToClipboard()
Add selected users to clipboard.
static _lookupObjectId($a_ref_id)
lookup object id
global $ilCtrl
Definition: ilias.php:18
initBaseFilter($a_split_learning_resources=false, $a_include_no_status_filter=true)
Init filter.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
$counter
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
This class represents a multi selection list property in a property form.
Class ilTable2GUI.
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
Class for single dates.
TableGUI class for learning progress.
if(!is_array($argv)) $options
getExportMeta()
Build export meta data.
static _showWarning($a_ref_id, $a_usr_id)
This class represents a repository selector in a property form.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
buildValueScale($a_max_value, $a_anonymize=false, $a_format_seconds=false)
This class represents a text property in a property form.
static formatDate(ilDateTime $date)
Format a date public.
foreach( $_REQUEST as $var) foreach(array('_POST'=> 'HTTP_POST_VARS', '_GET'=> 'HTTP_GET_VARS', '_COOKIE'=> 'HTTP_COOKIE_VARS', '_SERVER'=> 'HTTP_SERVER_VARS', '_ENV'=> 'HTTP_ENV_VARS', '_FILES'=> 'HTTP_POST_FILES') as $array=> $other) $step
Definition: cssgen.php:155
Date and time handling
$ilUser
Definition: imgupload.php:18
static _lookupOwner($a_id)
lookup object owner
setMaxLength($a_maxlength)
Set Max Length.
searchFilterListener($a_ref_id, $a_data)
Listener for SearchResultFilter Checks wheather the object is hidden and mode is not LP_MODE_DEACTIVA...
fillMetaExcel(ilExcel $a_excel, &$a_row)
const UDF_TYPE_WYSIWYG
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const CONTEXT_KEY
Session parameter for the context.
writeFilterToSession()
Write filter values to session.
static supportsMark($a_obj_type)
sendMail(array $a_user_ids, $a_parent_obj, $a_parent_cmd)
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
setCell($a_row, $a_col, $a_value)
Set cell value.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
determineSelectedFilters()
Determine selected filters.
const IL_CAL_DATE
static supportsSpentSeconds($a_obj_type)
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
$ref_id
Definition: sahs_server.php:39
getMonthsFilter($a_short=false)
global $ilSetting
Definition: privfeed.php:17
formatSeconds($seconds, $a_shorten_zero=false)
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
global $lng
Definition: privfeed.php:17
showTimingsWarning($a_ref_id, $a_user_id)
$text
static getLogger($a_component_id)
Get component logger.
const QP_COMBINATION_AND
static _getInstance()
Get instance of ilPrivacySettings.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
getId()
Get element id.
getCurrentFilter($as_query=false)
static redirect($a_script)
http redirect to other script
static getInstance($a_obj_id)
$_POST["username"]
resetFilter()
Reset filter.
const IL_COMP_SERVICE
static & _getTimings($a_ref_id)