ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
class.ilInfoScreenGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23use ILIAS\Export\ExportHandler\Factory as ExportServices;
24use ILIAS\Data\Factory as DataFactory;
26
35{
36 protected \ILIAS\Repository\HTML\HTMLUtil $html;
37 protected \ILIAS\DI\UIServices $ui;
43 protected ilObjUser $user;
44 protected ilTree $tree;
46 protected Metadata $metadata;
47 protected DataFactory $data_factory;
49 public ilCtrl $ctrl;
50 public ?object $gui_object;
51 public array $top_buttons = array();
52 public array $top_formbuttons = array();
53 public array $hiddenelements = array();
54 public string $table_class = "il_InfoScreen";
55 public bool $open_form_tag = true;
56 public bool $close_form_tag = true;
57 protected ?int $contextRefId = null;
58 protected ?int $contextObjId = null;
59 protected ?string $contentObjType = null;
60 public string $form_action;
61 protected bool $booking_enabled = false;
62 protected bool $availability_enabled = true;
63 protected bool $hidden = false;
64 protected array $section = [];
65 protected array $block_property = [];
66 protected bool $news_editing = false;
67 protected bool $show_hidden_toggle = false;
68 protected int $sec_nr = 0;
69 protected bool $private_notes_enabled = false;
70 protected bool $news_enabled = false;
71 protected bool $feedback_enabled = false;
72 protected bool $learning_progress_enabled = false;
74
75
76 public function __construct(?object $a_gui_object = null)
77 {
78 global $DIC;
79
80 $this->rbacsystem = $DIC->rbac()->system();
81 $this->tpl = $DIC["tpl"];
82 $this->access = $DIC->access();
83 $this->user = $DIC->user();
84 $this->tree = $DIC->repositoryTree();
85 $this->settings = $DIC->settings();
86 $ilCtrl = $DIC->ctrl();
87 $lng = $DIC->language();
88 $ilTabs = $DIC->tabs();
89 $this->metadata = $DIC->learningObjectMetadata();
90
91 $this->ctrl = $ilCtrl;
92 $this->lng = $lng;
93 $this->tabs_gui = $ilTabs;
94 $this->gui_object = $a_gui_object;
95 $this->form_action = "";
96 $this->top_formbuttons = array();
97 $this->hiddenelements = array();
98 $this->ui = $DIC->ui();
99 $this->request = $DIC->infoScreen()->internal()->gui()->standardRequest();
100 $this->html = $DIC->infoScreen()->internal()->gui()->html();
101 $this->data_factory = new DataFactory();
102 }
103
110 public function executeCommand(): void
111 {
113
114 $next_class = $this->ctrl->getNextClass($this);
115
116 $cmd = $this->ctrl->getCmd("showSummary");
117 $this->ctrl->setReturn($this, "showSummary");
118
119 $this->setTabs();
120
121 switch ($next_class) {
122 case strtolower(ilCommentGUI::class):
123 if ($this->ctrl->isAsynch()) {
124 $this->showNotesSection();
125 } else {
126 $this->showSummary(); // forwards command
127 }
128 break;
129
130 case "ilcolumngui":
131 $this->showSummary();
132 break;
133
134 case strtolower(PublicProfileGUI::class):
135 $user_profile = new PublicProfileGUI($this->request->getUserId());
136 $user_profile->setBackUrl($this->ctrl->getLinkTarget($this, "showSummary"));
137 $html = $this->ctrl->forwardCommand($user_profile);
139 break;
140
141 case "ilcommonactiondispatchergui":
143 $this->ctrl->forwardCommand($gui);
144 break;
145
146 default:
147 $this->$cmd();
148 break;
149 }
150 }
151
152 public function setMessageBox(ILIAS\UI\Component\MessageBox\MessageBox $a_val): void
153 {
154 $this->mbox = $a_val;
155 }
156
157 public function getMessageBox(): ILIAS\UI\Component\MessageBox\MessageBox
158 {
159 return $this->mbox;
160 }
161
162
163 public function setTableClass(string $a_val): void
164 {
165 $this->table_class = $a_val;
166 }
167
168 public function getTableClass(): string
169 {
170 return $this->table_class;
171 }
172
173 public function enablePrivateNotes(bool $a_enable = true): void
174 {
175 $this->private_notes_enabled = $a_enable;
176 }
177
178 public function enableLearningProgress(bool $a_enable = true): void
179 {
180 $this->learning_progress_enabled = $a_enable;
181 }
182
183 public function enableAvailability(bool $a_enable = true): void
184 {
185 $this->availability_enabled = $a_enable;
186 }
187
188 public function enableBookingInfo(bool $a_enable = true): void
189 {
190 $this->booking_enabled = $a_enable;
191 }
192
193
194 public function enableFeedback(bool $a_enable = true): void
195 {
196 $this->feedback_enabled = $a_enable;
197 }
198
199 public function enableNews(bool $a_enable = true): void
200 {
201 $this->news_enabled = $a_enable;
202 }
203
204 public function enableNewsEditing(bool $a_enable = true): void
205 {
206 $this->news_editing = $a_enable;
207 }
208
213 public function setBlockProperty(string $a_block_type, string $a_property, string $a_value): void
214 {
215 $this->block_property[$a_block_type][$a_property] = $a_value;
216 }
217
218 public function getAllBlockProperties(): array
219 {
221 }
222
223 public function addSection(string $a_title): void
224 {
225 $this->sec_nr++;
226 $this->section[$this->sec_nr]["title"] = $a_title;
227 $this->section[$this->sec_nr]["hidden"] = $this->hidden;
228 }
229
233 public function setFormAction(string $a_form_action): void
234 {
235 $this->form_action = $a_form_action;
236 }
237
238 public function removeFormAction(): void
239 {
240 $this->form_action = "";
241 }
242
250 public function addProperty(string $a_name, string $a_value, string $a_link = ""): void
251 {
252 $this->section[$this->sec_nr]["properties"][] =
253 array("name" => $a_name, "value" => $a_value,
254 "link" => $a_link);
255 }
256
257
261 public function addPropertyTextinput(
262 string $a_name,
263 string $a_input_name,
264 string $a_input_value = "",
265 string $a_input_size = "",
266 string $direct_button_command = "",
267 string $direct_button_label = "",
268 bool $direct_button_primary = false
269 ): void {
270 $input = "<span class=\"form-inline\"><input class=\"form-control\" type=\"text\" name=\"$a_input_name\" id=\"$a_input_name\"";
271 if (strlen($a_input_value)) {
272 $input .= " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput($a_input_value) . "\"";
273 }
274 if (strlen($a_input_size)) {
275 $input .= " size=\"" . $a_input_size . "\"";
276 }
277 $input .= " />";
278 if (strlen($direct_button_command) && strlen($direct_button_label)) {
279 $css = "";
280 if ($direct_button_primary) {
281 $css = " btn-primary";
282 }
283 $input .= " <input type=\"submit\" class=\"btn btn-default" . $css . "\" name=\"cmd[$direct_button_command]\" value=\"$direct_button_label\" />";
284 }
285 $input .= "</span>";
286 $this->section[$this->sec_nr]["properties"][] =
287 array("name" => "<label for=\"$a_input_name\">$a_name</label>", "value" => $input);
288 }
289
293 public function addButton(
294 string $a_title,
295 string $a_link,
296 string $a_frame = "",
297 string $a_position = "top",
298 bool $a_primary = false
299 ): void {
300 if ($a_position == "top") {
301 $this->top_buttons[] =
302 array("title" => $a_title,"link" => $a_link,"target" => $a_frame,"primary" => $a_primary);
303 }
304 }
305
310 public function addFormButton(
311 string $a_command,
312 string $a_title,
313 string $a_position = "top"
314 ): void {
315 if ($a_position == "top") {
316 $this->top_formbuttons[] = array("command" => $a_command, "title" => $a_title);
317 }
318 }
319
320 public function addHiddenElement(string $a_name, string $a_value): void
321 {
322 $this->hiddenelements[] = array("name" => $a_name, "value" => $a_value);
323 }
324
325 public function addMetaDataSections(int $a_rep_obj_id, int $a_obj_id, string $a_type): void
326 {
328
329 $lng->loadLanguageModule("meta");
330 $lng->loadLanguageModule('export');
331
332 $md_reader = $this->metadata->read($a_rep_obj_id, $a_obj_id, $a_type);
333 $md_paths = $this->metadata->paths();
334 $md_data_helper = $this->metadata->dataHelper();
335 $md_copyright_helper = $this->metadata->copyrightHelper();
336
337 // general
338 $lang_data = $md_reader->allData($md_paths->languages());
339 $langs = $md_data_helper->makePresentableAsList(', ', ...$lang_data);
340
341 $keyword_data = $md_reader->allData($md_paths->keywords());
342 $keywords = $md_data_helper->makePresentableAsList(', ', ...$keyword_data);
343
344 // authors
345 $author_data = $md_reader->allData($md_paths->authors());
346 $author = $md_data_helper->makePresentableAsList(', ', ...$author_data);
347
348 // learning time
349 $learning_time_data = $md_reader->firstData($md_paths->firstTypicalLearningTime());
350 $learning_time = $md_data_helper->makePresentable($learning_time_data);
351
352 // copyright
353 $copyright = '';
354 if ($md_copyright_helper->hasPresetCopyright($md_reader)) {
355 $copyright = $this->ui->renderer()->render(
356 $md_copyright_helper->readPresetCopyright($md_reader)->presentAsUIComponents()
357 );
358 } else {
359 $copyright = $md_copyright_helper->readCustomCopyright($md_reader);
360 }
361
362 // public access export
363 $public_access_export = $this->buildPublicAccessExportButton($a_rep_obj_id, $a_obj_id);
364
365 // output
366
367 // general section
368 $this->addSection($lng->txt("meta_general"));
369 if ($langs != "") { // language
370 $this->addProperty(
371 $lng->txt("language"),
372 $this->html->escape($langs)
373 );
374 }
375 if ($keywords != "") { // keywords
376 $this->addProperty(
377 $lng->txt("keywords"),
378 $this->html->escape($keywords)
379 );
380 }
381 if ($author != "") { // author
382 $this->addProperty(
383 $lng->txt("author"),
384 $this->html->escape($author)
385 );
386 }
387 if ($learning_time != "") { // typical learning time
388 $this->addProperty(
389 $lng->txt("meta_typical_learning_time"),
390 $this->html->escape($learning_time)
391 );
392 }
393
394 // licence and use section
395 if ($copyright === '' && $public_access_export === '') {
396 return;
397 }
398 $this->addSection($lng->txt('meta_info_licence_section'));
399
400 if ($public_access_export !== '') { // public access export
401 $this->addProperty(
402 $lng->txt('export_info_public_access'),
403 $public_access_export
404 );
405 }
406
407 if ($copyright !== '') { // copyright
408 $this->addProperty(
409 $lng->txt("meta_copyright"),
410 $copyright
411 );
412 }
413 }
414
415 protected function buildPublicAccessExportButton(int $rep_obj_id, int $obj_id): string
416 {
417 /*
418 * This should be replaced by a proper export API
419 * when it is available.
420 */
421 $export_services = new ExportServices();
422 $public_access = $export_services->publicAccess()->handler();
423
424 /*
425 * Make sure we are not in a subobject, and that we will get
426 * the ref_id via the GUI from the correct object.
427 */
428 if (
429 $rep_obj_id !== $this->gui_object->getObject()->getId() ||
430 ($obj_id !== 0 && $obj_id !== $rep_obj_id)
431 ) {
432 return '';
433 }
434
435 if (!$public_access->hasPublicAccessFile($this->data_factory->objId($rep_obj_id))) {
436 return '';
437 }
438
439 $ref_id = $this->gui_object->getObject()->getRefId();
440
441 return $this->ui->renderer()->render(
442 $this->ui->factory()->button()->standard(
443 $this->lng->txt('export_info_public_access_download'),
444 $public_access->downloadLinkOfPublicAccessFile($this->data_factory->refId($ref_id))
445 )
446 );
447 }
448
454 public function addObjectSections(): void
455 {
457 $ilCtrl = $this->ctrl;
458 $ilUser = $this->user;
459 $ilAccess = $this->access;
460 $tree = $this->tree;
461
462 // resource bookings
463 if ($this->booking_enabled) {
464 $booking_adapter = new ilBookingInfoScreenAdapter($this);
465 $booking_adapter->add();
466 }
467
468 $this->addSection($lng->txt("additional_info"));
469 $a_obj = $this->gui_object->getObject();
470
471 // links to the object
472 if (is_object($a_obj)) {
473 // permanent link
474 $type = $a_obj->getType();
475 $ref_id = $a_obj->getRefId();
476
477 if ($ref_id) {
478 if (ilECSServerSettings::getInstance()->activeServerExists()) {
479 $this->addProperty(
480 $lng->txt("object_id"),
481 (string) $a_obj->getId()
482 );
483 }
484
485 $this->tpl->setPermanentLink($type, $ref_id);
486
487 // links to resource
488 if ($ilAccess->checkAccess("write", "", $ref_id) ||
489 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
490 $obj_id = $a_obj->getId();
491 $rs = ilObject::_getAllReferences($obj_id);
492 $refs = array();
493 foreach ($rs as $r) {
494 if ($tree->isInTree($r)) {
495 $refs[] = $r;
496 }
497 }
498 if (count($refs) > 1) {
499 $links = $sep = "";
500 foreach ($refs as $r) {
501 $cont_loc = new ilLocatorGUI();
502 $cont_loc->addContextItems($r, true);
503 $links .= $sep . $cont_loc->getHTML();
504 $sep = "<br />";
505 }
506
507 $this->addProperty(
508 $lng->txt("res_links"),
509 '<div class="small">' . $links . '</div>'
510 );
511 }
512 }
513 }
514 }
515
516
517 // creation date
518 if ($ilAccess->checkAccess("write", "", $ref_id) ||
519 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
520 $this->addProperty(
521 $lng->txt("create_date"),
522 ilDatePresentation::formatDate(new ilDateTime($a_obj->getCreateDate(), IL_CAL_DATETIME, 'UTC'))
523 );
524
525 // owner
526 if ($ilUser->getId() != ANONYMOUS_USER_ID and $a_obj->getOwner()) {
527 if (ilObjUser::userExists(array($a_obj->getOwner()))) {
529 $ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(), false);
530 } else {
531 $ownerObj = ilObjectFactory::getInstanceByObjId(6, false);
532 }
533
534 if (!is_object($ownerObj) || $ownerObj->getType() != "usr") { // root user deleted
535 $this->addProperty($lng->txt("owner"), $lng->txt("no_owner"));
536 } elseif ($ownerObj->hasPublicProfile()) {
537 $ilCtrl->setParameterByClass(PublicProfileGUI::class, "user_id", $ownerObj->getId());
538 $this->addProperty(
539 $lng->txt("owner"),
540 $ownerObj->getPublicName(),
541 $ilCtrl->getLinkTargetByClass([ilPublicProfileBaseClassGUI::class, PublicProfileGUI::class], "getHTML")
542 );
543 } else {
544 $this->addProperty($lng->txt("owner"), $ownerObj->getPublicName());
545 }
546 }
547
548 // change event
550 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
551 $readEvents = ilChangeEvent::_lookupReadEvents($a_obj->getId());
552 $count_users = 0;
553 $count_user_reads = 0;
554 $count_anonymous_reads = 0;
555 foreach ($readEvents as $evt) {
556 if ($evt['usr_id'] == ANONYMOUS_USER_ID) {
557 $count_anonymous_reads += $evt['read_count'];
558 } else {
559 $count_user_reads += $evt['read_count'];
560 $count_users++;
561 /* to do: if ($evt['user_id'] is member of $this->getRefId())
562 {
563 $count_members++;
564 }*/
565 }
566 }
567 if ($count_anonymous_reads > 0) {
568 $this->addProperty(
569 $this->lng->txt("readcount_anonymous_users"),
570 (string) $count_anonymous_reads
571 );
572 }
573 if ($count_user_reads > 0) {
574 $this->addProperty($this->lng->txt("readcount_users"), (string) $count_user_reads);
575 }
576 if ($count_users > 0) {
577 $this->addProperty($this->lng->txt("accesscount_registered_users"), (string) $count_users);
578 }
579 }
580 }
581 }
582 }
583 // END ChangeEvent: Display standard object info
584
591 public function showSummary(): void
592 {
593 $tpl = $this->tpl;
594
595 $tpl->setContent($this->getCenterColumnHTML());
596 $tpl->setRightContent($this->getRightColumnHTML());
597 }
598
599
607 public function getCenterColumnHTML(): string
608 {
609 $ilCtrl = $this->ctrl;
610 $html = "";
611 $column_gui = new ilColumnGUI("info", IL_COL_CENTER);
612 $this->setColumnSettings($column_gui);
613
614 if (!$ilCtrl->isAsynch()) {
615 if ($column_gui->getScreenMode() != IL_SCREEN_SIDE) {
616 // right column wants center
617 if ($column_gui->getCmdSide() == IL_COL_RIGHT) {
618 $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
619 $this->setColumnSettings($column_gui);
620 $html = $ilCtrl->forwardCommand($column_gui);
621 }
622 // left column wants center
623 if ($column_gui->getCmdSide() == IL_COL_LEFT) {
624 $column_gui = new ilColumnGUI("info", IL_COL_LEFT);
625 $this->setColumnSettings($column_gui);
626 $html = $ilCtrl->forwardCommand($column_gui);
627 }
628 } else {
629 $html = $this->getHTML();
630 }
631 }
632
633 return $html;
634 }
635
640 public function getRightColumnHTML(): string
641 {
642 $ilCtrl = $this->ctrl;
643
644 $html = "";
645 $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
646 $this->setColumnSettings($column_gui);
647
648 if ($ilCtrl->getNextClass() == "ilcolumngui" &&
649 $column_gui->getCmdSide() == IL_COL_RIGHT &&
650 $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
651 $html = $ilCtrl->forwardCommand($column_gui);
652 } elseif (!$ilCtrl->isAsynch() && $this->news_enabled) {
653 $html = $ilCtrl->getHTML($column_gui);
654 }
655
656 return $html;
657 }
658
662 public function setColumnSettings(ilColumnGUI $column_gui): void
663 {
664 $column_gui->setEnableEdit($this->news_editing);
665 $column_gui->setRepositoryMode(true);
666 $column_gui->setAllBlockProperties($this->getAllBlockProperties());
667 }
668
669 public function setOpenFormTag(bool $a_val): void
670 {
671 $this->open_form_tag = $a_val;
672 }
673
674 public function setCloseFormTag(bool $a_val): void
675 {
676 $this->close_form_tag = $a_val;
677 }
678
686 public function getHTML(): string
687 {
689 $ilSetting = $this->settings;
690 $ilCtrl = $this->ctrl;
691 $ilUser = $this->user;
692
693 $tpl = new ilTemplate("tpl.infoscreen.html", true, true, "components/ILIAS/InfoScreen");
694
695 // other class handles form action (@todo: this is not implemented/tested)
696 if ($this->form_action == "") {
697 $this->setFormAction($ilCtrl->getFormAction($this));
698 }
699
701
702 if ($this->hidden) {
703 $tpl->touchBlock("hidden_js");
704 if ($this->show_hidden_toggle) {
705 $this->addButton($lng->txt("show_hidden_sections"), "JavaScript:toggleSections(this, '" . $lng->txt("show_hidden_sections") . "', '" . $lng->txt("hide_visible_sections") . "');");
706 }
707 }
708
709
710 // DEPRECATED - use ilToolbarGUI
711
712 // add top buttons
713 if (count($this->top_buttons) > 0) {
714 $tpl->addBlockFile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html");
715
716 foreach ($this->top_buttons as $button) {
717 // view button
718 $tpl->setCurrentBlock("btn_cell");
719 $tpl->setVariable("BTN_LINK", $button["link"]);
720 $tpl->setVariable("BTN_TARGET", $button["target"]);
721 $tpl->setVariable("BTN_TXT", $button["title"]);
722 if ($button["primary"]) {
723 $tpl->setVariable("BTN_CLASS", " btn-primary");
724 }
725 $tpl->parseCurrentBlock();
726 }
727 }
728
729 // add top formbuttons
730 if ((count($this->top_formbuttons) > 0) && ($this->form_action !== '')) {
731 $tpl->addBlockFile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html", "components/ILIAS/InfoScreen");
732
733 foreach ($this->top_formbuttons as $button) {
734 // view button
735 $tpl->setCurrentBlock("btn_submit_cell");
736 $tpl->setVariable("BTN_COMMAND", $button["command"]);
737 $tpl->setVariable("BTN_NAME", $button["title"]);
738 $tpl->parseCurrentBlock();
739 }
740 }
741
742 // add form action
743 if ($this->form_action != "") {
744 if ($this->open_form_tag) {
745 $tpl->setCurrentBlock("formtop");
746 $tpl->setVariable("FORMACTION", $this->form_action);
747 $tpl->parseCurrentBlock();
748 }
749
750 if ($this->close_form_tag) {
751 $tpl->touchBlock("formbottom");
752 }
753 }
754
755 if (count($this->hiddenelements)) {
756 foreach ($this->hiddenelements as $hidden) {
757 $tpl->setCurrentBlock("hidden_element");
758 $tpl->setVariable("HIDDEN_NAME", $hidden["name"]);
759 $tpl->setVariable("HIDDEN_VALUE", $hidden["value"]);
760 $tpl->parseCurrentBlock();
761 }
762 }
763
764 if ($this->availability_enabled) {
765 $this->addAvailability();
766 }
767
768 $this->addPreconditions();
769
770 // learning progress
771 if ($this->learning_progress_enabled) {
772 $this->showLearningProgress($tpl);
773 }
774
775 // notes section
776 if ($this->private_notes_enabled && !$ilSetting->get('disable_notes')) {
777 $html = $this->showNotesSection();
778 $tpl->setCurrentBlock("notes");
779 $tpl->setVariable("NOTES", $html);
780 $tpl->parseCurrentBlock();
781 }
782
783 if (
784 isset($this->gui_object) &&
785 method_exists($this->gui_object, "getObject") &&
786 is_object($this->gui_object->getObject())
787 ) {
788 $this->addObjectSections();
789 }
790
791 // render all sections
792 for ($i = 1; $i <= $this->sec_nr; $i++) {
793 if (isset($this->section[$i]["properties"])) {
794 // section properties
795 foreach ($this->section[$i]["properties"] as $property) {
796 if ($property["name"] != "") {
797 if (($property["link"] ?? "") == "") {
798 $tpl->setCurrentBlock("pv");
799 $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]);
800 } else {
801 $tpl->setCurrentBlock("lpv");
802 $tpl->setVariable("TXT_PROPERTY_LVALUE", $property["value"]);
803 $tpl->setVariable("LINK_PROPERTY_VALUE", $property["link"]);
804 }
805 $tpl->parseCurrentBlock();
806 $tpl->setCurrentBlock("property_row");
807 $tpl->setVariable("TXT_PROPERTY", $property["name"]);
808 } else {
809 $tpl->setCurrentBlock("property_full_row");
810 $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]);
811 }
812 $tpl->parseCurrentBlock();
813 }
814
815 // section header
816 if ($this->section[$i]["hidden"] ?? false) {
817 $tpl->setVariable("SECTION_HIDDEN", " style=\"display:none;\"");
818 $tpl->setVariable("SECTION_ID", "hidable_" . $i);
819 } else {
820 $tpl->setVariable("SECTION_ID", $i);
821 }
822 $tpl->setVariable("TCLASS", $this->getTableClass());
823 $tpl->setVariable("TXT_SECTION", $this->section[$i]["title"]);
824 $tpl->setCurrentBlock("row");
825 $tpl->parseCurrentBlock();
826 }
827 }
828
829 if (!is_null($this->mbox)) {
830 $tpl->setVariable("MBOX", $this->ui->renderer()->render([$this->mbox]));
831 }
832
833 return $tpl->get();
834 }
835
836 public function getContextRefId(): int
837 {
838 if ($this->contextRefId !== null) {
839 return $this->contextRefId;
840 }
841
842 return $this->gui_object->getObject()->getRefId();
843 }
844
845 public function setContextRefId(int $contextRefId): void
846 {
847 $this->contextRefId = $contextRefId;
848 }
849
850 public function getContextObjId(): int
851 {
852 if ($this->contextObjId !== null) {
853 return $this->contextObjId;
854 }
855
856 return $this->gui_object->getObject()->getId();
857 }
858
859 public function setContextObjId(int $contextObjId): void
860 {
861 $this->contextObjId = $contextObjId;
862 }
863
864 public function getContentObjType(): string
865 {
866 if ($this->contentObjType !== null) {
867 return $this->contentObjType;
868 }
869
870 return $this->gui_object->getObject()->getType();
871 }
872
873 public function setContentObjType(string $contentObjType): void
874 {
875 $this->contentObjType = $contentObjType;
876 }
877
882 public function showLearningProgress(ilTemplate $a_tpl): void
883 {
884 return;
885
886 $ilUser = $this->user;
887 $rbacsystem = $this->rbacsystem;
888
889 if (!$rbacsystem->checkAccess('read', $this->getContextRefId())) {
890 return;
891 }
892 if ($ilUser->getId() == ANONYMOUS_USER_ID) {
893 return;
894 }
895
897 return;
898 }
899
900 $olp = ilObjectLP::getInstance($this->getContextObjId());
901 if ($olp->getCurrentMode() != ilLPObjSettings::LP_MODE_MANUAL) {
902 return;
903 }
904
905 $this->lng->loadLanguageModule('trac');
906
907 // section header
908 // $a_tpl->setCurrentBlock("header_row");
909 $a_tpl->setVariable(
910 "TXT_SECTION",
911 $this->lng->txt('learning_progress')
912 );
913 $a_tpl->parseCurrentBlock();
914 }
915
916 public function saveProgress(bool $redirect = true): void
917 {
918 $ilUser = $this->user;
919
920 // ensure a read event
922 $ilUser->getId(),
923 $this->getContextObjId(),
924 $this->getContextRefId(),
925 ilObject::_lookupType($this->getContextObjId())
926 );
927
928 $lp_marks = new ilLPMarks($this->getContextObjId(), $ilUser->getId());
929 $lp_marks->setCompleted((bool) $this->request->getLPEdit());
930 $lp_marks->update();
931
932 ilLPStatusWrapper::_updateStatus($this->getContextObjId(), $ilUser->getId());
933
934 $this->lng->loadLanguageModule('trac');
935 $this->tpl->setOnScreenMessage('success', $this->lng->txt('trac_updated_status'), true);
936
937 if ($redirect) {
938 $this->ctrl->redirect($this, ""); // #14993
939 }
940 }
941
942
947 public function showNotesSection(): string
948 {
949 global $DIC;
950
951 $ilAccess = $this->access;
952 $ilSetting = $this->settings;
953 $notes_gui = $DIC->notes()->gui();
954 $notes_gui->initJavascript();
955 $comments_gui = $notes_gui->getCommentsGUI(
956 $this->gui_object->getObject()->getId(),
957 0,
958 $this->gui_object->getObject()->getType()
959 );
960
961 $next_class = $this->ctrl->getNextClass($this);
962 $comments_gui->setUseObjectTitleHeader(false);
963
964 // global switch
965 if ($ilSetting->get("disable_comments")) {
966 return "";
967 } else {
968 $ref_id = $this->gui_object->getObject()->getRefId();
969 $has_write = $ilAccess->checkAccess("write", "", $ref_id);
970
971 if ($has_write && $ilSetting->get("comments_del_tutor", "1")) {
972 $comments_gui->enablePublicNotesDeletion();
973 }
974
975 /* should probably be discussed further
976 for now this will only work properly with comments settings
977 (see ilNoteGUI constructor)
978 */
979 if ($has_write ||
980 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
981 $comments_gui->enableCommentsSettings();
982 }
983 }
984
985 /* moved to action menu
986 $notes_gui->enablePrivateNotes();
987 */
988 if ($next_class === strtolower(ilCommentGUI::class)) {
989 $html = $this->ctrl->forwardCommand($comments_gui);
990 } else {
991 $html = $comments_gui->getListHTML();
992 }
993
994 return $html;
995 }
996
1000 public function showLDAPRoleGroupMappingInfo(string $a_section = ''): void
1001 {
1002 if (strlen($a_section)) {
1003 $this->addSection($a_section);
1004 }
1005 $ldap_mapping = ilLDAPRoleGroupMapping::_getInstance();
1006 if ($infos = $ldap_mapping->getInfoStrings($this->gui_object->getObject()->getId())) {
1007 $info_combined = '<div style="color:green;">';
1008 $counter = 0;
1009 foreach ($infos as $info_string) {
1010 if ($counter++) {
1011 $info_combined .= '<br />';
1012 }
1013 $info_combined .= $info_string;
1014 }
1015 $info_combined .= '</div>';
1016 $this->addProperty($this->lng->txt('applications'), $info_combined);
1017 }
1018 }
1019
1020 public function setTabs(): void
1021 {
1022 $this->getTabs($this->tabs_gui);
1023 }
1024
1025 public function getTabs(ilTabsGUI $tabs_gui): void
1026 {
1027 $next_class = $this->ctrl->getNextClass($this);
1028 $force_active = ($next_class == "ilnotegui");
1029
1030 $tabs_gui->addSubTabTarget(
1031 'summary',
1032 $this->ctrl->getLinkTarget($this, "showSummary"),
1033 array("showSummary", ""),
1034 get_class($this),
1035 "",
1036 $force_active
1037 );
1038 }
1039
1040
1041
1042 public function hideFurtherSections(bool $a_add_toggle = true): void
1043 {
1044 $this->hidden = true;
1045 $this->show_hidden_toggle = $a_add_toggle;
1046 }
1047
1048 public function getHiddenToggleButton(): string
1049 {
1050 $lng = $this->lng;
1051
1052 return "<a onClick=\"toggleSections(this, '" . $lng->txt("show_hidden_sections") . "', '" . $lng->txt("hide_visible_sections") . "'); return false;\" href=\"#\">" . $lng->txt("show_hidden_sections") . "</a>";
1053 }
1054
1055
1060 protected function addAvailability(): void
1061 {
1062 if (
1063 !is_object($this->gui_object) ||
1064 !method_exists($this->gui_object, "getObject") ||
1065 !is_object($this->gui_object->getObject())
1066 ) {
1067 return;
1068 }
1069
1070 $obj = $this->gui_object->getObject();
1071 if ($obj->getRefId() <= 0) {
1072 return;
1073 }
1074
1075 $act = new ilObjectActivation();
1076 $act->read($obj->getRefId());
1077 if ($act->getTimingType() == ilObjectActivation::TIMINGS_ACTIVATION) {
1078 $this->lng->loadLanguageModule("rep");
1079 $this->addSection($this->lng->txt("rep_activation_availability"));
1080 $this->addAccessPeriodProperty();
1081 }
1082 }
1083
1087 protected function addPreconditions(): void
1088 {
1089 if (
1090 !is_object($this->gui_object) ||
1091 !method_exists($this->gui_object, "getObject") ||
1092 !is_object($this->gui_object->getObject())
1093 ) {
1094 return;
1095 }
1096
1097 $obj = $this->gui_object->getObject();
1098 if ($obj->getRefId() <= 0) {
1099 return;
1100 }
1101
1102 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($obj->getRefId(), $obj->getId());
1103
1104 if (sizeof($conditions)) {
1105 for ($i = 0; $i < count($conditions); $i++) {
1106 $conditions[$i]['title'] = ilObject::_lookupTitle($conditions[$i]['trigger_obj_id']);
1107 }
1108 $conditions = ilArrayUtil::sortArray($conditions, 'title', 'DESC');
1109
1110 // Show obligatory and optional preconditions seperated
1111 $this->addPreconditionSection($obj, $conditions, true);
1112 $this->addPreconditionSection($obj, $conditions, false);
1113 }
1114 }
1115
1116 protected function addPreconditionSection(
1117 ilObject $obj,
1118 array $conditions,
1119 bool $obligatory = true
1120 ): void {
1121 $lng = $this->lng;
1122 $tree = $this->tree;
1123
1125 $num_optional_required =
1126 $num_required - count($conditions) + count(ilConditionHandler::getEffectiveOptionalConditionsOfTarget($obj->getRefId(), $obj->getId()));
1127
1128 // Check if all conditions are fulfilled
1129 $visible_conditions = array();
1130 $passed_optional = 0;
1131 foreach ($conditions as $condition) {
1132 if ($obligatory and !$condition['obligatory']) {
1133 continue;
1134 }
1135 if (!$obligatory and $condition['obligatory']) {
1136 continue;
1137 }
1138
1139 if ($tree->isDeleted($condition['trigger_ref_id'])) {
1140 continue;
1141 }
1142
1143 $ok = ilConditionHandler::_checkCondition($condition) and
1144 !ilMemberViewSettings::getInstance()->isActive();
1145
1146 if (!$ok) {
1147 $visible_conditions[] = $condition['id'];
1148 }
1149
1150 if (!$obligatory and $ok) {
1151 ++$passed_optional;
1152 // optional passed
1153 if ($passed_optional >= $num_optional_required) {
1154 return;
1155 }
1156 }
1157 }
1158
1159 $properties = [];
1160
1161 foreach ($conditions as $condition) {
1162 if (!isset($condition["id"]) || !in_array($condition['id'], $visible_conditions)) {
1163 continue;
1164 }
1165
1166 $properties[] = [
1168 $condition['trigger_obj_id'],
1169 $condition['operator'],
1170 $condition['value']
1171 ),
1172 "title" => ilObject::_lookupTitle($condition['trigger_obj_id']),
1173 "link" => ilLink::_getLink($condition['trigger_ref_id'])
1174 ];
1175 }
1176
1177 if (count($properties) > 0) {
1178 if ($obligatory) {
1179 $this->addSection($lng->txt("preconditions_obligatory_hint"));
1180 } else {
1181 $this->addSection(sprintf(
1182 $lng->txt("preconditions_optional_hint"),
1183 $num_optional_required - $passed_optional
1184 ));
1185 }
1186
1187 foreach ($properties as $p) {
1188 $this->addProperty(
1189 $p["condition"],
1190 "<a href='" . $p["link"] . "'>" . $this->html->strip($p["title"]) . "</a>"
1191 );
1192 }
1193 }
1194 }
1195
1200 public function addAccessPeriodProperty(): void
1201 {
1202 $a_obj = $this->gui_object->getObject();
1203
1204 $this->lng->loadLanguageModule("rep");
1205 $this->lng->loadLanguageModule("crs");
1206
1207 // links to the object
1208 if (is_object($a_obj)) {
1209 $act = new ilObjectActivation();
1210 $act->read($a_obj->getRefId());
1211 if ($act->getTimingType() == ilObjectActivation::TIMINGS_ACTIVATION) {
1212 $this->addProperty(
1213 $this->lng->txt('rep_activation_access'),
1215 new ilDateTime($act->getTimingStart(), IL_CAL_UNIX),
1216 new ilDateTime($act->getTimingEnd(), IL_CAL_UNIX)
1217 )
1218 );
1219 } else {
1220 $this->addProperty(
1221 $this->lng->txt('rep_activation_access'),
1222 $this->lng->txt('crs_visibility_limitless')
1223 );
1224 }
1225 }
1226 }
1227}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
Builds data types.
Definition: Factory.php:36
GUI class for public user profile presentation.
const IL_SCREEN_SIDE
const IL_COL_RIGHT
const IL_COL_CENTER
const IL_COL_LEFT
const IL_CAL_UNIX
const IL_CAL_DATETIME
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupReadEvents($obj_id, $usr_id=null)
Reads all read events which occured on the object.
static _isActive()
Returns true, if change event tracking is active.
Column user interface class.
setAllBlockProperties(array $a_block_properties)
setEnableEdit(bool $a_enableedit)
setRepositoryMode(bool $a_repositorymode)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static translateOperator(int $a_obj_id, string $a_operator, string $value='')
static calculateEffectiveRequiredTriggers(int $a_target_ref_id, int $a_target_obj_id, string $a_target_obj_type='')
static _checkCondition(array $condition, int $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
static getEffectiveOptionalConditionsOfTarget(int $a_target_ref_id, int $a_target_obj_id, string $a_obj_type='')
Class ilCtrl provides processing control methods.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.
@classDescription Date and time handling
static getInstance()
Get singleton instance.
setContent(string $a_html)
Sets content for standard template.
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
addBlockFile(string $var, string $block, string $template_name, ?string $in_module=null)
overwrites ITX::addBlockFile
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
setRightContent(string $a_html)
Sets content of right column.
touchBlock(string $blockname)
overwrites ITX::touchBlock.
Class ilInfoScreenGUI.
buildPublicAccessExportButton(int $rep_obj_id, int $obj_id)
enableNews(bool $a_enable=true)
StandardGUIRequest $request
ilAccessHandler $access
setColumnSettings(ilColumnGUI $column_gui)
Set column settings.
setFormAction(string $a_form_action)
setBlockProperty(string $a_block_type, string $a_property, string $a_value)
This function is supposed to be used for block type specific properties, that should be passed to ilB...
setCloseFormTag(bool $a_val)
__construct(?object $a_gui_object=null)
enableBookingInfo(bool $a_enable=true)
getTabs(ilTabsGUI $tabs_gui)
showLearningProgress(ilTemplate $a_tpl)
enableFeedback(bool $a_enable=true)
enableLearningProgress(bool $a_enable=true)
addSection(string $a_title)
ilGlobalPageTemplate $tpl
addProperty(string $a_name, string $a_value, string $a_link="")
add a property to current section
addFormButton(string $a_command, string $a_title, string $a_position="top")
add a form button to the info screen the form buttons are only valid if a form action is set
enableNewsEditing(bool $a_enable=true)
addButton(string $a_title, string $a_link, string $a_frame="", string $a_position="top", bool $a_primary=false)
enableAvailability(bool $a_enable=true)
hideFurtherSections(bool $a_add_toggle=true)
ILIAS Repository HTML HTMLUtil $html
enablePrivateNotes(bool $a_enable=true)
setContextObjId(int $contextObjId)
addPropertyTextinput(string $a_name, string $a_input_name, string $a_input_value="", string $a_input_size="", string $direct_button_command="", string $direct_button_label="", bool $direct_button_primary=false)
setTableClass(string $a_val)
showLDAPRoleGroupMappingInfo(string $a_section='')
ILIAS UI Component MessageBox MessageBox $mbox
addHiddenElement(string $a_name, string $a_value)
saveProgress(bool $redirect=true)
setContextRefId(int $contextRefId)
addPreconditions()
Add preconditions.
ILIAS DI UIServices $ui
addPreconditionSection(ilObject $obj, array $conditions, bool $obligatory=true)
addMetaDataSections(int $a_rep_obj_id, int $a_obj_id, string $a_type)
setMessageBox(ILIAS\UI\Component\MessageBox\MessageBox $a_val)
setContentObjType(string $contentObjType)
static _getInstance()
Get singleton instance of this class.
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
language handling
static _tracProgress(int $a_user_id, int $a_obj_id, int $a_ref_id, string $a_obj_type='')
static prepareFormOutput($a_str, bool $a_strip=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
static userExists(array $a_usr_ids=[])
Class ilObjectActivation.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstance(int $obj_id)
Class ilObject Basic functions for all objects.
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addSubTabTarget(string $a_text, string $a_link, $a_cmd="", $a_cmdClass="", string $a_frame="", bool $a_activate=false, bool $a_dir_text=false)
special template class to simplify handling of ITX/PEAR
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
isInTree(?int $a_node_id)
get all information of a node.
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name.
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
const ANONYMOUS_USER_ID
Definition: constants.php:27
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$ref_id
Definition: ltiauth.php:66
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:26
global $ilSetting
Definition: privfeed.php:26
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$counter