ILIAS  release_8 Revision v8.24
class.ilInfoScreenGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
31{
32 protected \ILIAS\DI\UIServices $ui;
38 protected ilObjUser $user;
39 protected ilTree $tree;
42 public ilCtrl $ctrl;
43 public ?object $gui_object;
44 public array $top_buttons = array();
45 public array $top_formbuttons = array();
46 public array $hiddenelements = array();
47 public string $table_class = "il_InfoScreen";
48 public bool $open_form_tag = true;
49 public bool $close_form_tag = true;
50 protected ?int $contextRefId = null;
51 protected ?int $contextObjId = null;
52 protected ?string $contentObjType = null;
53 public string $form_action;
54 protected bool $booking_enabled = false;
55 protected bool $availability_enabled = true;
56 protected bool $hidden = false;
57 protected array $section = [];
58 protected array $block_property = [];
59 protected bool $news_editing = false;
60 protected bool $show_hidden_toggle = false;
61 protected int $sec_nr = 0;
62 protected bool $private_notes_enabled = false;
63 protected bool $news_enabled = false;
64 protected bool $feedback_enabled = false;
65 protected bool $learning_progress_enabled = false;
67
68
69 public function __construct(?object $a_gui_object = null)
70 {
71 global $DIC;
72
73 $this->rbacsystem = $DIC->rbac()->system();
74 $this->tpl = $DIC["tpl"];
75 $this->access = $DIC->access();
76 $this->user = $DIC->user();
77 $this->tree = $DIC->repositoryTree();
78 $this->settings = $DIC->settings();
79 $ilCtrl = $DIC->ctrl();
80 $lng = $DIC->language();
81 $ilTabs = $DIC->tabs();
82
83 $this->ctrl = $ilCtrl;
84 $this->lng = $lng;
85 $this->tabs_gui = $ilTabs;
86 $this->gui_object = $a_gui_object;
87 $this->form_action = "";
88 $this->top_formbuttons = array();
89 $this->hiddenelements = array();
90 $this->ui = $DIC->ui();
91 $this->request = new StandardGUIRequest(
92 $DIC->http(),
93 $DIC->refinery()
94 );
95 }
96
103 public function executeCommand(): void
104 {
106
107 $next_class = $this->ctrl->getNextClass($this);
108
109 $cmd = $this->ctrl->getCmd("showSummary");
110 $this->ctrl->setReturn($this, "showSummary");
111
112 $this->setTabs();
113
114 switch ($next_class) {
115 case "ilnotegui":
116 if ($this->ctrl->isAsynch()) {
117 $this->showNotesSection();
118 } else {
119 $this->showSummary(); // forwards command
120 }
121 break;
122
123 case "ilcolumngui":
124 $this->showSummary();
125 break;
126
127 case "ilpublicuserprofilegui":
128 $user_profile = new ilPublicUserProfileGUI($this->request->getUserId());
129 $user_profile->setBackUrl($this->ctrl->getLinkTarget($this, "showSummary"));
130 $html = $this->ctrl->forwardCommand($user_profile);
131 $tpl->setContent($html);
132 break;
133
134 case "ilcommonactiondispatchergui":
136 $this->ctrl->forwardCommand($gui);
137 break;
138
139 default:
140 $this->$cmd();
141 break;
142 }
143 }
144
145 public function setMessageBox(ILIAS\UI\Component\MessageBox\MessageBox $a_val): void
146 {
147 $this->mbox = $a_val;
148 }
149
150 public function getMessageBox(): ILIAS\UI\Component\MessageBox\MessageBox
151 {
152 return $this->mbox;
153 }
154
155
156 public function setTableClass(string $a_val): void
157 {
158 $this->table_class = $a_val;
159 }
160
161 public function getTableClass(): string
162 {
163 return $this->table_class;
164 }
165
166 public function enablePrivateNotes(bool $a_enable = true): void
167 {
168 $this->private_notes_enabled = $a_enable;
169 }
170
171 public function enableLearningProgress(bool $a_enable = true): void
172 {
173 $this->learning_progress_enabled = $a_enable;
174 }
175
176 public function enableAvailability(bool $a_enable = true): void
177 {
178 $this->availability_enabled = $a_enable;
179 }
180
181 public function enableBookingInfo(bool $a_enable = true): void
182 {
183 $this->booking_enabled = $a_enable;
184 }
185
186
187 public function enableFeedback(bool $a_enable = true): void
188 {
189 $this->feedback_enabled = $a_enable;
190 }
191
192 public function enableNews(bool $a_enable = true): void
193 {
194 $this->news_enabled = $a_enable;
195 }
196
197 public function enableNewsEditing(bool $a_enable = true): void
198 {
199 $this->news_editing = $a_enable;
200 }
201
206 public function setBlockProperty(string $a_block_type, string $a_property, string $a_value): void
207 {
208 $this->block_property[$a_block_type][$a_property] = $a_value;
209 }
210
211 public function getAllBlockProperties(): array
212 {
214 }
215
216 public function addSection(string $a_title): void
217 {
218 $this->sec_nr++;
219 $this->section[$this->sec_nr]["title"] = $a_title;
220 $this->section[$this->sec_nr]["hidden"] = $this->hidden;
221 }
222
223 public function setFormAction(string $a_form_action): void
224 {
225 $this->form_action = $a_form_action;
226 }
227
228 public function removeFormAction(): void
229 {
230 $this->form_action = "";
231 }
232
240 public function addProperty(string $a_name, string $a_value, string $a_link = ""): void
241 {
242 $this->section[$this->sec_nr]["properties"][] =
243 array("name" => $a_name, "value" => $a_value,
244 "link" => $a_link);
245 }
246
250 public function addPropertyCheckbox(
251 string $a_name,
252 string $a_checkbox_name,
253 string $a_checkbox_value,
254 string $a_checkbox_label = "",
255 bool $a_checkbox_checked = false
256 ): void {
257 $checkbox = "<input type=\"checkbox\" name=\"$a_checkbox_name\" value=\"$a_checkbox_value\" id=\"$a_checkbox_name$a_checkbox_value\"";
258 if ($a_checkbox_checked) {
259 $checkbox .= " checked=\"checked\"";
260 }
261 $checkbox .= " />";
262 if (strlen($a_checkbox_label)) {
263 $checkbox .= "&nbsp;<label for=\"$a_checkbox_name$a_checkbox_value\">$a_checkbox_label</label>";
264 }
265 $this->section[$this->sec_nr]["properties"][] =
266 array("name" => $a_name, "value" => $checkbox, "link" => "");
267 }
268
272 public function addPropertyTextinput(
273 string $a_name,
274 string $a_input_name,
275 string $a_input_value = "",
276 string $a_input_size = "",
277 string $direct_button_command = "",
278 string $direct_button_label = "",
279 bool $direct_button_primary = false
280 ): void {
281 $input = "<span class=\"form-inline\"><input class=\"form-control\" type=\"text\" name=\"$a_input_name\" id=\"$a_input_name\"";
282 if (strlen($a_input_value)) {
283 $input .= " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput($a_input_value) . "\"";
284 }
285 if (strlen($a_input_size)) {
286 $input .= " size=\"" . $a_input_size . "\"";
287 }
288 $input .= " />";
289 if (strlen($direct_button_command) && strlen($direct_button_label)) {
290 $css = "";
291 if ($direct_button_primary) {
292 $css = " btn-primary";
293 }
294 $input .= " <input type=\"submit\" class=\"btn btn-default" . $css . "\" name=\"cmd[$direct_button_command]\" value=\"$direct_button_label\" />";
295 }
296 $input .= "</span>";
297 $this->section[$this->sec_nr]["properties"][] =
298 array("name" => "<label for=\"$a_input_name\">$a_name</label>", "value" => $input);
299 }
300
304 public function addButton(
305 string $a_title,
306 string $a_link,
307 string $a_frame = "",
308 string $a_position = "top",
309 bool $a_primary = false
310 ): void {
311 if ($a_position == "top") {
312 $this->top_buttons[] =
313 array("title" => $a_title,"link" => $a_link,"target" => $a_frame,"primary" => $a_primary);
314 }
315 }
316
321 public function addFormButton(
322 string $a_command,
323 string $a_title,
324 string $a_position = "top"
325 ): void {
326 if ($a_position == "top") {
327 $this->top_formbuttons[] = array("command" => $a_command, "title" => $a_title);
328 }
329 }
330
331 public function addHiddenElement(string $a_name, string $a_value): void
332 {
333 $this->hiddenelements[] = array("name" => $a_name, "value" => $a_value);
334 }
335
336 public function addMetaDataSections(int $a_rep_obj_id, int $a_obj_id, string $a_type): void
337 {
339
340 $lng->loadLanguageModule("meta");
341
342 $md = new ilMD($a_rep_obj_id, $a_obj_id, $a_type);
343 $description = "";
344 $langs = '';
345 $keywords = "";
346 if ($md_gen = $md->getGeneral()) {
347 // get first descrption
348 // The description is shown on the top of the page.
349 // Thus it is not necessary to show it again.
350 foreach ($md_gen->getDescriptionIds() as $id) {
351 $md_des = $md_gen->getDescription($id);
352 $description = $md_des->getDescription();
353 break;
354 }
355
356 // get language(s)
357 $language_arr = [];
358 foreach ($md_gen->getLanguageIds() as $id) {
359 $md_lan = $md_gen->getLanguage($id);
360 if ($md_lan->getLanguageCode() != "") {
361 $language_arr[] = $lng->txt("meta_l_" . $md_lan->getLanguageCode());
362 }
363 }
364 $langs = implode(", ", $language_arr);
365
366 // keywords
367 $keyword_arr = [];
368 foreach ($md_gen->getKeywordIds() as $id) {
369 $md_key = $md_gen->getKeyword($id);
370 $keyword_arr[] = $md_key->getKeyword();
371 }
372 $keywords = implode(", ", $keyword_arr);
373 }
374
375 // authors
376 $author = "";
377 if (is_object($lifecycle = $md->getLifecycle())) {
378 $sep = "";
379 foreach (($lifecycle->getContributeIds()) as $con_id) {
380 $md_con = $lifecycle->getContribute($con_id);
381 if ($md_con->getRole() == "Author") {
382 foreach ($md_con->getEntityIds() as $ent_id) {
383 $md_ent = $md_con->getEntity($ent_id);
384 $author = $author . $sep . $md_ent->getEntity();
385 $sep = ", ";
386 }
387 }
388 }
389 }
390
391 // copyright
392 $copyright = "";
393 if (is_object($rights = $md->getRights())) {
394 $copyright = ilMDUtils::_parseCopyright($rights->getDescription());
395 } else {
396 $copyright = ilMDUtils::_getDefaultCopyright();
397 }
398
399 // learning time
400 #if(is_object($educational = $md->getEducational()))
401 #{
402 # $learning_time = $educational->getTypicalLearningTime();
403 #}
404 $learning_time = "";
405 if (is_object($educational = $md->getEducational())) {
406 if ($seconds = $educational->getTypicalLearningTimeSeconds()) {
407 $learning_time = ilDatePresentation::secondsToString($seconds);
408 }
409 }
410
411
412 // output
413
414 // description
415 if ($description != "") {
416 $this->addSection($lng->txt("description"));
417 $this->addProperty("", nl2br($description));
418 }
419
420 // general section
421 $this->addSection($lng->txt("meta_general"));
422 if ($langs != "") { // language
423 $this->addProperty(
424 $lng->txt("language"),
425 $langs
426 );
427 }
428 if ($keywords != "") { // keywords
429 $this->addProperty(
430 $lng->txt("keywords"),
431 $keywords
432 );
433 }
434 if ($author != "") { // author
435 $this->addProperty(
436 $lng->txt("author"),
437 $author
438 );
439 }
440 if ($copyright != "") { // copyright
441 $this->addProperty(
442 $lng->txt("meta_copyright"),
443 $copyright
444 );
445 }
446 if ($learning_time != "") { // typical learning time
447 $this->addProperty(
448 $lng->txt("meta_typical_learning_time"),
449 $learning_time
450 );
451 }
452 }
453
459 public function addObjectSections(): void
460 {
462 $ilCtrl = $this->ctrl;
463 $ilUser = $this->user;
464 $ilAccess = $this->access;
465 $tree = $this->tree;
466
467 // resource bookings
468 if ($this->booking_enabled) {
469 $booking_adapter = new ilBookingInfoScreenAdapter($this);
470 $booking_adapter->add();
471 }
472
473 $this->addSection($lng->txt("additional_info"));
474 $a_obj = $this->gui_object->getObject();
475
476 // links to the object
477 if (is_object($a_obj)) {
478 // permanent link
479 $type = $a_obj->getType();
480 $ref_id = $a_obj->getRefId();
481
482 if ($ref_id) {
483 if (ilECSServerSettings::getInstance()->activeServerExists()) {
484 $this->addProperty(
485 $lng->txt("object_id"),
486 (string) $a_obj->getId()
487 );
488 }
489
490 $this->tpl->setPermanentLink($type, $ref_id);
491
492 // links to resource
493 if ($ilAccess->checkAccess("write", "", $ref_id) ||
494 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
495 $obj_id = $a_obj->getId();
496 $rs = ilObject::_getAllReferences($obj_id);
497 $refs = array();
498 foreach ($rs as $r) {
499 if ($tree->isInTree($r)) {
500 $refs[] = $r;
501 }
502 }
503 if (count($refs) > 1) {
504 $links = $sep = "";
505 foreach ($refs as $r) {
506 $cont_loc = new ilLocatorGUI();
507 $cont_loc->addContextItems($r, true);
508 $links .= $sep . $cont_loc->getHTML();
509 $sep = "<br />";
510 }
511
512 $this->addProperty(
513 $lng->txt("res_links"),
514 '<div class="small">' . $links . '</div>'
515 );
516 }
517 }
518 }
519 }
520
521
522 // creation date
523 if ($ilAccess->checkAccess("write", "", $ref_id) ||
524 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
525
526 $this->addProperty(
527 $lng->txt("create_date"),
528 ilDatePresentation::formatDate(new ilDateTime($a_obj->getCreateDate(), IL_CAL_DATETIME))
529 );
530
531 // owner
532 if ($ilUser->getId() != ANONYMOUS_USER_ID and $a_obj->getOwner()) {
533 if (ilObjUser::userExists(array($a_obj->getOwner()))) {
535 $ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(), false);
536 } else {
537 $ownerObj = ilObjectFactory::getInstanceByObjId(6, false);
538 }
539
540 if (!is_object($ownerObj) || $ownerObj->getType() != "usr") { // root user deleted
541 $this->addProperty($lng->txt("owner"), $lng->txt("no_owner"));
542 } elseif ($ownerObj->hasPublicProfile()) {
543 $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $ownerObj->getId());
544 $this->addProperty(
545 $lng->txt("owner"),
546 $ownerObj->getPublicName(),
547 $ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML")
548 );
549 } else {
550 $this->addProperty($lng->txt("owner"), $ownerObj->getPublicName());
551 }
552 }
553
554 // change event
556 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
557 $readEvents = ilChangeEvent::_lookupReadEvents($a_obj->getId());
558 $count_users = 0;
559 $count_user_reads = 0;
560 $count_anonymous_reads = 0;
561 foreach ($readEvents as $evt) {
562 if ($evt['usr_id'] == ANONYMOUS_USER_ID) {
563 $count_anonymous_reads += $evt['read_count'];
564 } else {
565 $count_user_reads += $evt['read_count'];
566 $count_users++;
567 /* to do: if ($evt['user_id'] is member of $this->getRefId())
568 {
569 $count_members++;
570 }*/
571 }
572 }
573 if ($count_anonymous_reads > 0) {
574 $this->addProperty(
575 $this->lng->txt("readcount_anonymous_users"),
576 (string) $count_anonymous_reads
577 );
578 }
579 if ($count_user_reads > 0) {
580 $this->addProperty($this->lng->txt("readcount_users"), (string) $count_user_reads);
581 }
582 if ($count_users > 0) {
583 $this->addProperty($this->lng->txt("accesscount_registered_users"), (string) $count_users);
584 }
585 }
586 }
587 }
588
589 // WebDAV: Display locking information
591 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
592 $webdav_dic = new ilWebDAVDIC();
593 $webdav_dic->initWithoutDIC();
594 $webdav_lock_backend = $webdav_dic->locksbackend();
595 // Show lock info
596 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
597 if ($lock = $webdav_lock_backend->getLocksOnObjectId($this->gui_object->getObject()->getId())) {
599 $lock_user = new ilObjUser($lock->getIliasOwner());
600 $this->addProperty(
601 $this->lng->txt("in_use_by"),
602 $lock_user->getPublicName(),
603 "./ilias.php?user=" . $lock_user->getId() . '&cmd=showUserProfile&cmdClass=ildashboardgui&cmdNode=1&baseClass=ilDashboardGUI'
604 );
605 }
606 }
607 }
608 }
609 }
610 // END ChangeEvent: Display standard object info
611
618 public function showSummary(): void
619 {
621
622 $tpl->setContent($this->getCenterColumnHTML());
623 $tpl->setRightContent($this->getRightColumnHTML());
624 }
625
626
634 public function getCenterColumnHTML(): string
635 {
636 $ilCtrl = $this->ctrl;
637 $html = "";
638 $column_gui = new ilColumnGUI("info", IL_COL_CENTER);
639 $this->setColumnSettings($column_gui);
640
641 if (!$ilCtrl->isAsynch()) {
642 if ($column_gui->getScreenMode() != IL_SCREEN_SIDE) {
643 // right column wants center
644 if ($column_gui->getCmdSide() == IL_COL_RIGHT) {
645 $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
646 $this->setColumnSettings($column_gui);
647 $html = $ilCtrl->forwardCommand($column_gui);
648 }
649 // left column wants center
650 if ($column_gui->getCmdSide() == IL_COL_LEFT) {
651 $column_gui = new ilColumnGUI("info", IL_COL_LEFT);
652 $this->setColumnSettings($column_gui);
653 $html = $ilCtrl->forwardCommand($column_gui);
654 }
655 } else {
656 $html = $this->getHTML();
657 }
658 }
659
660 return $html;
661 }
662
667 public function getRightColumnHTML(): string
668 {
669 $ilCtrl = $this->ctrl;
670
671 $html = "";
672 $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
673 $this->setColumnSettings($column_gui);
674
675 if ($ilCtrl->getNextClass() == "ilcolumngui" &&
676 $column_gui->getCmdSide() == IL_COL_RIGHT &&
677 $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
678 $html = $ilCtrl->forwardCommand($column_gui);
679 } elseif (!$ilCtrl->isAsynch() && $this->news_enabled) {
680 $html = $ilCtrl->getHTML($column_gui);
681 }
682
683 return $html;
684 }
685
689 public function setColumnSettings(ilColumnGUI $column_gui): void
690 {
691 $column_gui->setEnableEdit($this->news_editing);
692 $column_gui->setRepositoryMode(true);
693 $column_gui->setAllBlockProperties($this->getAllBlockProperties());
694 }
695
696 public function setOpenFormTag(bool $a_val): void
697 {
698 $this->open_form_tag = $a_val;
699 }
700
701 public function setCloseFormTag(bool $a_val): void
702 {
703 $this->close_form_tag = $a_val;
704 }
705
713 public function getHTML(): string
714 {
717 $ilCtrl = $this->ctrl;
718 $ilUser = $this->user;
719
720 $tpl = new ilTemplate("tpl.infoscreen.html", true, true, "Services/InfoScreen");
721
722 // other class handles form action (@todo: this is not implemented/tested)
723 if ($this->form_action == "") {
724 $this->setFormAction($ilCtrl->getFormAction($this));
725 }
726
728
729 if ($this->hidden) {
730 $tpl->touchBlock("hidden_js");
731 if ($this->show_hidden_toggle) {
732 $this->addButton($lng->txt("show_hidden_sections"), "JavaScript:toggleSections(this, '" . $lng->txt("show_hidden_sections") . "', '" . $lng->txt("hide_visible_sections") . "');");
733 }
734 }
735
736
737 // DEPRECATED - use ilToolbarGUI
738
739 // add top buttons
740 if (count($this->top_buttons) > 0) {
741 $tpl->addBlockFile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html");
742
743 foreach ($this->top_buttons as $button) {
744 // view button
745 $tpl->setCurrentBlock("btn_cell");
746 $tpl->setVariable("BTN_LINK", $button["link"]);
747 $tpl->setVariable("BTN_TARGET", $button["target"]);
748 $tpl->setVariable("BTN_TXT", $button["title"]);
749 if ($button["primary"]) {
750 $tpl->setVariable("BTN_CLASS", " btn-primary");
751 }
752 $tpl->parseCurrentBlock();
753 }
754 }
755
756 // add top formbuttons
757 if ((count($this->top_formbuttons) > 0) && ($this->form_action !== '')) {
758 $tpl->addBlockFile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html", "Services/InfoScreen");
759
760 foreach ($this->top_formbuttons as $button) {
761 // view button
762 $tpl->setCurrentBlock("btn_submit_cell");
763 $tpl->setVariable("BTN_COMMAND", $button["command"]);
764 $tpl->setVariable("BTN_NAME", $button["title"]);
765 $tpl->parseCurrentBlock();
766 }
767 }
768
769 // add form action
770 if ($this->form_action != "") {
771 if ($this->open_form_tag) {
772 $tpl->setCurrentBlock("formtop");
773 $tpl->setVariable("FORMACTION", $this->form_action);
774 $tpl->parseCurrentBlock();
775 }
776
777 if ($this->close_form_tag) {
778 $tpl->touchBlock("formbottom");
779 }
780 }
781
782 if (count($this->hiddenelements)) {
783 foreach ($this->hiddenelements as $hidden) {
784 $tpl->setCurrentBlock("hidden_element");
785 $tpl->setVariable("HIDDEN_NAME", $hidden["name"]);
786 $tpl->setVariable("HIDDEN_VALUE", $hidden["value"]);
787 $tpl->parseCurrentBlock();
788 }
789 }
790
791 if ($this->availability_enabled) {
792 $this->addAvailability();
793 }
794
795 $this->addPreconditions();
796
797 // learning progress
798 if ($this->learning_progress_enabled) {
799 $this->showLearningProgress($tpl);
800 }
801
802 // notes section
803 if ($this->private_notes_enabled && !$ilSetting->get('disable_notes')) {
804 $html = $this->showNotesSection();
805 $tpl->setCurrentBlock("notes");
806 $tpl->setVariable("NOTES", $html);
807 $tpl->parseCurrentBlock();
808 }
809
810 // tagging
811 if (
812 isset($this->gui_object) &&
813 method_exists($this->gui_object, "getObject") &&
814 is_object($this->gui_object->getObject())
815 ) {
816 $tags_set = new ilSetting("tags");
817 if ($tags_set->get("enable") && $ilUser->getId() != ANONYMOUS_USER_ID) {
818 $this->addTagging();
819 }
820
821 $this->addObjectSections();
822 }
823
824 // render all sections
825 for ($i = 1; $i <= $this->sec_nr; $i++) {
826 if (isset($this->section[$i]["properties"])) {
827 // section properties
828 foreach ($this->section[$i]["properties"] as $property) {
829 if ($property["name"] != "") {
830 if (($property["link"] ?? "") == "") {
831 $tpl->setCurrentBlock("pv");
832 $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]);
833 } else {
834 $tpl->setCurrentBlock("lpv");
835 $tpl->setVariable("TXT_PROPERTY_LVALUE", $property["value"]);
836 $tpl->setVariable("LINK_PROPERTY_VALUE", $property["link"]);
837 }
838 $tpl->parseCurrentBlock();
839 $tpl->setCurrentBlock("property_row");
840 $tpl->setVariable("TXT_PROPERTY", $property["name"]);
841 } else {
842 $tpl->setCurrentBlock("property_full_row");
843 $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]);
844 }
845 $tpl->parseCurrentBlock();
846 }
847
848 // section header
849 if ($this->section[$i]["hidden"] ?? false) {
850 $tpl->setVariable("SECTION_HIDDEN", " style=\"display:none;\"");
851 $tpl->setVariable("SECTION_ID", "hidable_" . $i);
852 } else {
853 $tpl->setVariable("SECTION_ID", $i);
854 }
855 $tpl->setVariable("TCLASS", $this->getTableClass());
856 $tpl->setVariable("TXT_SECTION", $this->section[$i]["title"]);
857 $tpl->setCurrentBlock("row");
858 $tpl->parseCurrentBlock();
859 }
860 }
861
862 if (!is_null($this->mbox)) {
863 $tpl->setVariable("MBOX", $this->ui->renderer()->render([$this->mbox]));
864 }
865
866 return $tpl->get();
867 }
868
869 public function getContextRefId(): int
870 {
871 if ($this->contextRefId !== null) {
872 return $this->contextRefId;
873 }
874
875 return $this->gui_object->getObject()->getRefId();
876 }
877
878 public function setContextRefId(int $contextRefId): void
879 {
880 $this->contextRefId = $contextRefId;
881 }
882
883 public function getContextObjId(): int
884 {
885 if ($this->contextObjId !== null) {
886 return $this->contextObjId;
887 }
888
889 return $this->gui_object->getObject()->getId();
890 }
891
892 public function setContextObjId(int $contextObjId): void
893 {
894 $this->contextObjId = $contextObjId;
895 }
896
897 public function getContentObjType(): string
898 {
899 if ($this->contentObjType !== null) {
900 return $this->contentObjType;
901 }
902
903 return $this->gui_object->getObject()->getType();
904 }
905
906 public function setContentObjType(string $contentObjType): void
907 {
908 $this->contentObjType = $contentObjType;
909 }
910
915 public function showLearningProgress(ilTemplate $a_tpl): void
916 {
917 return;
918
919 $ilUser = $this->user;
920 $rbacsystem = $this->rbacsystem;
921
922 if (!$rbacsystem->checkAccess('read', $this->getContextRefId())) {
923 return;
924 }
925 if ($ilUser->getId() == ANONYMOUS_USER_ID) {
926 return;
927 }
928
930 return;
931 }
932
933 $olp = ilObjectLP::getInstance($this->getContextObjId());
934 if ($olp->getCurrentMode() != ilLPObjSettings::LP_MODE_MANUAL) {
935 return;
936 }
937
938 $this->lng->loadLanguageModule('trac');
939
940 // section header
941 // $a_tpl->setCurrentBlock("header_row");
942 $a_tpl->setVariable(
943 "TXT_SECTION",
944 $this->lng->txt('learning_progress')
945 );
946 $a_tpl->parseCurrentBlock();
947 }
948
949 public function saveProgress(bool $redirect = true): void
950 {
951 $ilUser = $this->user;
952
953 // ensure a read event
955 $ilUser->getId(),
956 $this->getContextObjId(),
957 $this->getContextRefId(),
958 ilObject::_lookupType($this->getContextObjId())
959 );
960
961 $lp_marks = new ilLPMarks($this->getContextObjId(), $ilUser->getId());
962 $lp_marks->setCompleted((bool) $this->request->getLPEdit());
963 $lp_marks->update();
964
965 ilLPStatusWrapper::_updateStatus($this->getContextObjId(), $ilUser->getId());
966
967 $this->lng->loadLanguageModule('trac');
968 $this->tpl->setOnScreenMessage('success', $this->lng->txt('trac_updated_status'), true);
969
970 if ($redirect) {
971 $this->ctrl->redirect($this, ""); // #14993
972 }
973 }
974
975
980 public function showNotesSection(): string
981 {
982 global $DIC;
983
984 $ilAccess = $this->access;
986 $DIC->notes()->gui()->initJavascript();
987
988 $next_class = $this->ctrl->getNextClass($this);
989 $notes_gui = new ilNoteGUI(
990 $this->gui_object->getObject()->getId(),
991 0,
992 $this->gui_object->getObject()->getType()
993 );
994 $notes_gui->setUseObjectTitleHeader(false);
995
996 // global switch
997 if ($ilSetting->get("disable_comments")) {
998 return "";
999 } else {
1000 $ref_id = $this->gui_object->getObject()->getRefId();
1001 $has_write = $ilAccess->checkAccess("write", "", $ref_id);
1002
1003 if ($has_write && $ilSetting->get("comments_del_tutor", "1")) {
1004 $notes_gui->enablePublicNotesDeletion();
1005 }
1006
1007 /* should probably be discussed further
1008 for now this will only work properly with comments settings
1009 (see ilNoteGUI constructor)
1010 */
1011 if ($has_write ||
1012 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
1013 $notes_gui->enableCommentsSettings();
1014 }
1015 }
1016
1017 /* moved to action menu
1018 $notes_gui->enablePrivateNotes();
1019 */
1020
1021 if ($next_class == "ilnotegui") {
1022 $html = $this->ctrl->forwardCommand($notes_gui);
1023 } else {
1024 $html = $notes_gui->getCommentsHTML();
1025 }
1026
1027 return $html;
1028 }
1029
1033 public function showLDAPRoleGroupMappingInfo(string $a_section = ''): void
1034 {
1035 if (strlen($a_section)) {
1036 $this->addSection($a_section);
1037 }
1038 $ldap_mapping = ilLDAPRoleGroupMapping::_getInstance();
1039 if ($infos = $ldap_mapping->getInfoStrings($this->gui_object->getObject()->getId())) {
1040 $info_combined = '<div style="color:green;">';
1041 $counter = 0;
1042 foreach ($infos as $info_string) {
1043 if ($counter++) {
1044 $info_combined .= '<br />';
1045 }
1046 $info_combined .= $info_string;
1047 }
1048 $info_combined .= '</div>';
1049 $this->addProperty($this->lng->txt('applications'), $info_combined);
1050 }
1051 }
1052
1053 public function setTabs(): void
1054 {
1055 $this->getTabs($this->tabs_gui);
1056 }
1057
1058 public function getTabs(ilTabsGUI $tabs_gui): void
1059 {
1060 $next_class = $this->ctrl->getNextClass($this);
1061 $force_active = ($next_class == "ilnotegui");
1062
1063 $tabs_gui->addSubTabTarget(
1064 'summary',
1065 $this->ctrl->getLinkTarget($this, "showSummary"),
1066 array("showSummary", ""),
1067 get_class($this),
1068 "",
1069 $force_active
1070 );
1071 }
1072
1073
1074 public function addTagging(): void
1075 {
1076 $lng = $this->lng;
1077
1078 $lng->loadLanguageModule("tagging");
1079 $tags_set = new ilSetting("tags");
1080
1081 $tagging_gui = new ilTaggingGUI();
1082 $tagging_gui->setObject(
1083 $this->gui_object->getObject()->getId(),
1084 $this->gui_object->getObject()->getType()
1085 );
1086
1087 $this->addSection($lng->txt("tagging_tags"));
1088
1089 if ($tags_set->get("enable_all_users")) {
1090 $this->addProperty(
1091 $lng->txt("tagging_all_users"),
1092 $tagging_gui->getAllUserTagsForObjectHTML()
1093 );
1094 }
1095
1096 $this->addProperty(
1097 $lng->txt("tagging_my_tags"),
1098 $tagging_gui->getTaggingInputHTML()
1099 );
1100 }
1101
1102 public function saveTags(): void
1103 {
1104 $tagging_gui = new ilTaggingGUI();
1105 $tagging_gui->setObject(
1106 $this->gui_object->getObject()->getId(),
1107 $this->gui_object->getObject()->getType()
1108 );
1109 $tagging_gui->saveInput();
1110
1111 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
1112 $this->ctrl->redirect($this, ""); // #14993
1113 }
1114
1115 public function hideFurtherSections(bool $a_add_toggle = true): void
1116 {
1117 $this->hidden = true;
1118 $this->show_hidden_toggle = $a_add_toggle;
1119 }
1120
1121 public function getHiddenToggleButton(): string
1122 {
1123 $lng = $this->lng;
1124
1125 return "<a onClick=\"toggleSections(this, '" . $lng->txt("show_hidden_sections") . "', '" . $lng->txt("hide_visible_sections") . "'); return false;\" href=\"#\">" . $lng->txt("show_hidden_sections") . "</a>";
1126 }
1127
1128
1133 protected function addAvailability(): void
1134 {
1135 if (
1136 !is_object($this->gui_object) ||
1137 !method_exists($this->gui_object, "getObject") ||
1138 !is_object($this->gui_object->getObject())
1139 ) {
1140 return;
1141 }
1142
1143 $obj = $this->gui_object->getObject();
1144 if ($obj->getRefId() <= 0) {
1145 return;
1146 }
1147
1148 $act = new ilObjectActivation();
1149 $act->read($obj->getRefId());
1150 if ($act->getTimingType() == ilObjectActivation::TIMINGS_ACTIVATION) {
1151 $this->lng->loadLanguageModule("rep");
1152 $this->addSection($this->lng->txt("rep_activation_availability"));
1153 $this->addAccessPeriodProperty();
1154 }
1155 }
1156
1160 protected function addPreconditions(): void
1161 {
1162 if (
1163 !is_object($this->gui_object) ||
1164 !method_exists($this->gui_object, "getObject") ||
1165 !is_object($this->gui_object->getObject())
1166 ) {
1167 return;
1168 }
1169
1170 $obj = $this->gui_object->getObject();
1171 if ($obj->getRefId() <= 0) {
1172 return;
1173 }
1174
1175 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($obj->getRefId(), $obj->getId());
1176
1177 if (sizeof($conditions)) {
1178 for ($i = 0; $i < count($conditions); $i++) {
1179 $conditions[$i]['title'] = ilObject::_lookupTitle($conditions[$i]['trigger_obj_id']);
1180 }
1181 $conditions = ilArrayUtil::sortArray($conditions, 'title', 'DESC');
1182
1183 // Show obligatory and optional preconditions seperated
1184 $this->addPreconditionSection($obj, $conditions, true);
1185 $this->addPreconditionSection($obj, $conditions, false);
1186 }
1187 }
1188
1189 protected function addPreconditionSection(
1190 ilObject $obj,
1191 array $conditions,
1192 bool $obligatory = true
1193 ): void {
1194 $lng = $this->lng;
1195 $tree = $this->tree;
1196
1198 $num_optional_required =
1199 $num_required - count($conditions) + count(ilConditionHandler::getEffectiveOptionalConditionsOfTarget($obj->getRefId(), $obj->getId()));
1200
1201 // Check if all conditions are fulfilled
1202 $visible_conditions = array();
1203 $passed_optional = 0;
1204 foreach ($conditions as $condition) {
1205 if ($obligatory and !$condition['obligatory']) {
1206 continue;
1207 }
1208 if (!$obligatory and $condition['obligatory']) {
1209 continue;
1210 }
1211
1212 if ($tree->isDeleted($condition['trigger_ref_id'])) {
1213 continue;
1214 }
1215
1216 $ok = ilConditionHandler::_checkCondition($condition) and
1217 !ilMemberViewSettings::getInstance()->isActive();
1218
1219 if (!$ok) {
1220 $visible_conditions[] = $condition['id'];
1221 }
1222
1223 if (!$obligatory and $ok) {
1224 ++$passed_optional;
1225 // optional passed
1226 if ($passed_optional >= $num_optional_required) {
1227 return;
1228 }
1229 }
1230 }
1231
1232 $properties = [];
1233
1234 foreach ($conditions as $condition) {
1235 if (!isset($condition["id"]) || !in_array($condition['id'], $visible_conditions)) {
1236 continue;
1237 }
1238
1239 $properties[] = [
1241 $condition['trigger_obj_id'],
1242 $condition['operator']
1243 ) . ' ' . $condition['value'],
1244 "title" => ilObject::_lookupTitle($condition['trigger_obj_id']),
1245 "link" => ilLink::_getLink($condition['trigger_ref_id'])
1246 ];
1247 }
1248
1249 if (count($properties) > 0) {
1250 if ($obligatory) {
1251 $this->addSection($lng->txt("preconditions_obligatory_hint"));
1252 } else {
1253 $this->addSection(sprintf(
1254 $lng->txt("preconditions_optional_hint"),
1255 $num_optional_required - $passed_optional
1256 ));
1257 }
1258
1259 foreach ($properties as $p) {
1260 $this->addProperty(
1261 $p["condition"],
1262 "<a href='" . $p["link"] . "'>" . ilUtil::stripSlashes($p["title"]) . "</a>"
1263 );
1264 }
1265 }
1266 }
1267
1272 public function addAccessPeriodProperty(): void
1273 {
1274 $a_obj = $this->gui_object->getObject();
1275
1276 $this->lng->loadLanguageModule("rep");
1277 $this->lng->loadLanguageModule("crs");
1278
1279 // links to the object
1280 if (is_object($a_obj)) {
1281 $act = new ilObjectActivation();
1282 $act->read($a_obj->getRefId());
1283 if ($act->getTimingType() == ilObjectActivation::TIMINGS_ACTIVATION) {
1284 $this->addProperty(
1285 $this->lng->txt('rep_activation_access'),
1287 new ilDateTime($act->getTimingStart(), IL_CAL_UNIX),
1288 new ilDateTime($act->getTimingEnd(), IL_CAL_UNIX)
1289 )
1290 );
1291 } else {
1292 $this->addProperty(
1293 $this->lng->txt('rep_activation_access'),
1294 $this->lng->txt('crs_visibility_limitless')
1295 );
1296 }
1297 }
1298 }
1299}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
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)
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 formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
static getInstance()
Get singleton instance.
setContent(string $a_html)
Sets content for standard template.
Class ilInfoScreenGUI.
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
addPropertyCheckbox(string $a_name, string $a_checkbox_name, string $a_checkbox_value, string $a_checkbox_label="", bool $a_checkbox_checked=false)
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)
@inheritDoc
enableAvailability(bool $a_enable=true)
hideFurtherSections(bool $a_add_toggle=true)
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...
static _parseCopyright(string $a_copyright)
static _getDefaultCopyright()
Notes GUI class.
User class.
static userExists(array $a_usr_ids=array())
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
Class ilTaggingGUI.
special template class to simplify handling of ITX/PEAR
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$ref_id
Definition: ltiauth.php:67
$i
Definition: metadata.php:41
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
global $ilSetting
Definition: privfeed.php:17
$type
$lng
catch(InvalidArgumentException $e) if(!ilDAVActivationChecker::_isActive()) $webdav_dic
Definition: webdav.php:55