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