ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilPortfolioPageGUI.php
Go to the documentation of this file.
1<?php
2
20
29{
30 public const EMBEDDED_NO_OUTPUT = -99;
31 protected bool $enable_comments;
32 protected int $portfolio_id;
33 protected \ILIAS\Portfolio\StandardGUIRequest $port_request;
34
35 protected bool $embedded = false;
37 protected ilTree $tree;
38 protected array $js_onload_code = array();
39 protected array $additional = array();
40 protected array $export_material = array("js" => array(), "images" => array(), "files" => array());
41 protected static int $initialized = 0;
42 protected static bool $calender_initialized = false;
43 protected int $requested_ppage;
44 protected \ILIAS\UI\Factory $ui_fac;
45 protected \ILIAS\UI\Renderer $ui_ren;
46
47 public function __construct(
48 int $a_portfolio_id,
49 int $a_id = 0,
50 int $a_old_nr = 0,
51 bool $a_enable_comments = true
52 ) {
53 global $DIC;
54
55 $this->tpl = $DIC["tpl"];
56 $this->ctrl = $DIC->ctrl();
57 $this->user = $DIC->user();
58 $this->obj_definition = $DIC["objDefinition"];
59 $this->access = $DIC->access();
60 $this->tree = $DIC->repositoryTree();
61 $this->lng = $DIC->language();
62 $tpl = $DIC["tpl"];
63 $this->port_request = $DIC->portfolio()
64 ->internal()
65 ->gui()
66 ->standardRequest();
67 $this->ui_fac = $DIC->ui()->factory();
68 $this->ui_ren = $DIC->ui()->renderer();
69
70 $this->portfolio_id = $a_portfolio_id;
71 $this->enable_comments = $a_enable_comments;
72
73 parent::__construct($this->getParentType(), $a_id, $a_old_nr);
74 $this->getPageObject()->setPortfolioId($this->portfolio_id);
75
76 // content style
77
78 $tpl->setCurrentBlock("SyntaxStyle");
80 "LOCATION_SYNTAX_STYLESHEET",
82 );
84 $this->requested_ppage = $this->port_request->getPortfolioPageId();
85 }
86
87 public function getParentType(): string
88 {
89 return "prtf";
90 }
91
92 protected function getPageContentUserId(int $a_user_id): int
93 {
94 // user id from content-xml
95 return $a_user_id;
96 }
97
98 protected function getPortfolioPage(): ilPortfolioPage
99 {
101 $page = $this->getPageObject();
102 return $page;
103 }
104
105 public function executeCommand(): string
106 {
107 $ilCtrl = $this->ctrl;
108 $ilUser = $this->user;
109
110 $next_class = $this->ctrl->getNextClass($this);
111 $cmd = $this->ctrl->getCmd();
112
113 switch ($next_class) {
114 case "ilcalendarmonthgui":
115 $this->ctrl->saveParameter($this, "chuid");
116 // booking action
117 if ($cmd && $cmd !== "preview") {
119 if ($categories->getMode() === 0) {
120 $chuid = $this->port_request->getConsultationHourUserId();
121 if ($chuid > 0) {
122 $categories->setCHUserId($chuid);
123 }
124 $categories->initialize(ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION, 0, true);
125 }
126
127 $req_seed = $this->port_request->getCalendarSeed();
128 if ($req_seed !== "") {
129 $seed = new ilDate($req_seed, IL_CAL_DATE);
130 } else {
131 $seed = new ilDate(time(), IL_CAL_UNIX);
132 }
133
134 $month_gui = new ilCalendarMonthGUI($seed);
135 return (string) $ilCtrl->forwardCommand($month_gui);
136 }
137
138 // calendar month navigation
139 //$ilCtrl->setParameter($this, "cmd", "preview");
140 return (string) self::EMBEDDED_NO_OUTPUT;
141 default:
142 $this->setPresentationTitle($this->getPageObject()->getTitle());
143 return (string) parent::executeCommand();
144 }
145 }
146
147 public function showPage(): string
148 {
149 $ilUser = $this->user;
150
151 if (!$this->getPageObject()) {
152 return "";
153 }
154
155 $this->setTemplateOutput(false);
156 // $this->setPresentationTitle($this->getPageObject()->getTitle());
157 return parent::showPage();
158 }
159
160 public function getTabs(string $a_activate = ""): void
161 {
162 if (!$this->embedded) {
163 parent::getTabs($a_activate);
164 }
165 }
166
170 public function setEmbedded(bool $a_value): void
171 {
172 $this->embedded = $a_value;
173 }
174
178 public function setAdditional(array $a_additional): void
179 {
180 $this->additional = $a_additional;
181 }
182
186 public function getAdditional(): array
187 {
188 return $this->additional;
189 }
190
191 public function getJsOnloadCode(): array
192 {
194 }
195
196 public function postOutputProcessing(string $a_output): string
197 {
198 $parts = array(
199 "Profile" => array("0-9", "a-z", "0-9a-z_;\W"), // user, mode, fields
200 "Verification" => array("0-9", "a-z", "0-9"), // user, type, id
201 "Blog" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
202 "BlogTeaser" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
203 "Skills" => array("0-9", "0-9"), // user, skill id
204 "SkillsTeaser" => array("0-9", "0-9"), // user, skill id
205 "ConsultationHours" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
206 "ConsultationHoursTeaser" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
207 "MyCourses" => array("0-9", "a-z*"), // user, sort
208 "MyCoursesTeaser" => array("0-9", "a-z*") // user, sort
209 );
210
211 foreach ($parts as $type => $def) {
212 // #15732 - allow optional parts
213 $def_parts = array();
214 foreach ($def as $part) {
215 $is_opt = (substr($part, -1) === "*");
216 if (!$is_opt) {
217 $def_parts[] = "#";
218 $end_marker = "+";
219 } else {
220 $def_parts[] = "#*";
221 $end_marker = "*";
222 $part = substr($part, 0, -1);
223 }
224 $def_parts[] = "([" . $part . "]" . $end_marker . ")";
225 }
226 $def = implode("", $def_parts);
227
228 if (preg_match_all(
229 "/" . $this->pl_start . $type . $def . $this->pl_end . "/",
230 $a_output,
231 $blocks
232 )) {
233 foreach ($blocks[0] as $idx => $block) {
234 switch ($type) {
235 case "Profile":
236 case "Blog":
237 case "BlogTeaser":
238 case "Skills":
239 case "SkillsTeaser":
240 case "ConsultationHours":
241 case "ConsultationHoursTeaser":
242 case "MyCourses":
243 case "MyCoursesTeaser":
244 $subs = null;
245 if (trim(($blocks[3][$idx] ?? ""))) {
246 foreach (explode(";", $blocks[3][$idx]) as $sub) {
247 if (trim($sub)) {
248 $subs[] = trim($sub);
249 }
250 }
251 }
252 $snippet = $this->{"render" . $type}(
253 $blocks[1][$idx],
254 $blocks[2][$idx],
255 $subs
256 );
257 break;
258
259 default:
260 $snippet = $this->{"render" . $type}(
261 $blocks[1][$idx],
262 $blocks[2][$idx],
263 $blocks[3][$idx]
264 );
265 break;
266 }
267
268 $snippet = $this->renderPageElement($type, $snippet);
269 $a_output = str_replace($block, $snippet, $a_output);
270 }
271 }
272 }
273
274 $a_output = $this->makePlaceHoldersClickable($a_output);
275
276 return $a_output;
277 }
278
279 protected function renderPageElement(
280 string $a_type,
281 string $a_html
282 ): string {
283 return trim($a_html);
284 }
285
286 protected function renderTeaser(
287 string $a_type,
288 string $a_title,
289 string $a_options = ""
290 ): string {
291 $options = "";
292 if ($a_options) {
293 $options = '<div class="il_Footer">' . $this->lng->txt("prtf_page_element_teaser_settings") .
294 ": " . $a_options . '</div>';
295 }
296
297 return '<div style="margin:5px" class="ilBox"><h3>' . $a_title . '</h3>' .
298 '<div class="il_Description_no_margin">' . $this->lng->txt("prtf_page_element_teaser_" . $a_type) . '</div>' .
299 $options . '</div>';
300 }
301
302 protected function renderProfile(
303 int $a_user_id,
304 string $a_type,
305 ?array $a_fields = null
306 ): string {
307 $ilCtrl = $this->ctrl;
308
309 $user_id = $this->getPageContentUserId($a_user_id);
310
311 $pub_profile = new PublicProfileGUI($user_id);
312 $pub_profile->setEmbedded(true, ($this->getOutputMode() === "offline"));
313
314 // full circle: additional was set in the original public user profile call
315 $pub_profile->setAdditional($this->getAdditional());
316
317 if ($a_type === "manual" && is_array($a_fields) && count($a_fields) > 0) {
318 $prefs = array();
319 foreach ($a_fields as $field) {
320 $field = trim($field);
321 if ($field) {
322 $prefs["public_" . $field] = "y";
323 }
324 }
325
326 $pub_profile->setCustomPrefs($prefs);
327 }
328
329 if ($this->getOutputMode() !== "offline") {
330 return $ilCtrl->getHTML($pub_profile);
331 }
332
333 return $pub_profile->getEmbeddable();
334 }
335
339 protected function renderVerification(
340 int $a_user_id,
341 string $a_type,
342 int $a_id
343 ): string {
344 $objDefinition = $this->obj_definition;
345
346 $outputMode = $this->getOutputMode();
347
348 // not used
349 // $user_id = $this->getPageContentUserId($a_user_id);
350 if ($a_type === 'crta' && $outputMode === 'offline') {
351 $fileService = new ilPortfolioCertificateFileService();
352
353 $certificatePdfFile = $fileService->createCertificateFilePath($a_user_id, $a_id);
354 $this->export_material["files"][] = $certificatePdfFile;
355
356 $url = 'files/' . basename($certificatePdfFile);
357
358 $userCertificateRepository = new ilUserCertificateRepository();
359
360 return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
361 }
362
363 if ($a_type === 'crta' && $outputMode === 'print') {
364 $userCertificateRepository = new ilUserCertificateRepository();
365 $url = $this->getPagePermaLink();
366
367 return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
368 }
369
370 if ($a_type === 'crta') {
371 $this->ctrl->setParameter($this, "dlid", $a_id);
372 $url = $this->ctrl->getLinkTarget($this, "dl" . $a_type);
373 $this->ctrl->setParameter($this, "dlid", "");
374
375 $userCertificateRepository = new ilUserCertificateRepository();
376
377 return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
378 }
379
380 if (!ilObject::_exists($a_id)) {
381 return $this->lng->txt('deleted');
382 }
383
384 $class = "ilObj" . $objDefinition->getClassName($a_type) . "GUI";
385 $verification = new $class($a_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
386
387 if ($outputMode === "print") {
388 $url = $this->getPagePermaLink();
389 } elseif ($outputMode !== "offline") {
390 // direct download link
391 $this->ctrl->setParameter($this, "dlid", $a_id);
392 $url = $this->ctrl->getLinkTarget($this, "dl" . $a_type);
393 $this->ctrl->setParameter($this, "dlid", "");
394 } else {
395 $file = $verification->getObject()->getFilePath();
396 $url = "files/" . basename($file);
397
398 $this->export_material["files"][] = $file;
399 }
400
401 return $verification->render(true, $url);
402 }
403
404 protected function dltstv(): void
405 {
406 $id = $this->port_request->getVerificationId();
407 if ($id) {
409 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
410 }
411 }
412
413 protected function dlexcv(): void
414 {
415 $id = $this->port_request->getVerificationId();
416 if ($id) {
418 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
419 }
420 }
421
422 protected function dlcrsv(): void
423 {
424 $id = $this->port_request->getVerificationId();
425 if ($id) {
427 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
428 }
429 }
430
431 protected function dlcmxv(): void
432 {
433 $id = $this->port_request->getVerificationId();
434 if ($id) {
436 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
437 }
438 }
439
440 protected function dlltiv(): void
441 {
442 $id = $this->port_request->getVerificationId();
443 if ($id) {
445 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
446 }
447 }
448
449 protected function dlscov(): void
450 {
451 $id = $this->port_request->getVerificationId();
452 if ($id) {
454 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
455 }
456 }
457
458 protected function dlcrta(): void
459 {
460 $objectId = $this->port_request->getVerificationId();
461 if ($objectId) {
463 $object->downloadFromPortfolioPage($this->getPortfolioPage(), $objectId, $this->user->getId());
464 }
465 }
466
467 protected function renderBlogTeaser(
468 int $a_user_id,
469 int $a_blog_id,
470 ?array $a_posting_ids = null
471 ): string {
472 // not used
473 // $user_id = $this->getPageContentUserId($a_user_id);
474
475 $postings = "";
476 if ($a_posting_ids) {
477 $postings = array("<ul>");
478 foreach ($a_posting_ids as $post) {
480 $postings[] = "<li>" . $post->getTitle() . " - " .
481 ilDatePresentation::formatDate($post->getCreated()) . "</li>";
482 }
483 $postings[] = "</ul>";
484 $postings = implode("\n", $postings);
485 }
486
487 return $this->renderTeaser("blog", $this->lng->txt("obj_blog") . ' "' .
488 ilObject::_lookupTitle($a_blog_id) . '"', $postings);
489 }
490
491 protected function renderSkills(
492 int $a_user_id,
493 int $a_skills_id
494 ): string {
495 if ($this->getOutputMode() === "preview") {
496 return $this->renderSkillsTeaser($a_user_id, $a_skills_id);
497 }
498
499 $user_id = $this->getPageContentUserId($a_user_id);
500
501 $gui = new ilPersonalSkillsGUI();
502 if ($this->getOutputMode() === "offline") {
503 $gui->setOfflineMode("./files/");
504 }
505 return $gui->getSkillHTML($a_skills_id, $user_id);
506 }
507
508 protected function renderSkillsTeaser(
509 int $a_user_id,
510 int $a_skills_id
511 ): string {
512 // not used
513 // $user_id = $this->getPageContentUserId($a_user_id);
514
515 return $this->renderTeaser("skills", $this->lng->txt("skills") . ' "' .
516 ilSkillTreeNode::_lookupTitle($a_skills_id) . '"');
517 }
518
520 int $a_user_id,
521 string $a_mode,
522 ?array $a_group_ids = null
523 ): string {
524 // not used
525 // $user_id = $this->getPageContentUserId($a_user_id);
526 if ($a_mode === "auto") {
527 $mode = $this->lng->txt("cont_cach_mode_automatic");
528 $groups = null;
529 }
530 // begin-abandon ch_groups
531 /*
532 else {
533 $mode = $this->lng->txt("cont_cach_mode_manual");
534
535 $groups = array();
536 foreach ($a_group_ids as $grp_id) {
537 $groups[] = ilConsultationHourGroups::lookupTitle($grp_id);
538 }
539 $groups = " (" . implode(", ", $groups) . ")";
540 }
541 */
542 // end-abandon ch_groups
543
544 $this->lng->loadLanguageModule("dateplaner");
545 return $this->renderTeaser(
546 "consultation_hours",
547 $this->lng->txt("app_consultation_hours"),
548 $mode . $groups
549 );
550 }
551
552 protected function renderConsultationHours(
553 int $a_user_id,
554 string $a_mode,
555 ?array $a_group_ids = null
556 ): string {
557 $ilUser = $this->user;
558 if ($this->getOutputMode() === "preview") {
559 return $this->renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids);
560 }
561
562 if ($this->getOutputMode() === "offline") {
563 return "";
564 }
565
566 if ($this->getOutputMode() === "print") {
567 return "";
568 }
569
570 $user_id = $this->getPageContentUserId($a_user_id);
571
572 // only if not owner
573 $bkid = 0;
574 if ($ilUser->getId() !== $user_id) {
575 $bkid = $user_id;
576 }
577 $this->ctrl->setParameter($this, "chuid", $user_id);
578
579 if ($a_mode !== "manual") {
580 $a_group_ids = null;
581 }
583 if (!self::$calender_initialized) {
586 0,
587 true
588 );
589 self::$calender_initialized = true;
590 }
591
592 $seed = $this->port_request->getCalendarSeed();
593 if ($seed === "") {
594 $seed = new ilDate(time(), IL_CAL_UNIX);
595 } else {
596 $seed = new ilDate($seed, IL_CAL_DATE);
597 }
598
599 $month_gui = new ilCalendarMonthGUI($seed);
600 if ($bkid > 0) {
601 $month_gui->setBkId($bkid);
602 }
603 $month_gui->setConsulationHoursUserId($user_id);
604
605 // custom schedule filter: handle booking group ids
607 $month_gui->addScheduleFilter($filter);
608
609 $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem', 'delos.css'));
610
611 $this->lng->loadLanguageModule("dateplaner");
612 return '<h3>' . $this->lng->txt("app_consultation_hours") . '</h3>' .
613 $this->ctrl->getHTML($month_gui);
614 }
615
616 protected function isMyCoursesActive(): bool
617 {
618 $prfa_set = new ilSetting("prfa");
619 return (bool) $prfa_set->get("mycrs", true);
620 }
621
622 protected function renderMyCoursesTeaser(
623 int $a_user_id,
624 $a_default_sorting
625 ): string {
626 // not used
627 // $user_id = $this->getPageContentUserId($a_user_id);
628
629 $title = $this->isMyCoursesActive()
630 ? "my_courses"
631 : "my_courses_inactive";
632
633 return $this->renderTeaser(
634 $title,
635 $this->lng->txt("prtf_page_element_my_courses_title")
636 );
637 }
638
639 protected function renderMyCourses(
640 int $a_user_id,
641 string $a_default_sorting
642 ): string {
643 $ilAccess = $this->access;
644 $ilUser = $this->user;
645 $ilCtrl = $this->ctrl;
646
647 if ($this->getOutputMode() === "preview") {
648 return $this->renderMyCoursesTeaser($a_user_id, $a_default_sorting);
649 }
650
651 if (!$this->isMyCoursesActive()) {
652 return "";
653 }
654
655 $img_path = null;
657
658 $user_id = $this->getPageContentUserId($a_user_id);
659
660 // sorting pref
661 $req_sorting = $this->port_request->getCourseSorting();
662 if (in_array($req_sorting, array("alpha", "loc"))) {
663 $ilUser->writePref("prtf_mcrs_sort", $req_sorting);
664 }
665 $sorting = $ilUser->getPref("prtf_mcrs_sort");
666 if (!$sorting) {
667 $sorting = $a_default_sorting;
668 }
669
670 $data = $this->getCoursesOfUser($user_id, ($sorting === "loc"));
671 if (count($data)) {
672 if ($sorting !== "loc") {
673 $data = ilArrayUtil::sortArray($data, "title", "ASC");
674 } else {
675 $data = ilArrayUtil::sortArray($data, "path_sort", "ASC");
676 }
677
678 $tpl = new ilTemplate("tpl.pc_my_courses.html", true, true, "components/ILIAS/Portfolio");
679 $tpl->setVariable("TITLE", $this->lng->txt("prtf_page_element_my_courses_title"));
680 $tpl->setVariable("INFO", $this->lng->txt("prtf_page_element_my_courses_info")); // #14464
681
682 $this->lng->loadLanguageModule("trac");
683 $this->lng->loadLanguageModule("crs");
684
685 // sorting
686 if ($this->getOutputMode() !== "print") {
687 $options = array(
688 "alpha" => $this->lng->txt("cont_mycourses_sortorder_alphabetical"),
689 "loc" => $this->lng->txt("cont_mycourses_sortorder_location")
690 );
691 $tpl->setVariable(
692 "SORT_SELECT",
694 $sorting,
695 "srt",
696 $options,
697 false,
698 true,
699 0,
700 "",
701 ["onchange" => "form.submit()"]
702 )
703 );
704 $tpl->setVariable("SORT_FORM", $this->getCourseSortAction($ilCtrl));
705 }
706
707 $old_path = null;
708
709 foreach ($data as $course) {
710 if (($sorting === "loc") && $course["path"] != $old_path) {
711 $tpl->setCurrentBlock("path_bl");
712 $tpl->setVariable("PATH", $course["path"]);
713 $tpl->parseCurrentBlock();
714
715 $old_path = $course["path"];
716 }
717
718 if (isset($course["lp_status"])) {
719 $lp_icon_rendered = $lp_icons->renderIconForStatus($course["lp_status"]);
720
721 $tpl->setCurrentBlock("lp_bl");
722 $tpl->setVariable("LP_ICON", $lp_icon_rendered);
723 $tpl->parseCurrentBlock();
724 }
725
726 $do_links = false;
727 if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
728 $do_links = $ilAccess->checkAccessOfUser($ilUser->getId(), "read", "", $course["ref_id"], "crs") ||
729 ($ilAccess->checkAccessOfUser($ilUser->getId(), "visible", "", $course["ref_id"], "crs") &&
730 $ilAccess->checkAccessOfUser($ilUser->getId(), "join", "", $course["ref_id"], "crs"));
731 }
732
733 if (isset($course["objectives"])) {
734 $loc_settings = ilLOSettings::getInstanceByObjId($course["obj_id"]);
735 $has_initial_test = (bool) $loc_settings->getInitialTest();
736
737 foreach ($course["objectives"] as $objtv) {
738 if ($do_links) {
739 $params = array("oobj" => $objtv["id"]);
740 $url = ilLink::_getLink($course["ref_id"], "crs", $params);
741
742 // #15510
743 $url .= "#objtv_acc_" . $objtv["id"];
744
745 if ($this->getOutputMode() !== "print") {
746 $tpl->touchBlock("objective_dnone");
747 }
748
749 $tpl->setCurrentBlock("objective_link_bl");
750
751 $objtv_link = $this->ui_fac->link()->standard(
752 $objtv["title"],
753 $url
754 );
755 if (trim($objtv["desc"] ?? "") !== "") {
756 $desc = nl2br($objtv["desc"]);
757 $objtv_link = $objtv_link->withHelpTopics(...$this->ui_fac->helpTopics($desc));
758 }
759
760 $tpl->setVariable("OBJECTIVE_LINK", $this->ui_ren->render($objtv_link));
761 } else {
762 $tpl->setCurrentBlock("objective_nolink_bl");
763 $tpl->setVariable("OBJECTIVE_NOLINK_TITLE", $objtv["title"]);
764 }
765 $tpl->parseCurrentBlock();
766
767 $objtv_icon = ilObject::_getIcon($objtv["id"], 'big', "lobj");
768 if ($img_path) {
769 $objtv_icon = $img_path . basename($objtv_icon);
770 }
771
772 $tpl->setCurrentBlock("objective_bl");
773 $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
774 $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
775
776 if (isset($objtv["type"])) {
777 $tpl->setVariable(
778 "LP_OBJTV_PROGRESS",
780 $has_initial_test,
781 $objtv["id"],
782 $objtv,
783 true,
784 false,
785 self::$initialized
786 )
787 );
788 }
789
790 $tpl->parseCurrentBlock();
791 }
792
793 $tpl->setCurrentBlock("objectives_bl");
794 $tpl->setVariable("OBJTV_LIST_CRS_ID", $course["obj_id"]);
795 $tpl->parseCurrentBlock();
796 }
797
798 // always check against current user
799 if ($do_links) {
800 $tpl->setCurrentBlock("course_link_bl");
801 $tpl->setVariable("COURSE_LINK_TITLE", $course["title"]);
802 $tpl->setVariable("COURSE_LINK_URL", ilLink::_getLink($course["ref_id"]));
803 } else {
804 $tpl->setCurrentBlock("course_nolink_bl");
805 $tpl->setVariable("COURSE_NOLINK_TITLE", $course["title"]);
806 }
807 $tpl->parseCurrentBlock();
808
809 $crs_icon = ilObject::_getIcon($course["obj_id"], 'small', 'crs');
810 if ($img_path) {
811 $crs_icon = $img_path . basename($crs_icon);
812 }
813
814 $tpl->setCurrentBlock("course_bl");
815
816 if (isset($course["objectives"])) {
817 $tpl->setVariable("TOGGLE_CLASS", "ilPCMyCoursesToggle");
818 } else {
819 $tpl->setVariable("NO_TOGGLE", ' style="visibility:hidden;"');
820 }
821
822 $tpl->setVariable("CRS_ICON_URL", $crs_icon);
823 $tpl->setVariable("CRS_ICON_ALT", $this->lng->txt("obj_crs"));
824 $tpl->parseCurrentBlock();
825 }
826
827 // #15508
828 if (!self::$initialized) {
829 $GLOBALS["tpl"]->addJavaScript("assets/js/ilPortfolio.js");
830 $GLOBALS["tpl"]->addOnLoadCode("ilPortfolio.init()");
831 }
832 self::$initialized++;
833
834 return $tpl->get();
835 }
836 return "";
837 }
838
842 protected function getCourseSortAction(ilCtrl $ctrl): string
843 {
844 return $ctrl->getFormActionByClass("ilobjportfoliogui", "preview");
845 }
846
847 protected function getCoursesOfUser(
848 int $a_user_id,
849 bool $a_add_path = false
850 ): array {
851 $tree = $this->tree;
852
853 // see ilPDSelectedItemsBlockGUI
854
855 $items = ilParticipants::_getMembershipByType($a_user_id, ['crs']);
856
857 $repo_title = $tree->getNodeData(ROOT_FOLDER_ID);
858 $repo_title = $repo_title["title"];
859 if ($repo_title == "ILIAS") {
860 $repo_title = $this->lng->txt("repository");
861 }
862
863 $references = $lp_obj_refs = array();
864 foreach ($items as $obj_id) {
866 if (is_array($ref_id) && count($ref_id)) {
867 $ref_id = array_pop($ref_id);
868 if (!$tree->isDeleted($ref_id)) {
869 $visible = false;
870 $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false);
871 if ($active && $visible) {
872 $references[$ref_id] = array(
873 'ref_id' => $ref_id,
874 'obj_id' => $obj_id,
875 'title' => ilObject::_lookupTitle($obj_id)
876 );
877
878 if ($a_add_path) {
879 $path = array();
880 foreach ($tree->getPathFull($ref_id) as $item) {
881 $path[] = $item["title"];
882 }
883 // top level comes first
884 if (count($path) === 2) {
885 $path[0] = 0;
886 } else {
887 $path[0] = 1;
888 }
889 $references[$ref_id]["path_sort"] = implode("__", $path);
890 array_shift($path);
891 array_pop($path);
892 if (!count($path)) {
893 array_unshift($path, $repo_title);
894 }
895 $references[$ref_id]["path"] = implode(" &rsaquo; ", $path);
896 }
897
898 $lp_obj_refs[$obj_id] = $ref_id;
899 }
900 }
901 }
902 }
903
904 // get lp data for valid courses
905
906 if (count($lp_obj_refs)) {
907 // listing the objectives should NOT depend on any LP status / setting
908 foreach ($lp_obj_refs as $obj_id => $ref_id) {
909 // only if set in DB (default mode is not relevant
911 $references[$ref_id]["objectives"] = $this->parseObjectives($obj_id, $a_user_id);
912 }
913 }
914
915 // LP must be active, personal and not anonymized
919 // see ilLPProgressTableGUI
920 $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs);
921 foreach ($lp_data as $item) {
922 $ref_id = $item["ref_ids"];
923 $references[$ref_id]["lp_status"] = $item["status"];
924 }
925 }
926 }
927
928 return $references;
929 }
930
931 protected function parseObjectives(
932 int $a_obj_id,
933 int $a_user_id
934 ): array {
935 $res = array();
936
937 // we need the collection for the correct order
939 $coll_objtv = $coll_objtv->getItems();
940 if ($coll_objtv) {
941 // #13373
942 $lo_results = $this->parseLOUserResults($a_obj_id, $a_user_id);
943
944 $lo_ass = ilLOTestAssignments::getInstance($a_obj_id);
945
946 $tmp = array();
947
948 foreach ($coll_objtv as $objective_id) {
950 $title = ilCourseObjective::lookupObjectiveTitle($objective_id, true);
951
952 $tmp[$objective_id] = array(
953 "id" => $objective_id,
954 "title" => $title["title"],
955 "desc" => $title["description"],
956 "itest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL),
957 "qtest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED)
958 );
959
960 if (array_key_exists($objective_id, $lo_results)) {
961 $lo_result = $lo_results[$objective_id];
962 $tmp[$objective_id]["user_id"] = $lo_result["user_id"];
963 $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"] ?? null;
964 $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"] ?? null;
965 $tmp[$objective_id]["status"] = $lo_result["status"] ?? null;
966 $tmp[$objective_id]["type"] = $lo_result["type"] ?? null;
967 $tmp[$objective_id]["initial"] = $lo_result["initial"] ?? null;
968 }
969 }
970
971 // order
972 foreach ($coll_objtv as $objtv_id) {
973 $res[] = $tmp[$objtv_id];
974 }
975 }
976
977 return $res;
978 }
979
980 // see ilContainerObjectiveGUI::parseLOUserResults()
981 protected function parseLOUserResults(
982 int $a_course_obj_id,
983 int $a_user_id
984 ): array {
985 $res = array();
986 $initial_status = "";
987
988 $lur = new ilLOUserResults($a_course_obj_id, $a_user_id);
989 foreach ($lur->getCourseResultsForUserPresentation() as $objective_id => $types) {
990 // show either initial or qualified for objective
991 if (isset($types[ilLOUserResults::TYPE_INITIAL])) {
992 $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"];
993 }
994
995 // qualified test has priority
996 if (isset($types[ilLOUserResults::TYPE_QUALIFIED])) {
997 $result = $types[ilLOUserResults::TYPE_QUALIFIED];
998 $result["type"] = ilLOUserResults::TYPE_QUALIFIED;
999 $result["initial"] = $types[ilLOUserResults::TYPE_INITIAL] ?? null;
1000 } else {
1001 $result = $types[ilLOUserResults::TYPE_INITIAL];
1002 $result["type"] = ilLOUserResults::TYPE_INITIAL;
1003 }
1004
1005 $result["initial_status"] = $initial_status;
1006
1007 $res[$objective_id] = $result;
1008 }
1009
1010 return $res;
1011 }
1012
1013 public function getExportMaterial(): array
1014 {
1015 return $this->export_material;
1016 }
1017
1018 public function makePlaceHoldersClickable(string $a_html): string
1019 {
1020 $ilCtrl = $this->ctrl;
1021 $lng = $this->lng;
1022 $ilUser = $this->user;
1023
1024 $end = 0;
1025 $start = strpos($a_html, "{{{{{PlaceHolder#");
1026 if (is_int($start)) {
1027 $end = strpos($a_html, "}}}}}", $start);
1028 }
1029 while ($end > 0) {
1030 $param = substr($a_html, $start + 17, $end - $start - 17);
1031 $param = explode("#", $param);
1032
1033 $html = $param[2];
1034 switch ($param[2]) {
1035 case "Text":
1036 $html = $lng->txt("cont_text_placeh");
1037 break;
1038
1039 case "Media":
1040 $html = $lng->txt("cont_media_placeh");
1041 break;
1042
1043 case "Question":
1044 $html = $lng->txt("cont_question_placeh");
1045 break;
1046
1047 case "Verification":
1048 $html = $lng->txt("cont_verification_placeh");
1049 break;
1050 }
1051
1052 // only if not owner
1053 if ($ilUser->getId() === ilObjPortfolio::_lookupOwner($this->portfolio_id)
1054 && $this->getOutputMode() === "presentation") {
1055 switch ($param[2]) {
1056 case "Text":
1057 $ilCtrl->setParameterByClass("ilportfoliopagegui", "prt_id", $this->port_request->getPortfolioId());
1058 $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $this->getId());
1059 $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_pc_id", $param[0]);
1060 $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_hier_id", $param[1]);
1061 $href = $ilCtrl->getLinkTargetByClass("ilportfoliopagegui", "insertJSAtPlaceholder");
1062 $html = "<a href='" . $href . "'>" . $html . "</a>";
1063 break;
1064
1065 case "Media":
1066 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "prt_id", $this->port_request->getPortfolioId());
1067 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "ppage", $this->getId());
1068 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_pc_id", $param[0]);
1069 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_hier_id", $param[1]);
1070 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "insertNew");
1071 $href = $ilCtrl->getLinkTargetByClass(array("ilPortfolioPageGUI", "ilPageEditorGUI", "ilPCPlaceHolderGUI", "ilpcmediaobjectgui"), "insert");
1072 $html = "<a href='" . $href . "'>" . $html . "</a>";
1073 break;
1074
1075 /* see #34170, may need a different change, keep code to monitor
1076 case "Verification":
1077 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "prt_id", $this->port_request->getPortfolioId());
1078 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "ppage", $this->getId());
1079 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "pl_pc_id", $param[0]);
1080 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "pl_hier_id", $param[1]);
1081 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "subCmd", "insertNew");
1082 $href = $ilCtrl->getLinkTargetByClass(array("ilPortfolioPageGUI", "ilPageEditorGUI", "ilPCPlaceHolderGUI", "ilPCVerificationGUI"), "insert");
1083 $html = "<a href='" . $href . "'>" . $html . "</a>";
1084 break;
1085 */
1086 }
1087 }
1088
1089 $h2 = substr($a_html, 0, $start) .
1090 $html .
1091 substr($a_html, $end + 5);
1092 $a_html = $h2;
1093
1094 $start = strpos($a_html, "{{{{{PlaceHolder#", $start + 5);
1095 $end = 0;
1096 if (is_int($start)) {
1097 $end = strpos($a_html, "}}}}}", $start);
1098 }
1099 }
1100 return $a_html;
1101 }
1102
1103 public function getViewPageLink(): string
1104 {
1105 global $DIC;
1106
1107 $ctrl = $DIC->ctrl();
1108
1109 $ctrl->setParameterByClass("ilobjportfoliogui", "user_page", $this->requested_ppage);
1110 return $ctrl->getLinkTargetByClass("ilobjportfoliogui", "preview");
1111 }
1112
1113 public function getViewPageText(): string
1114 {
1115 return $this->lng->txt("preview");
1116 }
1117
1118 public function getPagePermaLink(): string
1119 {
1121 return ilLink::_getStaticLink($pid, "prtf", true, "_" . $this->getId());
1122 }
1123
1125 int $a_id,
1126 ilUserCertificateRepository $userCertificateRepository,
1127 string $url
1128 ): string {
1129 try {
1130 $presentation = $userCertificateRepository->fetchActiveCertificateForPresentation($this->user->getId(), $a_id);
1131 } catch (Exception $e) {
1132 return "";
1133 }
1134 $caption = $this->lng->txt('certificate') . ': ';
1135 $caption .= $this->lng->txt($presentation->getUserCertificate()->getObjType()) . ' ';
1136 $caption .= '"' . $presentation->getObjectTitle() . '"';
1137
1138 return '<div><a href="' . $url . '">' . $caption . '</a></div>';
1139 }
1140
1141 public function getCommentsHTMLExport(): string
1142 {
1143 $notes_gui = new ilCommentGUI(
1144 $this->portfolio_id,
1145 $this->getPageObject()->getId(),
1146 "pfpg"
1147 );
1148 $notes_gui->enablePublicNotes(true);
1149 $notes_gui->setRepositoryMode(false);
1150 $notes_gui->setExportMode();
1151 return $notes_gui->getListHTML();
1152 }
1153
1154 public function finishEditing(): void
1155 {
1156 $this->ctrl->redirectByClass("ilObjPortfolioGUI", "view");
1157 }
1158}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
GUI class for public user profile presentation.
const IL_CAL_DATE
const IL_CAL_UNIX
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
Class ilBlogPosting.
static _getInstance($a_usr_id=0)
get singleton instance
Calendar schedule filter for consultation hour bookings.
static buildObjectiveProgressBar(bool $a_has_initial_test, int $a_objective_id, array $a_lo_result, bool $a_list_mode=false, bool $a_sub=false, ?string $a_tt_suffix=null)
Render progressbar(s) for given objective and result data.
static lookupObjectiveTitle(int $a_objective_id, bool $a_add_description=false)
Class ilCtrl provides processing control methods.
getFormActionByClass( $a_class, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Class for single dates.
static getInstanceByObjId(int $a_obj_id)
static getInstance(int $a_container_id)
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
static _isActivated(int $a_obj_id, ?bool &$a_visible_flag=null, bool $a_mind_member_view=true)
GUI class for course verification.
static _lookupViewMode(int $a_id)
GUI class for exercise verification.
GUI class for scorm verification.
GUI class for test verification.
parses the objects.xml it handles the xml-description of all ilias objects
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupOwner(int $obj_id)
Lookup owner user ID for object ID.
static _getAllReferences(int $id)
get all reference ids for object ID
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupTitle(int $obj_id)
Class ilPageObjectGUI.
setPresentationTitle(string $a_title="")
setTemplateOutput(bool $a_output=true)
ilGlobalTemplateInterface $tpl
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
Personal skills GUI class.
Portfolio page gui class.
getTabs(string $a_activate="")
renderConsultationHoursTeaser(int $a_user_id, string $a_mode, ?array $a_group_ids=null)
renderVerification(int $a_user_id, string $a_type, int $a_id)
getCourseSortAction(ilCtrl $ctrl)
Get course sort action.
__construct(int $a_portfolio_id, int $a_id=0, int $a_old_nr=0, bool $a_enable_comments=true)
renderProfile(int $a_user_id, string $a_type, ?array $a_fields=null)
postOutputProcessing(string $a_output)
Finalizing output processing.
renderMyCoursesTeaser(int $a_user_id, $a_default_sorting)
renderPageElement(string $a_type, string $a_html)
ilObjectDefinition $obj_definition
renderTeaser(string $a_type, string $a_title, string $a_options="")
renderMyCourses(int $a_user_id, string $a_default_sorting)
makePlaceHoldersClickable(string $a_html)
getCoursesOfUser(int $a_user_id, bool $a_add_path=false)
getPageContentUserId(int $a_user_id)
getAdditional()
Get Additonal Information.
setEmbedded(bool $a_value)
Set embedded mode: will suppress tabs.
setAdditional(array $a_additional)
Set Additonal Information.
renderSkillsTeaser(int $a_user_id, int $a_skills_id)
renderConsultationHours(int $a_user_id, string $a_mode, ?array $a_group_ids=null)
showPage()
display content of page
renderBlogTeaser(int $a_user_id, int $a_blog_id, ?array $a_posting_ids=null)
renderSkills(int $a_user_id, int $a_skills_id)
parseLOUserResults(int $a_course_obj_id, int $a_user_id)
ILIAS Portfolio StandardGUIRequest $port_request
createPersistentCertificateUrl(int $a_id, ilUserCertificateRepository $userCertificateRepository, string $url)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static findPortfolioForPage(int $a_page_id)
Get portfolio id of page id.
ILIAS Setting Class.
A node in the skill tree.
special template class to simplify handling of ITX/PEAR
static getObjectsStatusForUser(int $a_user_id, array $obj_refs)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name.
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
const ANONYMOUS_USER_ID
Definition: constants.php:27
const ROOT_FOLDER_ID
Definition: constants.php:32
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
$ref_id
Definition: ltiauth.php:66
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
$path
Definition: ltiservices.php:30
$res
Definition: ltiservices.php:69
$post
Definition: ltitoken.php:46
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
try
handle Lrs Init
Definition: xapiproxy.php:73
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:70
$GLOBALS["DIC"]
Definition: wac.php:54
$param
Definition: xapitoken.php:44