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