ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
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 if ($this->getOutputMode() === "offline") {
740 $params = array("oobj" => $objtv["id"]);
741 $url = ilLink::_getLink($course["ref_id"], "crs", $params);
742 } else {
743 $this->ctrl->setParameterByClass(ilObjCourseGUI::class, "ref_id", $course["ref_id"]);
744 $this->ctrl->setParameterByClass(ilObjCourseGUI::class, "oobj", $objtv["id"]);
745 $url = $this->ctrl->getLinkTargetByClass(
746 [
747 ilRepositoryGUI::class,
748 ilObjCourseGUI::class
749 ]
750 );
751 $this->ctrl->setParameterByClass(ilObjCourseGUI::class, "ref_id", null);
752 $this->ctrl->setParameterByClass(ilObjCourseGUI::class, "oobj", null);
753 }
754
755 // #15510
756 $url .= "#objtv_acc_" . $objtv["id"];
757
758 if ($this->getOutputMode() !== "print") {
759 $tpl->touchBlock("objective_dnone");
760 }
761
762 $tpl->setCurrentBlock("objective_link_bl");
763
764 $objtv_link = $this->ui_fac->link()->standard(
765 $objtv["title"],
766 $url
767 );
768 if (trim($objtv["desc"] ?? "") !== "") {
769 $desc = nl2br($objtv["desc"]);
770 $objtv_link = $objtv_link->withHelpTopics(...$this->ui_fac->helpTopics($desc));
771 }
772
773 $tpl->setVariable("OBJECTIVE_LINK", $this->ui_ren->render($objtv_link));
774 } else {
775 $tpl->setCurrentBlock("objective_nolink_bl");
776 $tpl->setVariable("OBJECTIVE_NOLINK_TITLE", $objtv["title"]);
777 }
778 $tpl->parseCurrentBlock();
779
780 $objtv_icon = ilObject::_getIcon($objtv["id"], 'big', "lobj");
781 if ($img_path) {
782 $objtv_icon = $img_path . basename($objtv_icon);
783 }
784
785 $tpl->setCurrentBlock("objective_bl");
786 $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
787 $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
788
789 if (isset($objtv["type"])) {
790 $tpl->setVariable(
791 "LP_OBJTV_PROGRESS",
793 $has_initial_test,
794 $objtv["id"],
795 $objtv,
796 true,
797 false,
798 self::$initialized
799 )
800 );
801 }
802
803 $tpl->parseCurrentBlock();
804 }
805
806 $tpl->setCurrentBlock("objectives_bl");
807 $tpl->setVariable("OBJTV_LIST_CRS_ID", $course["obj_id"]);
808 $tpl->parseCurrentBlock();
809 }
810
811 // always check against current user
812 if ($do_links) {
813 $tpl->setCurrentBlock("course_link_bl");
814 $tpl->setVariable("COURSE_LINK_TITLE", $course["title"]);
815 $tpl->setVariable("COURSE_LINK_URL", ilLink::_getLink($course["ref_id"]));
816 } else {
817 $tpl->setCurrentBlock("course_nolink_bl");
818 $tpl->setVariable("COURSE_NOLINK_TITLE", $course["title"]);
819 }
820 $tpl->parseCurrentBlock();
821
822 $crs_icon = ilObject::_getIcon($course["obj_id"], 'small', 'crs');
823 if ($img_path) {
824 $crs_icon = $img_path . basename($crs_icon);
825 }
826
827 $tpl->setCurrentBlock("course_bl");
828
829 if (isset($course["objectives"])) {
830 $tpl->setVariable("TOGGLE_CLASS", "ilPCMyCoursesToggle");
831 } else {
832 $tpl->setVariable("NO_TOGGLE", ' style="visibility:hidden;"');
833 }
834
835 $tpl->setVariable("CRS_ICON_URL", $crs_icon);
836 $tpl->setVariable("CRS_ICON_ALT", $this->lng->txt("obj_crs"));
837 $tpl->parseCurrentBlock();
838 }
839
840 // #15508
841 if (!self::$initialized) {
842 $GLOBALS["tpl"]->addJavaScript("assets/js/ilPortfolio.js");
843 $GLOBALS["tpl"]->addOnLoadCode("ilPortfolio.init()");
844 }
845 self::$initialized++;
846
847 return $tpl->get();
848 }
849 return "";
850 }
851
855 protected function getCourseSortAction(ilCtrl $ctrl): string
856 {
857 return $ctrl->getFormActionByClass("ilobjportfoliogui", "preview");
858 }
859
860 protected function getCoursesOfUser(
861 int $a_user_id,
862 bool $a_add_path = false
863 ): array {
864 $tree = $this->tree;
865
866 // see ilPDSelectedItemsBlockGUI
867
868 $items = ilParticipants::_getMembershipByType($a_user_id, ['crs']);
869
870 $repo_title = $tree->getNodeData(ROOT_FOLDER_ID);
871 $repo_title = $repo_title["title"];
872 if ($repo_title == "ILIAS") {
873 $repo_title = $this->lng->txt("repository");
874 }
875
876 $references = $lp_obj_refs = array();
877 foreach ($items as $obj_id) {
879 if (is_array($ref_id) && count($ref_id)) {
880 $ref_id = array_pop($ref_id);
881 if (!$tree->isDeleted($ref_id)) {
882 $visible = false;
883 $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false);
884 if (ilObject::lookupOfflineStatus($obj_id)) {
885 $visible = false;
886 }
887 if ($active && $visible) {
888 $references[$ref_id] = array(
889 'ref_id' => $ref_id,
890 'obj_id' => $obj_id,
891 'title' => ilObject::_lookupTitle($obj_id)
892 );
893
894 if ($a_add_path) {
895 $path = array();
896 foreach ($tree->getPathFull($ref_id) as $item) {
897 $path[] = $item["title"];
898 }
899 // top level comes first
900 if (count($path) === 2) {
901 $path[0] = 0;
902 } else {
903 $path[0] = 1;
904 }
905 $references[$ref_id]["path_sort"] = implode("__", $path);
906 array_shift($path);
907 array_pop($path);
908 if (!count($path)) {
909 array_unshift($path, $repo_title);
910 }
911 $references[$ref_id]["path"] = implode(" &rsaquo; ", $path);
912 }
913
914 $lp_obj_refs[$obj_id] = $ref_id;
915 }
916 }
917 }
918 }
919
920 // get lp data for valid courses
921
922 if (count($lp_obj_refs)) {
923 // listing the objectives should NOT depend on any LP status / setting
924 foreach ($lp_obj_refs as $obj_id => $ref_id) {
925 // only if set in DB (default mode is not relevant
927 $references[$ref_id]["objectives"] = $this->parseObjectives($obj_id, $a_user_id);
928 }
929 }
930
931 // LP must be active, personal and not anonymized
935 // see ilLPProgressTableGUI
936 $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs);
937 foreach ($lp_data as $item) {
938 $ref_id = $item["ref_ids"];
939 $references[$ref_id]["lp_status"] = $item["status"];
940 }
941 }
942 }
943
944 return $references;
945 }
946
947 protected function parseObjectives(
948 int $a_obj_id,
949 int $a_user_id
950 ): array {
951 $res = array();
952
953 // we need the collection for the correct order
955 $coll_objtv = $coll_objtv->getItems();
956 if ($coll_objtv) {
957 // #13373
958 $lo_results = $this->parseLOUserResults($a_obj_id, $a_user_id);
959
960 $lo_ass = ilLOTestAssignments::getInstance($a_obj_id);
961
962 $tmp = array();
963
964 foreach ($coll_objtv as $objective_id) {
966 $title = ilCourseObjective::lookupObjectiveTitle($objective_id, true);
967
968 $tmp[$objective_id] = array(
969 "id" => $objective_id,
970 "title" => $title["title"],
971 "desc" => $title["description"],
972 "itest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL),
973 "qtest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED)
974 );
975
976 if (array_key_exists($objective_id, $lo_results)) {
977 $lo_result = $lo_results[$objective_id];
978 $tmp[$objective_id]["user_id"] = $lo_result["user_id"];
979 $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"] ?? null;
980 $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"] ?? null;
981 $tmp[$objective_id]["status"] = $lo_result["status"] ?? null;
982 $tmp[$objective_id]["type"] = $lo_result["type"] ?? null;
983 $tmp[$objective_id]["initial"] = $lo_result["initial"] ?? null;
984 }
985 }
986
987 // order
988 foreach ($coll_objtv as $objtv_id) {
989 $res[] = $tmp[$objtv_id];
990 }
991 }
992
993 return $res;
994 }
995
996 // see ilContainerObjectiveGUI::parseLOUserResults()
997 protected function parseLOUserResults(
998 int $a_course_obj_id,
999 int $a_user_id
1000 ): array {
1001 $res = array();
1002 $initial_status = "";
1003
1004 $lur = new ilLOUserResults($a_course_obj_id, $a_user_id);
1005 foreach ($lur->getCourseResultsForUserPresentation() as $objective_id => $types) {
1006 // show either initial or qualified for objective
1007 if (isset($types[ilLOUserResults::TYPE_INITIAL])) {
1008 $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"];
1009 }
1010
1011 // qualified test has priority
1012 if (isset($types[ilLOUserResults::TYPE_QUALIFIED])) {
1013 $result = $types[ilLOUserResults::TYPE_QUALIFIED];
1014 $result["type"] = ilLOUserResults::TYPE_QUALIFIED;
1015 $result["initial"] = $types[ilLOUserResults::TYPE_INITIAL] ?? null;
1016 } else {
1017 $result = $types[ilLOUserResults::TYPE_INITIAL];
1018 $result["type"] = ilLOUserResults::TYPE_INITIAL;
1019 }
1020
1021 $result["initial_status"] = $initial_status;
1022
1023 $res[$objective_id] = $result;
1024 }
1025
1026 return $res;
1027 }
1028
1029 public function getExportMaterial(): array
1030 {
1031 return $this->export_material;
1032 }
1033
1034 public function makePlaceHoldersClickable(string $a_html): string
1035 {
1036 $ilCtrl = $this->ctrl;
1037 $lng = $this->lng;
1038 $ilUser = $this->user;
1039
1040 $end = 0;
1041 $start = strpos($a_html, "{{{{{PlaceHolder#");
1042 if (is_int($start)) {
1043 $end = strpos($a_html, "}}}}}", $start);
1044 }
1045 while ($end > 0) {
1046 $param = substr($a_html, $start + 17, $end - $start - 17);
1047 $param = explode("#", $param);
1048
1049 $html = $param[2];
1050 switch ($param[2]) {
1051 case "Text":
1052 $html = $lng->txt("cont_text_placeh");
1053 break;
1054
1055 case "Media":
1056 $html = $lng->txt("cont_media_placeh");
1057 break;
1058
1059 case "Question":
1060 $html = $lng->txt("cont_question_placeh");
1061 break;
1062
1063 case "Verification":
1064 $html = $lng->txt("cont_verification_placeh");
1065 break;
1066 }
1067
1068 // only if not owner
1069 if ($ilUser->getId() === ilObjPortfolio::_lookupOwner($this->portfolio_id)
1070 && $this->getOutputMode() === "presentation") {
1071 switch ($param[2]) {
1072 case "Text":
1073 $ilCtrl->setParameterByClass("ilportfoliopagegui", "prt_id", $this->port_request->getPortfolioId());
1074 $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $this->getId());
1075 $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_pc_id", $param[0]);
1076 $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_hier_id", $param[1]);
1077 $href = $ilCtrl->getLinkTargetByClass("ilportfoliopagegui", "insertJSAtPlaceholder");
1078 $html = "<a href='" . $href . "'>" . $html . "</a>";
1079 break;
1080
1081 case "Media":
1082 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "prt_id", $this->port_request->getPortfolioId());
1083 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "ppage", $this->getId());
1084 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_pc_id", $param[0]);
1085 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_hier_id", $param[1]);
1086 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "insertNew");
1087 $href = $ilCtrl->getLinkTargetByClass(array("ilPortfolioPageGUI", "ilPageEditorGUI", "ilPCPlaceHolderGUI", "ilpcmediaobjectgui"), "insert");
1088 $html = "<a href='" . $href . "'>" . $html . "</a>";
1089 break;
1090
1091 /* see #34170, may need a different change, keep code to monitor
1092 case "Verification":
1093 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "prt_id", $this->port_request->getPortfolioId());
1094 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "ppage", $this->getId());
1095 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "pl_pc_id", $param[0]);
1096 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "pl_hier_id", $param[1]);
1097 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "subCmd", "insertNew");
1098 $href = $ilCtrl->getLinkTargetByClass(array("ilPortfolioPageGUI", "ilPageEditorGUI", "ilPCPlaceHolderGUI", "ilPCVerificationGUI"), "insert");
1099 $html = "<a href='" . $href . "'>" . $html . "</a>";
1100 break;
1101 */
1102 }
1103 }
1104
1105 $h2 = substr($a_html, 0, $start) .
1106 $html .
1107 substr($a_html, $end + 5);
1108 $a_html = $h2;
1109
1110 $start = strpos($a_html, "{{{{{PlaceHolder#", $start + 5);
1111 $end = 0;
1112 if (is_int($start)) {
1113 $end = strpos($a_html, "}}}}}", $start);
1114 }
1115 }
1116 return $a_html;
1117 }
1118
1119 public function getViewPageLink(): string
1120 {
1121 global $DIC;
1122
1123 $ctrl = $DIC->ctrl();
1124
1125 $ctrl->setParameterByClass("ilobjportfoliogui", "user_page", $this->requested_ppage);
1126 return $ctrl->getLinkTargetByClass("ilobjportfoliogui", "preview");
1127 }
1128
1129 public function getViewPageText(): string
1130 {
1131 return $this->lng->txt("preview");
1132 }
1133
1134 public function getPagePermaLink(): string
1135 {
1137 return ilLink::_getStaticLink($pid, "prtf", true, "_" . $this->getId());
1138 }
1139
1141 int $a_id,
1142 ilUserCertificateRepository $userCertificateRepository,
1143 string $url
1144 ): string {
1145 try {
1146 $presentation = $userCertificateRepository->fetchActiveCertificateForPresentation($this->user->getId(), $a_id);
1147 } catch (Exception $e) {
1148 return "";
1149 }
1150 $caption = $this->lng->txt('certificate') . ': ';
1151 $caption .= $this->lng->txt($presentation->getUserCertificate()->getObjType()) . ' ';
1152 $caption .= '"' . $presentation->getObjectTitle() . '"';
1153
1154 return '<div><a href="' . $url . '">' . $caption . '</a></div>';
1155 }
1156
1157 public function getCommentsHTMLExport(): string
1158 {
1159 $notes_gui = new ilCommentGUI(
1160 $this->portfolio_id,
1161 $this->getPageObject()->getId(),
1162 "pfpg"
1163 );
1164 $notes_gui->enablePublicNotes(true);
1165 $notes_gui->setRepositoryMode(false);
1166 $notes_gui->setExportMode();
1167 return $notes_gui->getListHTML();
1168 }
1169
1170 public function finishEditing(): void
1171 {
1172 $this->ctrl->redirectByClass("ilObjPortfolioGUI", "view");
1173 }
1174}
$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)
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
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:26
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