ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPortfolioPageGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
5 
19 {
23  protected $obj_definition;
24 
28  protected $tree;
29 
30  const EMBEDDED_NO_OUTPUT = -99;
31 
32  protected $js_onload_code = array();
33  protected $additional = array();
34  protected $export_material = array("js" => array(), "images" => array(), "files" => array());
35 
36  protected static $initialized = 0;
37 
41  protected $requested_ppage;
42 
46  public function __construct($a_portfolio_id, $a_id = 0, $a_old_nr = 0, $a_enable_comments = true)
47  {
48  global $DIC;
49 
50  $this->tpl = $DIC["tpl"];
51  $this->ctrl = $DIC->ctrl();
52  $this->user = $DIC->user();
53  $this->obj_definition = $DIC["objDefinition"];
54  $this->access = $DIC->access();
55  $this->tree = $DIC->repositoryTree();
56  $this->lng = $DIC->language();
57  $tpl = $DIC["tpl"];
58 
59  $this->portfolio_id = (int) $a_portfolio_id;
60  $this->enable_comments = (bool) $a_enable_comments;
61 
62  parent::__construct($this->getParentType(), $a_id, $a_old_nr);
63  $this->getPageObject()->setPortfolioId($this->portfolio_id);
64 
65  // content style
66  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
67 
68  $tpl->setCurrentBlock("SyntaxStyle");
69  $tpl->setVariable(
70  "LOCATION_SYNTAX_STYLESHEET",
72  );
73  $tpl->parseCurrentBlock();
74 
75  $tpl->setCurrentBlock("ContentStyle");
76  $tpl->setVariable(
77  "LOCATION_CONTENT_STYLESHEET",
79  );
80  $tpl->setVariable(
81  "LOCATION_ADDITIONAL_STYLESHEET",
83  );
84  $tpl->parseCurrentBlock();
85 
86  $this->requested_ppage = (int) $_GET["ppage"];
87  }
88 
89  public function getParentType()
90  {
91  return "prtf";
92  }
93 
94  protected function getPageContentUserId($a_user_id)
95  {
96  // user id from content-xml
97  return $a_user_id;
98  }
99 
103  public function executeCommand()
104  {
107 
108  $next_class = $this->ctrl->getNextClass($this);
109  $cmd = $this->ctrl->getCmd();
110 
111  switch ($next_class) {
112  case "ilobjbloggui":
113  // #12879 - we need the wsp-id for the keywords
114  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
115  $wsp_tree = new ilWorkspaceTree($ilUser->getId());
116  $blog_obj_id = (int) $this->getPageObject()->getTitle();
117  $blog_node_id = $wsp_tree->lookupNodeId($blog_obj_id);
118 
119  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
120  $blog_gui = new ilObjBlogGUI($blog_node_id, ilObjBlogGUI::WORKSPACE_NODE_ID);
121  $blog_gui->disableNotes(!$this->enable_comments);
122  $blog_gui->prtf_embed = true; // disables prepareOutput()/getStandardTemplate() in blog
123  return $ilCtrl->forwardCommand($blog_gui);
124 
125  case "ilcalendarmonthgui":
126 
127 
128  // booking action
129  if ($cmd && $cmd != "preview") {
130  $categories = ilCalendarCategories::_getInstance();
131  if ($categories->getMode() == 0) {
132  if ($_GET['chuid']) {
133  $categories->setCHUserId((int) $_GET['chuid']);
134  }
135  $categories->initialize(ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION, null, true);
136  }
137 
138  if ($_GET['seed']) {
139  $seed = new ilDate((string) $_GET['seed'], IL_CAL_DATE);
140  } else {
141  $seed = new ilDate(time(), IL_CAL_UNIX);
142  }
143 
144  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
145  $month_gui = new ilCalendarMonthGUI($seed);
146  return $ilCtrl->forwardCommand($month_gui);
147  }
148  // calendar month navigation
149  else {
150  $ilCtrl->setParameter($this, "cmd", "preview");
151  return self::EMBEDDED_NO_OUTPUT;
152  }
153 
154  // no break
155  case "ilpageobjectgui":
156  die("Deprecated. ilPortfolioPage gui forwarding to ilpageobject");
157  return;
158 
159  default:
160  $this->setPresentationTitle($this->getPageObject()->getTitle());
161  return parent::executeCommand();
162  }
163  }
164 
170  public function showPage()
171  {
173 
174  if (!$this->getPageObject()) {
175  return;
176  }
177 
178  switch ($this->getPageObject()->getType()) {
180  return $this->renderBlog($ilUser->getId(), (int) $this->getPageObject()->getTitle());
181 
182  default:
183  $this->setTemplateOutput(false);
184  // $this->setPresentationTitle($this->getPageObject()->getTitle());
185  $output = parent::showPage();
186 
187  return $output;
188  }
189  }
190 
197  public function getTabs($a_activate = "")
198  {
199  if (!$this->embedded) {
200  parent::getTabs($a_activate);
201  }
202  }
203 
209  public function setEmbedded($a_value)
210  {
211  $this->embedded = (bool) $a_value;
212  }
213 
219  public function setAdditional($a_additional)
220  {
221  $this->additional = $a_additional;
222  }
223 
229  public function getAdditional()
230  {
231  return $this->additional;
232  }
233 
234  public function getJsOnloadCode()
235  {
236  return $this->js_onload_code;
237  }
238 
239  public function postOutputProcessing($a_output)
240  {
241  $parts = array(
242  "Profile" => array("0-9", "a-z", "0-9a-z_;\W"), // user, mode, fields
243  "Verification" => array("0-9", "a-z", "0-9"), // user, type, id
244  "Blog" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
245  "BlogTeaser" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
246  "Skills" => array("0-9", "0-9"), // user, skill id
247  "SkillsTeaser" => array("0-9", "0-9"), // user, skill id
248  "ConsultationHours" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
249  "ConsultationHoursTeaser" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
250  "MyCourses" => array("0-9", "a-z*"), // user, sort
251  "MyCoursesTeaser" => array("0-9", "a-z*") // user, sort
252  );
253 
254  foreach ($parts as $type => $def) {
255  // #15732 - allow optional parts
256  $def_parts = array();
257  foreach ($def as $part) {
258  $is_opt = (substr($part, -1) == "*");
259  if (!$is_opt) {
260  $def_parts[] = "#";
261  $end_marker = "+";
262  } else {
263  $def_parts[] = "#*";
264  $end_marker = "*";
265  $part = substr($part, 0, -1);
266  }
267  $def_parts[] = "([" . $part . "]" . $end_marker . ")";
268  }
269  $def = implode("", $def_parts);
270 
271  if (preg_match_all(
272  "/" . $this->pl_start . $type . $def . $this->pl_end . "/",
273  $a_output,
274  $blocks
275  )) {
276  foreach ($blocks[0] as $idx => $block) {
277  switch ($type) {
278  case "Profile":
279  case "Blog":
280  case "BlogTeaser":
281  case "Skills":
282  case "SkillsTeaser":
283  case "ConsultationHours":
284  case "ConsultationHoursTeaser":
285  case "MyCourses":
286  case "MyCoursesTeaser":
287  $subs = null;
288  if (trim($blocks[3][$idx])) {
289  foreach (explode(";", $blocks[3][$idx]) as $sub) {
290  if (trim($sub)) {
291  $subs[] = trim($sub);
292  }
293  }
294  }
295  $snippet = $this->{"render" . $type}(
296  $blocks[1][$idx],
297  $blocks[2][$idx],
298  $subs
299  );
300  break;
301 
302  default:
303  $snippet = $this->{"render" . $type}(
304  $blocks[1][$idx],
305  $blocks[2][$idx],
306  $blocks[3][$idx]
307  );
308  break;
309  }
310 
311  $snippet = $this->renderPageElement($type, $snippet);
312  $a_output = str_replace($block, $snippet, $a_output);
313  }
314  }
315  }
316 
317  $a_output = $this->makePlaceHoldersClickable($a_output);
318 
319  return $a_output;
320  }
321 
322  protected function renderPageElement($a_type, $a_html)
323  {
324  return trim($a_html);
325  }
326 
327  protected function renderTeaser($a_type, $a_title, $a_options = null)
328  {
329  $options = "";
330  if ($a_options) {
331  $options = '<div class="il_Footer">' . $this->lng->txt("prtf_page_element_teaser_settings") .
332  ": " . $a_options . '</div>';
333  }
334 
335  return '<div style="margin:5px" class="ilBox"><h3>' . $a_title . '</h3>' .
336  '<div class="il_Description_no_margin">' . $this->lng->txt("prtf_page_element_teaser_" . $a_type) . '</div>' .
337  $options . '</div>';
338  }
339 
340  protected function renderProfile($a_user_id, $a_type, array $a_fields = null)
341  {
343 
344  $user_id = $this->getPageContentUserId($a_user_id);
345 
346  if ($this->getOutputMode() == "offline") {
347  // profile picture is done in ilPortfolioHTMLExport
348 
349  $this->export_material["js"][] = "http://maps.google.com/maps/api/js?sensor=false";
350  $this->export_material["js"][] = "./Services/Maps/js/ServiceGoogleMaps.js";
351  $this->export_material["js"][] = "./Services/Maps/js/OpenLayers.js";
352  $this->export_material["js"][] = "./Services/Maps/js/ServiceOpenLayers.js";
353  }
354 
355  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
356  $pub_profile = new ilPublicUserProfileGUI($user_id);
357  $pub_profile->setEmbedded(true, ($this->getOutputMode() == "offline"));
358 
359  // full circle: additional was set in the original public user profile call
360  $pub_profile->setAdditional($this->getAdditional());
361 
362  if ($a_type == "manual" && sizeof($a_fields)) {
363  $prefs = array();
364  foreach ($a_fields as $field) {
365  $field = trim($field);
366  if ($field) {
367  $prefs["public_" . $field] = "y";
368  }
369  }
370 
371  $pub_profile->setCustomPrefs($prefs);
372  }
373 
374  if ($this->getOutputMode() != "offline") {
375  return $ilCtrl->getHTML($pub_profile);
376  } else {
377  return $pub_profile->getEmbeddable();
378  }
379  }
380 
388  protected function renderVerification($a_user_id, $a_type, $a_id)
389  {
390  $objDefinition = $this->obj_definition;
391 
392  $outputMode = $this->getOutputMode();
393 
394  // not used
395  // $user_id = $this->getPageContentUserId($a_user_id);
396  if ($a_type === 'crta' && $outputMode === 'offline') {
397  $fileService = new ilPortfolioCertificateFileService();
398 
399  $certificatePdfFile = $fileService->createCertificateFilePath($a_user_id, $a_id);
400  $this->export_material["files"][] = $certificatePdfFile;
401 
402  $url = 'files/' . basename($certificatePdfFile);
403 
404  $userCertificateRepository = new ilUserCertificateRepository();
405 
406  return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
407  } elseif ($a_type === 'crta' && $outputMode === 'print') {
408  $userCertificateRepository = new ilUserCertificateRepository();
409  $url = $this->getPagePermaLink();
410 
411  return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
412  } elseif ($a_type === 'crta') {
413  $this->ctrl->setParameter($this, "dlid", $a_id);
414  $url = $this->ctrl->getLinkTarget($this, "dl" . $a_type);
415  $this->ctrl->setParameter($this, "dlid", "");
416 
417  $userCertificateRepository = new ilUserCertificateRepository();
418 
419  return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
420  }
421 
422  $class = "ilObj" . $objDefinition->getClassName($a_type) . "GUI";
423  include_once $objDefinition->getLocation($a_type) . "/class." . $class . ".php";
424  $verification = new $class($a_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
425 
426  if ($outputMode == "print") {
427  $url = $this->getPagePermaLink();
428  } elseif ($outputMode != "offline") {
429  // direct download link
430  $this->ctrl->setParameter($this, "dlid", $a_id);
431  $url = $this->ctrl->getLinkTarget($this, "dl" . $a_type);
432  $this->ctrl->setParameter($this, "dlid", "");
433  } else {
434  $file = $verification->object->getFilePath();
435  $url = "files/" . basename($file);
436 
437  $this->export_material["files"][] = $file;
438  }
439 
440  return $verification->render(true, $url);
441  }
442 
443  protected function dltstv()
444  {
445  $id = $_GET["dlid"];
446  if ($id) {
447  include_once "Modules/Test/classes/class.ilObjTestVerificationGUI.php";
449  $verification->downloadFromPortfolioPage($this->getPageObject());
450  }
451  }
452 
453  protected function dlexcv()
454  {
455  $id = $_GET["dlid"];
456  if ($id) {
457  include_once "Modules/Exercise/classes/class.ilObjExerciseVerificationGUI.php";
459  $verification->downloadFromPortfolioPage($this->getPageObject());
460  }
461  }
462 
463  protected function dlcrsv()
464  {
465  $id = $_GET["dlid"];
466  if ($id) {
467  include_once "Modules/Course/classes/Verification/class.ilObjCourseVerificationGUI.php";
469  $verification->downloadFromPortfolioPage($this->getPageObject());
470  }
471  }
472 
473  protected function dlscov()
474  {
475  $id = $_GET["dlid"];
476  if ($id) {
477  include_once "Modules/ScormAicc/classes/Verification/class.ilObjSCORMVerificationGUI.php";
479  $verification->downloadFromPortfolioPage($this->getPageObject());
480  }
481  }
482 
483  protected function dlcrta()
484  {
485  $objectId = $_GET["dlid"];
486  if ($objectId) {
488  $object->downloadFromPortfolioPage($this->getPageObject(), $objectId, $this->user->getId());
489  }
490  }
491 
492  protected function renderBlog($a_user_id, $a_blog_id, array $a_posting_ids = null)
493  {
495 
496  // not used
497  // $user_id = $this->getPageContentUserId($a_user_id);
498 
499  // full blog (separate tab/page)
500  if (!$a_posting_ids) {
501  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
502  if (ilObject::_lookupType($a_blog_id) != "blog") {
503  return;
504  }
505  $blog = new ilObjBlogGUI($a_blog_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
506  $blog->disableNotes(!$this->enable_comments);
507  $blog->setContentStyleSheet();
508 
509  if ($this->getOutputMode() != "offline") {
510  return $ilCtrl->getHTML($blog);
511  } else {
512  }
513  }
514  // embedded postings
515  else {
516  $html = array();
517 
518  include_once "Modules/Blog/classes/class.ilObjBlog.php";
519  $html[] = ilObjBlog::_lookupTitle($a_blog_id);
520 
521  include_once "Modules/Blog/classes/class.ilBlogPostingGUI.php";
522  foreach ($a_posting_ids as $post) {
523  $page = new ilBlogPostingGUI(0, null, $post);
524  if ($this->getOutputMode() != "offline") {
525  $page->setOutputMode(IL_PAGE_PREVIEW);
526  } else {
527  $page->setOutputMode("offline");
528  }
529  $html[] = $page->showPage();
530  }
531 
532  return implode("\n", $html);
533  }
534  }
535 
536  protected function renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids = null)
537  {
538  // not used
539  // $user_id = $this->getPageContentUserId($a_user_id);
540 
541  $postings = "";
542  if ($a_posting_ids) {
543  $postings = array("<ul>");
544  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
545  foreach ($a_posting_ids as $post) {
546  $post = new ilBlogPosting($post);
547  $postings[] = "<li>" . $post->getTitle() . " - " .
548  ilDatePresentation::formatDate($post->getCreated()) . "</li>";
549  }
550  $postings[] = "</ul>";
551  $postings = implode("\n", $postings);
552  }
553 
554  return $this->renderTeaser("blog", $this->lng->txt("obj_blog") . ' "' .
555  ilObject::_lookupTitle($a_blog_id) . '"', $postings);
556  }
557 
558  protected function renderSkills($a_user_id, $a_skills_id)
559  {
560  if ($this->getOutputMode() == "preview") {
561  return $this->renderSkillsTeaser($a_user_id, $a_skills_id);
562  }
563 
564  $user_id = $this->getPageContentUserId($a_user_id);
565 
566  include_once "Services/Skill/classes/class.ilPersonalSkillsGUI.php";
567  $gui = new ilPersonalSkillsGUI();
568  if ($this->getOutputMode() == "offline") {
569  $gui->setOfflineMode("./files/");
570  }
571  $html = $gui->getSkillHTML($a_skills_id, $user_id);
572 
573  return $html;
574  }
575 
576  protected function renderSkillsTeaser($a_user_id, $a_skills_id)
577  {
578  // not used
579  // $user_id = $this->getPageContentUserId($a_user_id);
580 
581  include_once "Services/Skill/classes/class.ilSkillTreeNode.php";
582 
583  return $this->renderTeaser("skills", $this->lng->txt("skills") . ' "' .
584  ilSkillTreeNode::_lookupTitle($a_skills_id) . '"');
585  }
586 
587  protected function renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids)
588  {
589  // not used
590  // $user_id = $this->getPageContentUserId($a_user_id);
591 
592  if ($a_mode == "auto") {
593  $mode = $this->lng->txt("cont_cach_mode_automatic");
594  $groups = null;
595  } else {
596  $mode = $this->lng->txt("cont_cach_mode_manual");
597 
598  include_once "Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php";
599  $groups = array();
600  foreach ($a_group_ids as $grp_id) {
601  $groups[] = ilConsultationHourGroups::lookupTitle($grp_id);
602  }
603  $groups = " (" . implode(", ", $groups) . ")";
604  }
605 
606  $this->lng->loadLanguageModule("dateplaner");
607  return $this->renderTeaser(
608  "consultation_hours",
609  $this->lng->txt("app_consultation_hours"),
610  $mode . $groups
611  );
612  }
613 
614  protected function renderConsultationHours($a_user_id, $a_mode, $a_group_ids)
615  {
617 
618  if ($this->getOutputMode() == "preview") {
619  return $this->renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids);
620  }
621 
622  if ($this->getOutputMode() == "offline") {
623  return;
624  }
625 
626  if ($this->getOutputMode() == "print") {
627  return;
628  }
629 
630  $user_id = $this->getPageContentUserId($a_user_id);
631 
632  // only if not owner
633  if ($ilUser->getId() != $user_id) {
634  $_GET["bkid"] = $user_id;
635  }
636 
637  if ($a_mode != "manual") {
638  $a_group_ids = null;
639  }
640 
641  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
642  ilCalendarCategories::_getInstance()->setCHUserId($user_id);
644 
645  if (!$_REQUEST["seed"]) {
646  $seed = new ilDate(time(), IL_CAL_UNIX);
647  } else {
648  $seed = new ilDate($_REQUEST["seed"], IL_CAL_DATE);
649  }
650 
651  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
652  $month_gui = new ilCalendarMonthGUI($seed);
653  $month_gui->setConsulationHoursUserId($user_id);
654 
655  // custom schedule filter: handle booking group ids
656  include_once('./Services/Calendar/classes/class.ilCalendarScheduleFilterBookings.php');
657  $filter = new ilCalendarScheduleFilterBookings($user_id, $a_group_ids);
658  $month_gui->addScheduleFilter($filter);
659 
660  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem', 'delos.css', 'Services/Calendar'));
661 
662  $this->lng->loadLanguageModule("dateplaner");
663  return '<h3>' . $this->lng->txt("app_consultation_hours") . '</h3>' .
664  $this->ctrl->getHTML($month_gui);
665  }
666 
667  protected function isMyCoursesActive()
668  {
669  $prfa_set = new ilSetting("prfa");
670  return (bool) $prfa_set->get("mycrs", true);
671  }
672 
673  protected function renderMyCoursesTeaser($a_user_id, $a_default_sorting)
674  {
675  // not used
676  // $user_id = $this->getPageContentUserId($a_user_id);
677 
678  $title = $this->isMyCoursesActive()
679  ? "my_courses"
680  : "my_courses_inactive";
681 
682  return $this->renderTeaser(
683  $title,
684  $this->lng->txt("prtf_page_element_my_courses_title")
685  );
686  }
687 
688  protected function renderMyCourses($a_user_id, $a_default_sorting)
689  {
690  $ilAccess = $this->access;
693 
694  if ($this->getOutputMode() == "preview") {
695  return $this->renderMyCoursesTeaser($a_user_id, $a_default_sorting);
696  }
697 
698  if (!$this->isMyCoursesActive()) {
699  return;
700  }
701 
702  $img_path = null;
703  if ($this->getOutputMode() == "offline") {
704  $this->export_material["images"][] = "./templates/default/images/icon_crs.svg";
705  $this->export_material["images"][] = "./templates/default/images/icon_lobj.svg";
706  $this->export_material["images"][] = "./templates/default/images/scorm/complete.svg";
707  $this->export_material["images"][] = "./templates/default/images/scorm/not_attempted.svg";
708  $this->export_material["images"][] = "./templates/default/images/scorm/failed.svg";
709  $this->export_material["images"][] = "./templates/default/images/scorm/incomplete.svg";
710 
711  $img_path = "images/";
712  }
713 
714  $user_id = $this->getPageContentUserId($a_user_id);
715 
716  // sorting pref
717  if ($_POST["srt"] &&
718  in_array($_POST["srt"], array("alpha", "loc"))) {
719  $ilUser->writePref("prtf_mcrs_sort", $_POST["srt"]);
720  }
721  $sorting = $ilUser->getPref("prtf_mcrs_sort");
722  if (!$sorting) {
723  $sorting = $a_default_sorting;
724  }
725 
726  $data = $this->getCoursesOfUser($user_id, ($sorting == "loc"));
727  if (sizeof($data)) {
728  if ($sorting != "loc") {
729  $data = ilUtil::sortArray($data, "title", "ASC");
730  } else {
731  $data = ilUtil::sortArray($data, "path_sort", "ASC");
732  }
733 
734  $tpl = new ilTemplate("tpl.pc_my_courses.html", true, true, "Modules/Portfolio");
735  $tpl->setVariable("TITLE", $this->lng->txt("prtf_page_element_my_courses_title"));
736  $tpl->setVariable("INFO", $this->lng->txt("prtf_page_element_my_courses_info")); // #14464
737 
738  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
739  $this->lng->loadLanguageModule("trac");
740  $this->lng->loadLanguageModule("crs");
741 
742  include_once("./Services/Container/classes/class.ilContainerObjectiveGUI.php");
743  include_once("./Services/Link/classes/class.ilLink.php");
744 
745  // sorting
746  if ($this->getOutputMode() != "print") {
747  $options = array(
748  "alpha" => $this->lng->txt("cont_mycourses_sortorder_alphabetical"),
749  "loc" => $this->lng->txt("cont_mycourses_sortorder_location")
750  );
751  $tpl->setVariable("SORT_SELECT", ilUtil::formSelect(
752  $sorting,
753  "srt",
754  $options,
755  false,
756  true,
757  0,
758  "",
759  array("onchange" => "form.submit()")
760  ));
761  $tpl->setVariable("SORT_FORM", $this->getCourseSortAction($ilCtrl));
762  }
763 
764  $old_path = null;
765 
766  foreach ($data as $course) {
767  if ($sorting == "loc") {
768  if ($course["path"] != $old_path) {
769  $tpl->setCurrentBlock("path_bl");
770  $tpl->setVariable("PATH", $course["path"]);
771  $tpl->parseCurrentBlock();
772 
773  $old_path = $course["path"];
774  }
775  }
776 
777  if (isset($course["lp_status"])) {
778  $lp_icon = ilLearningProgressBaseGUI::_getImagePathForStatus($course["lp_status"]);
779  $lp_alt = ilLearningProgressBaseGUI::_getStatusText($course["lp_status"]);
780 
781  if ($img_path) {
782  $lp_icon = $img_path . basename($lp_icon);
783  }
784 
785  $tpl->setCurrentBlock("lp_bl");
786  $tpl->setVariable("LP_ICON_URL", $lp_icon);
787  $tpl->setVariable("LP_ICON_ALT", $lp_alt);
788  $tpl->parseCurrentBlock();
789  }
790 
791  $do_links = false;
792  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
793  $do_links = $ilAccess->checkAccessOfUser($ilUser->getId(), "read", "", $course["ref_id"], "crs") ||
794  ($ilAccess->checkAccessOfUser($ilUser->getId(), "visible", "", $course["ref_id"], "crs") &&
795  $ilAccess->checkAccessOfUser($ilUser->getId(), "join", "", $course["ref_id"], "crs"));
796  }
797 
798  if (isset($course["objectives"])) {
799  include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
800  $loc_settings = ilLOSettings::getInstanceByObjId($course["obj_id"]);
801  $has_initial_test = (bool) $loc_settings->getInitialTest();
802 
803  foreach ($course["objectives"] as $objtv) {
804  if ($do_links) {
805  $params = array("oobj" => $objtv["id"]);
806  $url = ilLink::_getLink($course["ref_id"], "crs", $params);
807 
808  // #15510
809  $url .= "#objtv_acc_" . $objtv["id"];
810 
811  if ($this->getOutputMode() != "print") {
812  $tpl->touchBlock("objective_dnone");
813  }
814 
815  $tpl->setCurrentBlock("objective_link_bl");
816 
817  if (trim($objtv["desc"])) {
818  $desc = nl2br($objtv["desc"]);
819  $tt_id = "objtvtt_" . $objtv["id"] . "_" . ((int) self::$initialized);
820 
821  include_once "Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
822  ilToolTipGUI::addTooltip($tt_id, $desc, "", "bottom center", "top center", false);
823 
824  $tpl->setVariable("OBJECTIVE_LINK_ID", $tt_id);
825  }
826 
827  $tpl->setVariable("OBJECTIVE_LINK_URL", $url);
828  $tpl->setVariable("OBJECTIVE_LINK_TITLE", $objtv["title"]);
829  $tpl->parseCurrentBlock();
830  } else {
831  $tpl->setCurrentBlock("objective_nolink_bl");
832  $tpl->setVariable("OBJECTIVE_NOLINK_TITLE", $objtv["title"]);
833  $tpl->parseCurrentBlock();
834  }
835 
836  $objtv_icon = ilUtil::getTypeIconPath("lobj", $objtv["id"]);
837  if ($img_path) {
838  $objtv_icon = $img_path . basename($objtv_icon);
839  }
840 
841  $tpl->setCurrentBlock("objective_bl");
842  $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
843  $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
844 
845  if ($objtv["type"]) {
846  $tpl->setVariable(
847  "LP_OBJTV_PROGRESS",
848  ilContainerObjectiveGUI::buildObjectiveProgressBar($has_initial_test, $objtv["id"], $objtv, true, false, (int) self::$initialized)
849  );
850  }
851 
852  $tpl->parseCurrentBlock();
853  }
854 
855  $tpl->setCurrentBlock("objectives_bl");
856  $tpl->setVariable("OBJTV_LIST_CRS_ID", $course["obj_id"]);
857  $tpl->parseCurrentBlock();
858  }
859 
860  // always check against current user
861  if ($do_links) {
862  $tpl->setCurrentBlock("course_link_bl");
863  $tpl->setVariable("COURSE_LINK_TITLE", $course["title"]);
864  $tpl->setVariable("COURSE_LINK_URL", ilLink::_getLink($course["ref_id"]));
865  $tpl->parseCurrentBlock();
866  } else {
867  $tpl->setCurrentBlock("course_nolink_bl");
868  $tpl->setVariable("COURSE_NOLINK_TITLE", $course["title"]);
869  $tpl->parseCurrentBlock();
870  }
871 
872  $crs_icon = ilUtil::getTypeIconPath("crs", $course["obj_id"]);
873  if ($img_path) {
874  $crs_icon = $img_path . basename($crs_icon);
875  }
876 
877  $tpl->setCurrentBlock("course_bl");
878 
879  if (isset($course["objectives"])) {
880  $tpl->setVariable("TOGGLE_CLASS", "ilPCMyCoursesToggle");
881  } else {
882  $tpl->setVariable("NO_TOGGLE", ' style="visibility:hidden;"');
883  }
884 
885  $tpl->setVariable("CRS_ICON_URL", $crs_icon);
886  $tpl->setVariable("CRS_ICON_ALT", $this->lng->txt("obj_crs"));
887  $tpl->parseCurrentBlock();
888  }
889 
890  // #15508
891  if (!self::$initialized) {
892  $GLOBALS["tpl"]->addJavaScript("Modules/Portfolio/js/ilPortfolio.js");
893  $GLOBALS["tpl"]->addOnLoadCode("ilPortfolio.init()");
894  }
895  self::$initialized++;
896 
897  return $tpl->get();
898  }
899  }
900 
907  protected function getCourseSortAction($ctrl)
908  {
909  return $ctrl->getFormActionByClass("ilobjportfoliogui", "preview");
910  }
911 
912 
913  protected function getCoursesOfUser($a_user_id, $a_add_path = false)
914  {
915  $tree = $this->tree;
916 
917  // see ilPDSelectedItemsBlockGUI
918 
919  include_once 'Modules/Course/classes/class.ilObjCourseAccess.php';
920  include_once 'Services/Membership/classes/class.ilParticipants.php';
921  $items = ilParticipants::_getMembershipByType($a_user_id, 'crs');
922 
923  $repo_title = $tree->getNodeData(ROOT_FOLDER_ID);
924  $repo_title = $repo_title["title"];
925  if ($repo_title == "ILIAS") {
926  $repo_title = $this->lng->txt("repository");
927  }
928 
929  $references = $lp_obj_refs = array();
930  foreach ($items as $obj_id) {
931  $ref_id = ilObject::_getAllReferences($obj_id);
932  if (is_array($ref_id) && count($ref_id)) {
933  $ref_id = array_pop($ref_id);
934  if (!$tree->isDeleted($ref_id)) {
935  $visible = false;
936  $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false);
937  if ($active && $visible) {
938  $references[$ref_id] = array(
939  'ref_id' => $ref_id,
940  'obj_id' => $obj_id,
941  'title' => ilObject::_lookupTitle($obj_id)
942  );
943 
944  if ($a_add_path) {
945  $path = array();
946  foreach ($tree->getPathFull($ref_id) as $item) {
947  $path[] = $item["title"];
948  }
949  // top level comes first
950  if (sizeof($path) == 2) {
951  $path[0] = 0;
952  } else {
953  $path[0] = 1;
954  }
955  $references[$ref_id]["path_sort"] = implode("__", $path);
956  array_shift($path);
957  array_pop($path);
958  if (!sizeof($path)) {
959  array_unshift($path, $repo_title);
960  }
961  $references[$ref_id]["path"] = implode(" &rsaquo; ", $path);
962  }
963 
964  $lp_obj_refs[$obj_id] = $ref_id;
965  }
966  }
967  }
968  }
969 
970  // get lp data for valid courses
971 
972  if (sizeof($lp_obj_refs)) {
973  // listing the objectives should NOT depend on any LP status / setting
974  include_once 'Modules/Course/classes/class.ilObjCourse.php';
975  foreach ($lp_obj_refs as $obj_id => $ref_id) {
976  // only if set in DB (default mode is not relevant
978  $references[$ref_id]["objectives"] = $this->parseObjectives($obj_id, $a_user_id);
979  }
980  }
981 
982  // LP must be active, personal and not anonymized
983  include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
987  // see ilLPProgressTableGUI
988  include_once "Services/Tracking/classes/class.ilTrQuery.php";
989  include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
990  $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs);
991  foreach ($lp_data as $item) {
992  $ref_id = $item["ref_ids"];
993  $references[$ref_id]["lp_status"] = $item["status"];
994  }
995  }
996  }
997 
998  return $references;
999  }
1000 
1001  protected function parseObjectives($a_obj_id, $a_user_id)
1002  {
1003  $res = array();
1004 
1005  // we need the collection for the correct order
1006  include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
1007  include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfObjectives.php";
1009  $coll_objtv = $coll_objtv->getItems();
1010  if ($coll_objtv) {
1011  // #13373
1012  $lo_results = $this->parseLOUserResults($a_obj_id, $a_user_id);
1013 
1014  include_once "Modules/Course/classes/Objectives/class.ilLOTestAssignments.php";
1015  $lo_ass = ilLOTestAssignments::getInstance($a_obj_id);
1016 
1017  $tmp = array();
1018 
1019  include_once "Modules/Course/classes/class.ilCourseObjective.php";
1020  foreach ($coll_objtv as $objective_id) {
1021  $title = ilCourseObjective::lookupObjectiveTitle($objective_id, true);
1022 
1023  $tmp[$objective_id] = array(
1024  "id" => $objective_id,
1025  "title" => $title["title"],
1026  "desc" => $title["description"],
1027  "itest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL),
1028  "qtest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED)
1029  );
1030 
1031  if (array_key_exists($objective_id, $lo_results)) {
1032  $lo_result = $lo_results[$objective_id];
1033  $tmp[$objective_id]["user_id"] = $lo_result["user_id"];
1034  $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"];
1035  $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"];
1036  $tmp[$objective_id]["status"] = $lo_result["status"];
1037  $tmp[$objective_id]["type"] = $lo_result["type"];
1038  $tmp[$objective_id]["initial"] = $lo_result["initial"];
1039  }
1040  }
1041 
1042  // order
1043  foreach ($coll_objtv as $objtv_id) {
1044  $res[] = $tmp[$objtv_id];
1045  }
1046  }
1047 
1048  return $res;
1049  }
1050 
1051  // see ilContainerObjectiveGUI::parseLOUserResults()
1052  protected function parseLOUserResults($a_course_obj_id, $a_user_id)
1053  {
1054  $res = array();
1055 
1056  include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
1057  $lur = new ilLOUserResults($a_course_obj_id, $a_user_id);
1058  foreach ($lur->getCourseResultsForUserPresentation() as $objective_id => $types) {
1059  // show either initial or qualified for objective
1060  if (isset($types[ilLOUserResults::TYPE_INITIAL])) {
1061  $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"];
1062  }
1063 
1064  // qualified test has priority
1065  if (isset($types[ilLOUserResults::TYPE_QUALIFIED])) {
1068  $result["initial"] = $types[ilLOUserResults::TYPE_INITIAL];
1069  } else {
1072  }
1073 
1074  $result["initial_status"] = $initial_status;
1075 
1076  $res[$objective_id] = $result;
1077  }
1078 
1079  return $res;
1080  }
1081 
1082  public function getExportMaterial()
1083  {
1084  return $this->export_material;
1085  }
1086 
1093  public function makePlaceHoldersClickable($a_html)
1094  {
1095  $ilCtrl = $this->ctrl;
1096  $lng = $this->lng;
1097  $ilUser = $this->user;
1098 
1099  $c_pos = 0;
1100  $start = strpos($a_html, "{{{{{PlaceHolder#");
1101  if (is_int($start)) {
1102  $end = strpos($a_html, "}}}}}", $start);
1103  }
1104  $i = 1;
1105  while ($end > 0) {
1106  $param = substr($a_html, $start + 17, $end - $start - 17);
1107  $param = explode("#", $param);
1108 
1109  $html = $param[2];
1110  switch ($param[2]) {
1111  case "Text":
1112  $html = $lng->txt("cont_text_placeh");
1113  break;
1114 
1115  case "Media":
1116  $html = $lng->txt("cont_media_placeh");
1117  break;
1118 
1119  case "Question":
1120  $html = $lng->txt("cont_question_placeh");
1121  break;
1122 
1123  case "Verification":
1124  $html = $lng->txt("cont_verification_placeh");
1125  break;
1126  }
1127 
1128  // only if not owner
1129  if ($ilUser->getId() == ilObjPortfolio::_lookupOwner($this->portfolio_id)
1130  && $this->getOutputMode() == "presentation") {
1131  switch ($param[2]) {
1132  case "Text":
1133  $ilCtrl->setParameterByClass("ilportfoliopagegui", "prt_id", $_GET["prt_id"]);
1134  $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $this->getId());
1135  $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_pc_id", $param[0]);
1136  $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_hier_id", $param[1]);
1137  $href = $ilCtrl->getLinkTargetByClass("ilportfoliopagegui", "insertJSAtPlaceholder");
1138  $html = "<a href='" . $href . "'>" . $html . "</a>";
1139  break;
1140 
1141  case "Media":
1142  $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "prt_id", $_GET["prt_id"]);
1143  $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "ppage", $this->getId());
1144  $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_pc_id", $param[0]);
1145  $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_hier_id", $param[1]);
1146  $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "insertNew");
1147  $href = $ilCtrl->getLinkTargetByClass(array("ilPortfolioPageGUI", "ilPageEditorGUI", "ilPCPlaceHolderGUI", "ilpcmediaobjectgui"), "insert");
1148  $html = "<a href='" . $href . "'>" . $html . "</a>";
1149  break;
1150  }
1151  }
1152 
1153  $h2 = substr($a_html, 0, $start) .
1154  $html .
1155  substr($a_html, $end + 5);
1156  $a_html = $h2;
1157  $i++;
1158 
1159  $start = strpos($a_html, "{{{{{PlaceHolder#", $start + 5);
1160  $end = 0;
1161  if (is_int($start)) {
1162  $end = strpos($a_html, "}}}}}", $start);
1163  }
1164  }
1165  return $a_html;
1166  }
1167 
1174  public function getViewPageLink()
1175  {
1176  global $DIC;
1177 
1178  $ctrl = $DIC->ctrl();
1179 
1180  $ctrl->setParameterByClass("ilobjportfoliogui", "user_page", $this->requested_ppage);
1181  return $ctrl->getLinkTargetByClass("ilobjportfoliogui", "preview");
1182  }
1183 
1190  public function getViewPageText()
1191  {
1192  return $this->lng->txt("preview");
1193  }
1194 
1201  public function getPagePermaLink()
1202  {
1203  include_once("./Services/Link/classes/class.ilLink.php");
1205  $href = ilLink::_getStaticLink($pid, "prtf", true, "_" . $this->getId());
1206  return $href;
1207  }
1208 
1215  private function createPersistentCertificateUrl($a_id, $userCertificateRepository, $url) : string
1216  {
1217  $presentation = $userCertificateRepository->fetchActiveCertificateForPresentation($this->user->getId(), $a_id);
1218  $caption = $this->lng->txt('certificate') . ': ';
1219  $caption .= $this->lng->txt($presentation->getUserCertificate()->getObjType()) . ' ';
1220  $caption .= '"' . $presentation->getObjectTitle() . '"';
1221 
1222  return '<div><a href="' . $url . '">' . $caption . '</a></div>';
1223  }
1224 }
getCoursesOfUser($a_user_id, $a_add_path=false)
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getInstanceByObjId($a_obj_id)
get singleton instance
$path
Definition: aliased.php:25
static getInstance($a_container_id)
Get instance by container id.
renderBlog($a_user_id, $a_blog_id, array $a_posting_ids=null)
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
const IL_PAGE_PREVIEW
const IL_CRS_VIEW_OBJECTIVE
static getPlaceHolderStylePath()
get placeholder style path (for Page Layouts)
__construct($a_portfolio_id, $a_id=0, $a_old_nr=0, $a_enable_comments=true)
Constructor.
getPageObject()
Get Page Object.
Class ilBlogPosting.
Calendar schedule filter for consultation hour bookings.
static _lookupTitle($a_id)
$result
setTemplateOutput($a_output=true)
static _getImagePathForStatus($a_status)
Get image path for status.
executeCommand()
execute command
$type
static lookupTitle($a_group_id)
Lookup group title.
global $DIC
Definition: saml.php:7
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
renderMyCourses($a_user_id, $a_default_sorting)
getAdditional()
Get Additonal Information.
Class ilBlogPosting GUI class.
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
Class ilPageObjectGUI.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
static findPortfolioForPage($a_page_id)
Get portfolio id of page id.
setEmbedded($a_value)
Set embedded mode: will suppress tabs.
if(!array_key_exists('StateId', $_REQUEST)) $id
static _lookupTitle($a_id)
lookup object title
Portfolio page gui class.
static _lookupViewMode($a_id)
lookup view mode of container
static getObjectsStatusForUser($a_user_id, array $obj_refs)
const IL_CAL_UNIX
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
user()
Definition: user.php:4
static _lookupOwner($a_id)
static _getAllReferences($a_id)
get all reference ids of object
Tree handler for personal workspace.
createPersistentCertificateUrl($a_id, $userCertificateRepository, $url)
global $ilCtrl
Definition: ilias.php:18
$start
Definition: bench.php:8
getViewPageLink()
Get view page link.
$a_type
Definition: workflow.php:92
Personal skills GUI class.
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
GUI class for course verification.
GUI class for public user profile presentation.
static _enabledLearningProgress()
check wether learing progress is enabled or not
Class for single dates.
foreach($_POST as $key=> $value) $res
Class ilObjBlogGUI.
getTabs($a_activate="")
Set all tabs.
GUI class for exercise verification.
renderSkills($a_user_id, $a_skills_id)
renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids=null)
makePlaceHoldersClickable($a_html)
Modify page content after xsl.
special template class to simplify handling of ITX/PEAR
renderSkillsTeaser($a_user_id, $a_skills_id)
getViewPageText()
Get view page link.
$post
Definition: post.php:34
setPresentationTitle($a_title="")
$ilUser
Definition: imgupload.php:18
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true)
get content style path
static _getInstance($a_usr_id=0)
get singleton instance
static _lookupType($a_id, $a_reference=false)
lookup object type
static buildObjectiveProgressBar($a_has_initial_test, $a_objective_id, array $a_lo_result, $a_list_mode=false, $a_sub=false, $a_tt_suffix=null)
Render progressbar(s) for given objective and result data.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
const IL_CAL_DATE
GUI class for test verification.
renderMyCoursesTeaser($a_user_id, $a_default_sorting)
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
setAdditional($a_additional)
Set Additonal Information.
renderTeaser($a_type, $a_title, $a_options=null)
renderVerification($a_user_id, $a_type, $a_id)
$i
Definition: disco.tpl.php:19
$def
Definition: croninfo.php:21
parseObjectives($a_obj_id, $a_user_id)
$url
renderPageElement($a_type, $a_html)
getCourseSortAction($ctrl)
Get course sort action.
static _isActivated($a_obj_id, &$a_visible_flag=null, $a_mind_member_view=true)
Is activated?
renderProfile($a_user_id, $a_type, array $a_fields=null)
GUI class for scorm verification.
$_POST["username"]
$html
Definition: example_001.php:87
parseLOUserResults($a_course_obj_id, $a_user_id)
getPagePermaLink()
Get page perma link.
renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids)
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
$data
Definition: bench.php:6
renderConsultationHours($a_user_id, $a_mode, $a_group_ids)