ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilInfoScreenGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
19{
23 protected $tabs_gui;
24
28 protected $rbacsystem;
29
33 protected $tpl;
34
38 protected $access;
39
43 protected $user;
44
48 protected $tree;
49
53 protected $settings;
54
55 public $lng;
56 public $ctrl;
58 public $top_buttons = array();
59 public $top_formbuttons = array();
60 public $hiddenelements = array();
61 public $table_class = "il_InfoScreen";
62 public $open_form_tag = true;
63 public $close_form_tag = true;
64
68 protected $contextRefId = null;
69
73 protected $contextObjId = null;
74
78 protected $contentObjType = null;
79
84
88 protected $booking_enabled = false;
89
93 protected $availability_enabled = true;
94
95
102 public function __construct($a_gui_object)
103 {
104 global $DIC;
105
106 $this->rbacsystem = $DIC->rbac()->system();
107 $this->tpl = $DIC["tpl"];
108 $this->access = $DIC->access();
109 $this->user = $DIC->user();
110 $this->tree = $DIC->repositoryTree();
111 $this->settings = $DIC->settings();
112 $ilCtrl = $DIC->ctrl();
113 $lng = $DIC->language();
114 $ilTabs = $DIC->tabs();
115
116 $this->ctrl = $ilCtrl;
117 $this->lng = $lng;
118 $this->tabs_gui = $ilTabs;
119 $this->gui_object = $a_gui_object;
120 $this->sec_nr = 0;
121 $this->private_notes_enabled = false;
122 $this->news_enabled = false;
123 $this->feedback_enabled = false;
124 $this->learning_progress_enabled = false;
125 $this->form_action = "";
126 $this->top_formbuttons = array();
127 $this->hiddenelements = array();
128 }
129
133 public function executeCommand()
134 {
137 $ilAccess = $this->access;
138
139 $next_class = $this->ctrl->getNextClass($this);
140
141 $cmd = $this->ctrl->getCmd("showSummary");
142 $this->ctrl->setReturn($this, "showSummary");
143
144 $this->setTabs();
145
146 switch ($next_class) {
147 case "ilnotegui":
148 if ($this->ctrl->isAsynch()) {
149 $this->showNotesSection();
150 } else {
151 $this->showSummary(); // forwards command
152 }
153 break;
154
155 case "ilcolumngui":
156 $this->showSummary();
157 break;
158
159 case "ilpublicuserprofilegui":
160 include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
161 $user_profile = new ilPublicUserProfileGUI($_GET["user_id"]);
162 $user_profile->setBackUrl($this->ctrl->getLinkTarget($this, "showSummary"));
163 $html = $this->ctrl->forwardCommand($user_profile);
164 $tpl->setContent($html);
165 break;
166
167 case "ilcommonactiondispatchergui":
168 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
170 $this->ctrl->forwardCommand($gui);
171 break;
172
173 default:
174 return $this->$cmd();
175 break;
176 }
177 return true;
178 }
179
185 public function setTableClass($a_val)
186 {
187 $this->table_class = $a_val;
188 }
189
195 public function getTableClass()
196 {
197 return $this->table_class;
198 }
199
203 public function enablePrivateNotes($a_enable = true)
204 {
205 $this->private_notes_enabled = $a_enable;
206 }
207
211 public function enableLearningProgress($a_enable = true)
212 {
213 $this->learning_progress_enabled = $a_enable;
214 }
215
219 public function enableAvailability($a_enable = true)
220 {
221 $this->availability_enabled = $a_enable;
222 }
223
228 public function enableBookingInfo($a_enable = true)
229 {
230 $this->booking_enabled = $a_enable;
231 }
232
233
237 public function enableFeedback($a_enable = true)
238 {
239 $this->feedback_enabled = $a_enable;
240 }
241
245 public function enableNews($a_enable = true)
246 {
247 $this->news_enabled = $a_enable;
248 }
249
253 public function enableNewsEditing($a_enable = true)
254 {
255 $this->news_editing = $a_enable;
256 }
257
265 public function setBlockProperty($a_block_type, $a_property, $a_value)
266 {
267 $this->block_property[$a_block_type][$a_property] = $a_value;
268 }
269
270 public function getAllBlockProperties()
271 {
272 return $this->block_property;
273 }
274
278 public function addSection($a_title)
279 {
280 $this->sec_nr++;
281 $this->section[$this->sec_nr]["title"] = $a_title;
282 $this->section[$this->sec_nr]["hidden"] = (bool) $this->hidden;
283 }
284
288 public function setFormAction($a_form_action)
289 {
290 $this->form_action = $a_form_action;
291 }
292
296 public function removeFormAction()
297 {
298 $this->form_action = "";
299 }
300
308 public function addProperty($a_name, $a_value, $a_link = "")
309 {
310 $this->section[$this->sec_nr]["properties"][] =
311 array("name" => $a_name, "value" => $a_value,
312 "link" => $a_link);
313 }
314
318 public function addPropertyCheckbox($a_name, $a_checkbox_name, $a_checkbox_value, $a_checkbox_label = "", $a_checkbox_checked = false)
319 {
320 $checkbox = "<input type=\"checkbox\" name=\"$a_checkbox_name\" value=\"$a_checkbox_value\" id=\"$a_checkbox_name$a_checkbox_value\"";
321 if ($a_checkbox_checked) {
322 $checkbox .= " checked=\"checked\"";
323 }
324 $checkbox .= " />";
325 if (strlen($a_checkbox_label)) {
326 $checkbox .= "&nbsp;<label for=\"$a_checkbox_name$a_checkbox_value\">$a_checkbox_label</label>";
327 }
328 $this->section[$this->sec_nr]["properties"][] =
329 array("name" => $a_name, "value" => $checkbox);
330 }
331
335 public function addPropertyTextinput($a_name, $a_input_name, $a_input_value = "", $a_input_size = "", $direct_button_command = "", $direct_button_label = "", $direct_button_primary = false)
336 {
337 $input = "<span class=\"form-inline\"><input class=\"form-control\" type=\"text\" name=\"$a_input_name\" id=\"$a_input_name\"";
338 if (strlen($a_input_value)) {
339 $input .= " value=\"" . ilUtil::prepareFormOutput($a_input_value) . "\"";
340 }
341 if (strlen($a_input_size)) {
342 $input .= " size=\"" . $a_input_size . "\"";
343 }
344 $input .= " />";
345 if (strlen($direct_button_command) && strlen($direct_button_label)) {
346 $css = "";
347 if ($direct_button_primary) {
348 $css = " btn-primary";
349 }
350 $input .= " <input type=\"submit\" class=\"btn btn-default" . $css . "\" name=\"cmd[$direct_button_command]\" value=\"$direct_button_label\" />";
351 }
352 $input .= "</span>";
353 $this->section[$this->sec_nr]["properties"][] =
354 array("name" => "<label for=\"$a_input_name\">$a_name</label>", "value" => $input);
355 }
356
360 public function addButton($a_title, $a_link, $a_frame = "", $a_position = "top", $a_primary = false)
361 {
362 if ($a_position == "top") {
363 $this->top_buttons[] =
364 array("title" => $a_title,"link" => $a_link,"target" => $a_frame,"primary" => $a_primary);
365 }
366 }
367
372 public function addFormButton($a_command, $a_title, $a_position = "top")
373 {
374 if ($a_position == "top") {
375 array_push(
376 $this->top_formbuttons,
377 array("command" => $a_command, "title" => $a_title)
378 );
379 }
380 }
381
382 public function addHiddenElement($a_name, $a_value)
383 {
384 array_push($this->hiddenelements, array("name" => $a_name, "value" => $a_value));
385 }
386
390 public function addMetaDataSections($a_rep_obj_id, $a_obj_id, $a_type)
391 {
393
394 $lng->loadLanguageModule("meta");
395
396 include_once("./Services/MetaData/classes/class.ilMD.php");
397 $md = new ilMD($a_rep_obj_id, $a_obj_id, $a_type);
398
399 if ($md_gen = $md->getGeneral()) {
400 // get first descrption
401 // The description is shown on the top of the page.
402 // Thus it is not necessary to show it again.
403 foreach ($md_gen->getDescriptionIds() as $id) {
404 $md_des = $md_gen->getDescription($id);
405 $description = $md_des->getDescription();
406 break;
407 }
408
409 // get language(s)
410 $langs = array();
411 foreach ($ids = $md_gen->getLanguageIds() as $id) {
412 $md_lan = $md_gen->getLanguage($id);
413 if ($md_lan->getLanguageCode() != "") {
414 $langs[] = $lng->txt("meta_l_" . $md_lan->getLanguageCode());
415 }
416 }
417 $langs = implode(", ", $langs);
418
419 // keywords
420 $keywords = array();
421 foreach ($ids = $md_gen->getKeywordIds() as $id) {
422 $md_key = $md_gen->getKeyword($id);
423 $keywords[] = $md_key->getKeyword();
424 }
425 $keywords = implode(", ", $keywords);
426 }
427
428 // authors
429 if (is_object($lifecycle = $md->getLifecycle())) {
430 $sep = $author = "";
431 foreach (($ids = $lifecycle->getContributeIds()) as $con_id) {
432 $md_con = $lifecycle->getContribute($con_id);
433 if ($md_con->getRole() == "Author") {
434 foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
435 $md_ent = $md_con->getEntity($ent_id);
436 $author = $author . $sep . $md_ent->getEntity();
437 $sep = ", ";
438 }
439 }
440 }
441 }
442
443 // copyright
444 $copyright = "";
445 if (is_object($rights = $md->getRights())) {
446 include_once('Services/MetaData/classes/class.ilMDUtils.php');
447 $copyright = ilMDUtils::_parseCopyright($rights->getDescription());
448 } else {
449 $copyright = ilMDUtils::_getDefaultCopyright();
450 }
451
452 // learning time
453 #if(is_object($educational = $md->getEducational()))
454 #{
455 # $learning_time = $educational->getTypicalLearningTime();
456 #}
457 $learning_time = "";
458 if (is_object($educational = $md->getEducational())) {
459 if ($seconds = $educational->getTypicalLearningTimeSeconds()) {
460 $learning_time = ilDatePresentation::secondsToString($seconds);
461 }
462 }
463
464
465 // output
466
467 // description
468 if ($description != "") {
469 $this->addSection($lng->txt("description"));
470 $this->addProperty("", nl2br($description));
471 }
472
473 // general section
474 $this->addSection($lng->txt("meta_general"));
475 if ($langs != "") { // language
476 $this->addProperty(
477 $lng->txt("language"),
478 $langs
479 );
480 }
481 if ($keywords != "") { // keywords
482 $this->addProperty(
483 $lng->txt("keywords"),
484 $keywords
485 );
486 }
487 if ($author != "") { // author
488 $this->addProperty(
489 $lng->txt("author"),
490 $author
491 );
492 }
493 if ($copyright != "") { // copyright
494 $this->addProperty(
495 $lng->txt("meta_copyright"),
496 $copyright
497 );
498 }
499 if ($learning_time != "") { // typical learning time
500 $this->addProperty(
501 $lng->txt("meta_typical_learning_time"),
502 $learning_time
503 );
504 }
505 }
506
510 public function addObjectSections()
511 {
513 $ilCtrl = $this->ctrl;
515 $ilAccess = $this->access;
517
518 // ressource bookings
519 if ($this->booking_enabled) {
520 $booking_adapter = new ilBookingInfoScreenAdapter($this);
521 $booking_adapter->add();
522 }
523
524 $this->addSection($lng->txt("additional_info"));
525 $a_obj = $this->gui_object->object;
526
527 // links to the object
528 if (is_object($a_obj)) {
529 // permanent link
530 $type = $a_obj->getType();
531 $ref_id = $a_obj->getRefId();
532
533 if ($ref_id) {
534 include_once 'Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
535 if (ilECSServerSettings::getInstance()->activeServerExists()) {
536 $this->addProperty(
537 $lng->txt("object_id"),
538 $a_obj->getId()
539 );
540 }
541
542 include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
543 $pm = new ilPermanentLinkGUI($type, $ref_id);
544 $pm->setIncludePermanentLinkText(false);
545 $pm->setAlignCenter(false);
546 $this->addProperty(
547 $lng->txt("perma_link"),
548 $pm->getHTML(),
549 ""
550 );
551
552 // links to resource
553 if ($ilAccess->checkAccess("write", "", $ref_id) ||
554 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
555 $obj_id = $a_obj->getId();
556 $rs = ilObject::_getAllReferences($obj_id);
557 $refs = array();
558 foreach ($rs as $r) {
559 if ($tree->isInTree($r)) {
560 $refs[] = $r;
561 }
562 }
563 if (count($refs) > 1) {
564 $links = $sep = "";
565 foreach ($refs as $r) {
566 $cont_loc = new ilLocatorGUI();
567 $cont_loc->addContextItems($r, true);
568 $links .= $sep . $cont_loc->getHTML();
569 $sep = "<br />";
570 }
571
572 $this->addProperty(
573 $lng->txt("res_links"),
574 '<div class="small">' . $links . '</div>'
575 );
576 }
577 }
578 }
579 }
580
581 if ($ilAccess->checkAccess("write", "", $ref_id) ||
582 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
583
584 // creation date
585 $this->addProperty(
586 $lng->txt("create_date"),
587 ilDatePresentation::formatDate(new ilDateTime($a_obj->getCreateDate(), IL_CAL_DATETIME))
588 );
589
590 // owner
591 if ($ilUser->getId() != ANONYMOUS_USER_ID and $a_obj->getOwner()) {
592 include_once './Services/Object/classes/class.ilObjectFactory.php';
593 include_once './Services/User/classes/class.ilObjUser.php';
594
595 if (ilObjUser::userExists(array($a_obj->getOwner()))) {
596 $ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(), false);
597 } else {
598 $ownerObj = ilObjectFactory::getInstanceByObjId(6, false);
599 }
600
601 if (!is_object($ownerObj) || $ownerObj->getType() != "usr") { // root user deleted
602 $this->addProperty($lng->txt("owner"), $lng->txt("no_owner"));
603 } elseif ($ownerObj->hasPublicProfile()) {
604 $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $ownerObj->getId());
605 $this->addProperty(
606 $lng->txt("owner"),
607 $ownerObj->getPublicName(),
608 $ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML")
609 );
610 } else {
611 $this->addProperty($lng->txt("owner"), $ownerObj->getPublicName());
612 }
613 }
614
615 // change event
616 require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
618 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
619 $readEvents = ilChangeEvent::_lookupReadEvents($a_obj->getId());
620 $count_users = 0;
621 $count_members = 0;
622 $count_user_reads = 0;
623 $count_anonymous_reads = 0;
624 foreach ($readEvents as $evt) {
625 if ($evt['usr_id'] == ANONYMOUS_USER_ID) {
626 $count_anonymous_reads += $evt['read_count'];
627 } else {
628 $count_user_reads += $evt['read_count'];
629 $count_users++;
630 /* to do: if ($evt['user_id'] is member of $this->getRefId())
631 {
632 $count_members++;
633 }*/
634 }
635 }
636 if ($count_anonymous_reads > 0) {
637 $this->addProperty($this->lng->txt("readcount_anonymous_users"), $count_anonymous_reads);
638 }
639 if ($count_user_reads > 0) {
640 $this->addProperty($this->lng->txt("readcount_users"), $count_user_reads);
641 }
642 if ($count_users > 0) {
643 $this->addProperty($this->lng->txt("accesscount_registered_users"), $count_users);
644 }
645 }
646 }
647 // END ChangeEvent: Display change event info
648 }
649
650 // WebDAV: Display locking information
651 require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
653 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
654 require_once 'Services/WebDAV/classes/lock/class.ilWebDAVLockBackend.php';
655 $webdav_lock_backend = new ilWebDAVLockBackend();
656
657 // Show lock info
658 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
659 if ($lock = $webdav_lock_backend->getLocksOnObjectId($this->gui_object->object->getId())) {
660 $lock_user = new ilObjUser($lock->getIliasOwner());
661 $this->addProperty(
662 $this->lng->txt("in_use_by"),
663 $lock_user->getPublicName(),
664 "./ilias.php?user=" . $lock_user->getId() . '&cmd=showUserProfile&cmdClass=ildashboardgui&cmdNode=1&baseClass=ilDashboardGUI'
665 );
666 }
667 }
668 }
669 }
670 }
671 // END ChangeEvent: Display standard object info
675 public function showSummary()
676 {
678 $ilAccess = $this->access;
679
680 $tpl->setContent($this->getCenterColumnHTML());
681 $tpl->setRightContent($this->getRightColumnHTML());
682 }
683
684
688 public function getCenterColumnHTML()
689 {
690 $ilCtrl = $this->ctrl;
691
692 include_once("Services/Block/classes/class.ilColumnGUI.php");
693 $column_gui = new ilColumnGUI("info", IL_COL_CENTER);
694 $this->setColumnSettings($column_gui);
695
696 if (!$ilCtrl->isAsynch()) {
697 if ($column_gui->getScreenMode() != IL_SCREEN_SIDE) {
698 // right column wants center
699 if ($column_gui->getCmdSide() == IL_COL_RIGHT) {
700 $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
701 $this->setColumnSettings($column_gui);
702 $html = $ilCtrl->forwardCommand($column_gui);
703 }
704 // left column wants center
705 if ($column_gui->getCmdSide() == IL_COL_LEFT) {
706 $column_gui = new ilColumnGUI("info", IL_COL_LEFT);
707 $this->setColumnSettings($column_gui);
708 $html = $ilCtrl->forwardCommand($column_gui);
709 }
710 } else {
711 $html = $this->getHTML();
712 }
713 }
714
715 return $html;
716 }
717
721 public function getRightColumnHTML()
722 {
725 $ilCtrl = $this->ctrl;
726
727 include_once("Services/Block/classes/class.ilColumnGUI.php");
728 $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
729 $this->setColumnSettings($column_gui);
730
731 if ($ilCtrl->getNextClass() == "ilcolumngui" &&
732 $column_gui->getCmdSide() == IL_COL_RIGHT &&
733 $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
734 $html = $ilCtrl->forwardCommand($column_gui);
735 } else {
736 if (!$ilCtrl->isAsynch()) {
737 if ($this->news_enabled) {
738 $html = $ilCtrl->getHTML($column_gui);
739 }
740 }
741 }
742
743 return $html;
744 }
745
749 public function setColumnSettings($column_gui)
750 {
752 $ilAccess = $this->access;
753
754 $column_gui->setEnableEdit($this->news_editing);
755 $column_gui->setRepositoryMode(true);
756 $column_gui->setAllBlockProperties($this->getAllBlockProperties());
757 }
758
759 public function setOpenFormTag($a_val)
760 {
761 $this->open_form_tag = $a_val;
762 }
763
764 public function setCloseFormTag($a_val)
765 {
766 $this->close_form_tag = $a_val;
767 }
768
772 public function getHTML()
773 {
777 $ilAccess = $this->access;
778 $ilCtrl = $this->ctrl;
780
781 $tpl = new ilTemplate("tpl.infoscreen.html", true, true, "Services/InfoScreen");
782
783 // other class handles form action (@todo: this is not implemented/tested)
784 if ($this->form_action == "") {
785 $this->setFormAction($ilCtrl->getFormAction($this));
786 }
787
788 require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
790
791 if ($this->hidden) {
792 $tpl->touchBlock("hidden_js");
793 if ($this->show_hidden_toggle) {
794 $this->addButton($lng->txt("show_hidden_sections"), "JavaScript:toggleSections(this, '" . $lng->txt("show_hidden_sections") . "', '" . $lng->txt("hide_visible_sections") . "');");
795 }
796 }
797
798
799 // DEPRECATED - use ilToolbarGUI
800
801 // add top buttons
802 if (count($this->top_buttons) > 0) {
803 $tpl->addBlockfile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html");
804
805 foreach ($this->top_buttons as $button) {
806 // view button
807 $tpl->setCurrentBlock("btn_cell");
808 $tpl->setVariable("BTN_LINK", $button["link"]);
809 $tpl->setVariable("BTN_TARGET", $button["target"]);
810 $tpl->setVariable("BTN_TXT", $button["title"]);
811 if ($button["primary"]) {
812 $tpl->setVariable("BTN_CLASS", " btn-primary");
813 }
814 $tpl->parseCurrentBlock();
815 }
816 }
817
818 // add top formbuttons
819 if ((count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0)) {
820 $tpl->addBlockfile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html", "Services/InfoScreen");
821
822 foreach ($this->top_formbuttons as $button) {
823 // view button
824 $tpl->setCurrentBlock("btn_submit_cell");
825 $tpl->setVariable("BTN_COMMAND", $button["command"]);
826 $tpl->setVariable("BTN_NAME", $button["title"]);
827 $tpl->parseCurrentBlock();
828 }
829 }
830
831 // add form action
832 if (strlen($this->form_action) > 0) {
833 if ($this->open_form_tag) {
834 $tpl->setCurrentBlock("formtop");
835 $tpl->setVariable("FORMACTION", $this->form_action);
836 $tpl->parseCurrentBlock();
837 }
838
839 if ($this->close_form_tag) {
840 $tpl->touchBlock("formbottom");
841 }
842 }
843
844 if (count($this->hiddenelements)) {
845 foreach ($this->hiddenelements as $hidden) {
846 $tpl->setCurrentBlock("hidden_element");
847 $tpl->setVariable("HIDDEN_NAME", $hidden["name"]);
848 $tpl->setVariable("HIDDEN_VALUE", $hidden["value"]);
849 $tpl->parseCurrentBlock();
850 }
851 }
852
853 if ($this->availability_enabled) {
854 $this->addAvailability();
855 }
856
857 $this->addPreconditions();
858
859 // learning progress
860 if ($this->learning_progress_enabled and $html = $this->showLearningProgress($tpl)) {
861 $tpl->setCurrentBlock("learning_progress");
862 $tpl->setVariable("LP_TABLE", $html);
863 $tpl->parseCurrentBlock();
864 }
865
866 // notes section
867 if ($this->private_notes_enabled && !$ilSetting->get('disable_notes')) {
868 $html = $this->showNotesSection();
869 $tpl->setCurrentBlock("notes");
870 $tpl->setVariable("NOTES", $html);
871 $tpl->parseCurrentBlock();
872 }
873
874 // tagging
875 if (is_object($this->gui_object->object)) {
876 $tags_set = new ilSetting("tags");
877 if ($tags_set->get("enable") && $ilUser->getId() != ANONYMOUS_USER_ID) {
878 $this->addTagging();
879 }
880 }
881
882 if (is_object($this->gui_object->object)) {
883 $this->addObjectSections();
884 }
885
886 // render all sections
887 for ($i = 1; $i <= $this->sec_nr; $i++) {
888 if (is_array($this->section[$i]["properties"])) {
889 // section properties
890 foreach ($this->section[$i]["properties"] as $property) {
891 if ($property["name"] != "") {
892 if ($property["link"] == "") {
893 $tpl->setCurrentBlock("pv");
894 $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]);
895 $tpl->parseCurrentBlock();
896 } else {
897 $tpl->setCurrentBlock("lpv");
898 $tpl->setVariable("TXT_PROPERTY_LVALUE", $property["value"]);
899 $tpl->setVariable("LINK_PROPERTY_VALUE", $property["link"]);
900 $tpl->parseCurrentBlock();
901 }
902 $tpl->setCurrentBlock("property_row");
903 $tpl->setVariable("TXT_PROPERTY", $property["name"]);
904 $tpl->parseCurrentBlock();
905 } else {
906 $tpl->setCurrentBlock("property_full_row");
907 $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]);
908 $tpl->parseCurrentBlock();
909 }
910 }
911
912 // section header
913 if ($this->section[$i]["hidden"]) {
914 $tpl->setVariable("SECTION_HIDDEN", " style=\"display:none;\"");
915 $tpl->setVariable("SECTION_ID", "hidable_" . $i);
916 } else {
917 $tpl->setVariable("SECTION_ID", $i);
918 }
919 $tpl->setVariable("TCLASS", $this->getTableClass());
920 $tpl->setVariable("TXT_SECTION", $this->section[$i]["title"]);
921 $tpl->setCurrentBlock("row");
922 $tpl->parseCurrentBlock();
923 }
924 }
925
926 return $tpl->get();
927 }
928
932 public function getContextRefId() : int
933 {
934 if ($this->contextRefId !== null) {
935 return $this->contextRefId;
936 }
937
938 return $this->gui_object->object->getRefId();
939 }
940
944 public function setContextRefId(int $contextRefId)
945 {
946 $this->contextRefId = $contextRefId;
947 }
948
952 public function getContextObjId() : int
953 {
954 if ($this->contextObjId !== null) {
955 return $this->contextObjId;
956 }
957
958 return $this->gui_object->object->getId();
959 }
960
964 public function setContextObjId(int $contextObjId)
965 {
966 $this->contextObjId = $contextObjId;
967 }
968
972 public function getContentObjType() : string
973 {
974 if ($this->contentObjType !== null) {
976 }
977
978 return $this->gui_object->object->getType();
979 }
980
984 public function setContentObjType(string $contentObjType)
985 {
986 $this->contentObjType = $contentObjType;
987 }
988
989 public function showLearningProgress($a_tpl)
990 {
993
994 if (!$rbacsystem->checkAccess('read', $this->getContextRefId())) {
995 return false;
996 }
997 if ($ilUser->getId() == ANONYMOUS_USER_ID) {
998 return false;
999 }
1000
1001 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
1003 return false;
1004 }
1005
1006 include_once './Services/Object/classes/class.ilObjectLP.php';
1008 if ($olp->getCurrentMode() != ilLPObjSettings::LP_MODE_MANUAL) {
1009 return false;
1010 }
1011
1012 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
1013
1014 $this->lng->loadLanguageModule('trac');
1015
1016 // section header
1017 // $a_tpl->setCurrentBlock("header_row");
1018 $a_tpl->setVariable(
1019 "TXT_SECTION",
1020 $this->lng->txt('learning_progress')
1021 );
1022 $a_tpl->parseCurrentBlock();
1023 // $a_tpl->touchBlock("row");
1024
1025 // status
1026 $i_tpl = new ilTemplate("tpl.lp_edit_manual_info_page.html", true, true, "Services/Tracking");
1027 $i_tpl->setVariable("INFO_EDITED", $this->lng->txt("trac_info_edited"));
1028 $i_tpl->setVariable("SELECT_STATUS", ilUtil::formSelect(
1030 $ilUser->getId(),
1031 $this->getContextObjId()
1032 ),
1033 'lp_edit',
1034 array(0 => $this->lng->txt('trac_not_completed'),
1035 1 => $this->lng->txt('trac_completed')),
1036 false,
1037 true
1038 ));
1039 $i_tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1040 $a_tpl->setCurrentBlock("pv");
1041 $a_tpl->setVariable("TXT_PROPERTY_VALUE", $i_tpl->get());
1042 $a_tpl->parseCurrentBlock();
1043 $a_tpl->setCurrentBlock("property_row");
1044 $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_status'));
1045 $a_tpl->parseCurrentBlock();
1046 // $a_tpl->touchBlock("row");
1047
1048
1049 // More infos for lm's
1050 if ($this->getContentObjType() == 'lm' ||
1051 $this->getContentObjType() == 'htlm') {
1052 $a_tpl->setCurrentBlock("pv");
1053
1054 include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
1055 $progress = ilLearningProgress::_getProgress($ilUser->getId(), $this->getContextObjId());
1056 if ($progress['access_time']) {
1057 $a_tpl->setVariable(
1058 "TXT_PROPERTY_VALUE",
1059 ilDatePresentation::formatDate(new ilDateTime($progress['access_time'], IL_CAL_UNIX))
1060 );
1061 } else {
1062 $a_tpl->setVariable(
1063 "TXT_PROPERTY_VALUE",
1064 $this->lng->txt('trac_not_accessed')
1065 );
1066 }
1067
1068 $a_tpl->parseCurrentBlock();
1069 $a_tpl->setCurrentBlock("property_row");
1070 $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_last_access'));
1071 $a_tpl->parseCurrentBlock();
1072 // $a_tpl->touchBlock("row");
1073
1074 // tags of all users
1075 $a_tpl->setCurrentBlock("pv");
1076 $a_tpl->setVariable(
1077 "TXT_PROPERTY_VALUE",
1078 (int) $progress['visits']
1079 );
1080 $a_tpl->parseCurrentBlock();
1081 $a_tpl->setCurrentBlock("property_row");
1082 $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_visits'));
1083 $a_tpl->parseCurrentBlock();
1084 // $a_tpl->touchBlock("row");
1085
1086
1087 if ($this->getContentObjType() == 'lm') {
1088 // tags of all users
1089 $a_tpl->setCurrentBlock("pv");
1090 $a_tpl->setVariable(
1091 "TXT_PROPERTY_VALUE",
1092 ilDatePresentation::secondsToString($progress['spent_seconds'])
1093 );
1094 $a_tpl->parseCurrentBlock();
1095 $a_tpl->setCurrentBlock("property_row");
1096 $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_spent_time'));
1097 $a_tpl->parseCurrentBlock();
1098 // $a_tpl->touchBlock("row");
1099 }
1100 }
1101
1102 // #10493
1103 $a_tpl->touchBlock("row");
1104 }
1105
1106 public function saveProgress($redirect = true)
1107 {
1109
1110 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
1111
1112 $lp_marks = new ilLPMarks($this->getContextObjId(), $ilUser->getId());
1113 $lp_marks->setCompleted((bool) $_POST['lp_edit']);
1114 $lp_marks->update();
1115
1116 require_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
1118
1119 $this->lng->loadLanguageModule('trac');
1120 ilUtil::sendSuccess($this->lng->txt('trac_updated_status'), true);
1121
1122 if ($redirect) {
1123 $this->ctrl->redirect($this, ""); // #14993
1124 }
1125 }
1126
1127
1131 public function showNotesSection()
1132 {
1133 $ilAccess = $this->access;
1135
1136 $next_class = $this->ctrl->getNextClass($this);
1137 include_once("Services/Notes/classes/class.ilNoteGUI.php");
1138 $notes_gui = new ilNoteGUI(
1139 $this->gui_object->object->getId(),
1140 0,
1141 $this->gui_object->object->getType()
1142 );
1143
1144 // global switch
1145 if ($ilSetting->get("disable_comments")) {
1146 $notes_gui->enablePublicNotes(false);
1147 } else {
1148 $ref_id = $this->gui_object->object->getRefId();
1149 $has_write = $ilAccess->checkAccess("write", "", $ref_id);
1150
1151 if ($has_write && $ilSetting->get("comments_del_tutor", 1)) {
1152 $notes_gui->enablePublicNotesDeletion(true);
1153 }
1154
1155 /* should probably be discussed further
1156 for now this will only work properly with comments settings
1157 (see ilNoteGUI constructor)
1158 */
1159 if ($has_write ||
1160 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
1161 $notes_gui->enableCommentsSettings();
1162 }
1163 }
1164
1165 /* moved to action menu
1166 $notes_gui->enablePrivateNotes();
1167 */
1168
1169 if ($next_class == "ilnotegui") {
1170 $html = $this->ctrl->forwardCommand($notes_gui);
1171 } else {
1172 $html = $notes_gui->getNotesHTML();
1173 }
1174
1175 return $html;
1176 }
1177
1185 public function showLDAPRoleGroupMappingInfo($a_section = '')
1186 {
1187 if (strlen($a_section)) {
1188 $this->addSection($a_section);
1189 }
1190 include_once('Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1191 $ldap_mapping = ilLDAPRoleGroupMapping::_getInstance();
1192 if ($infos = $ldap_mapping->getInfoStrings($this->gui_object->object->getId())) {
1193 $info_combined = '<div style="color:green;">';
1194 $counter = 0;
1195 foreach ($infos as $info_string) {
1196 if ($counter++) {
1197 $info_combined .= '<br />';
1198 }
1199 $info_combined .= $info_string;
1200 }
1201 $info_combined .= '</div>';
1202 $this->addProperty($this->lng->txt('applications'), $info_combined);
1203 }
1204 return true;
1205 }
1206
1207 public function setTabs()
1208 {
1209 $tpl = $this->tpl;
1210
1211 $this->getTabs($this->tabs_gui);
1212 }
1213
1217 public function getTabs(&$tabs_gui)
1218 {
1221 $ilAccess = $this->access;
1222
1223 $next_class = $this->ctrl->getNextClass($this);
1224 $force_active = ($next_class == "ilnotegui")
1225 ? true
1226 : false;
1227
1228 $tabs_gui->addSubTabTarget(
1229 'summary',
1230 $this->ctrl->getLinkTarget($this, "showSummary"),
1231 array("showSummary", ""),
1232 get_class($this),
1233 "",
1234 $force_active
1235 );
1236 }
1237
1238
1242 public function addTagging()
1243 {
1244 $lng = $this->lng;
1245 $ilCtrl = $this->ctrl;
1246
1247 $lng->loadLanguageModule("tagging");
1248 $tags_set = new ilSetting("tags");
1249
1250 include_once("Services/Tagging/classes/class.ilTaggingGUI.php");
1251 $tagging_gui = new ilTaggingGUI();
1252 $tagging_gui->setObject(
1253 $this->gui_object->object->getId(),
1254 $this->gui_object->object->getType()
1255 );
1256
1257 $this->addSection($lng->txt("tagging_tags"));
1258
1259 if ($tags_set->get("enable_all_users")) {
1260 $this->addProperty(
1261 $lng->txt("tagging_all_users"),
1262 $tagging_gui->getAllUserTagsForObjectHTML()
1263 );
1264 }
1265
1266 $this->addProperty(
1267 $lng->txt("tagging_my_tags"),
1268 $tagging_gui->getTaggingInputHTML()
1269 );
1270 }
1271
1272 public function saveTags()
1273 {
1274 include_once("Services/Tagging/classes/class.ilTaggingGUI.php");
1275 $tagging_gui = new ilTaggingGUI();
1276 $tagging_gui->setObject(
1277 $this->gui_object->object->getId(),
1278 $this->gui_object->object->getType()
1279 );
1280 $tagging_gui->saveInput();
1281
1282 ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
1283 $this->ctrl->redirect($this, ""); // #14993
1284
1285 // return $this->showSummary();
1286 }
1287
1288 public function hideFurtherSections($a_add_toggle = true)
1289 {
1290 $this->hidden = true;
1291 $this->show_hidden_toggle = (bool) $a_add_toggle;
1292 }
1293
1294 public function getHiddenToggleButton()
1295 {
1296 $lng = $this->lng;
1297
1298 return "<a onClick=\"toggleSections(this, '" . $lng->txt("show_hidden_sections") . "', '" . $lng->txt("hide_visible_sections") . "'); return false;\" href=\"#\">" . $lng->txt("show_hidden_sections") . "</a>";
1299 }
1300
1301
1305 protected function addAvailability()
1306 {
1307 if (!is_object($this->gui_object) || !is_object($this->gui_object->object)) {
1308 return;
1309 }
1310
1311 $obj = $this->gui_object->object;
1312 if ($obj->getRefId() <= 0) {
1313 return;
1314 }
1315
1316 $act = new ilObjectActivation();
1317 $act->read($obj->getRefId());
1318 if ($act->getTimingType() == ilObjectActivation::TIMINGS_ACTIVATION) {
1319 $this->lng->loadLanguageModule("rep");
1320 $this->addSection($this->lng->txt("rep_activation_availability"));
1321 $this->addAccessPeriodProperty();
1322 }
1323 }
1324
1328 protected function addPreconditions()
1329 {
1330 if (!is_object($this->gui_object) || !is_object($this->gui_object->object)) {
1331 return;
1332 }
1333
1334 $obj = $this->gui_object->object;
1335 if ($obj->getRefId() <= 0) {
1336 return;
1337 }
1338
1339 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($obj->getRefId(), $obj->getId());
1340
1341 if (sizeof($conditions)) {
1342 for ($i = 0; $i < count($conditions); $i++) {
1343 $conditions[$i]['title'] = ilObject::_lookupTitle($conditions[$i]['trigger_obj_id']);
1344 }
1345 $conditions = ilUtil::sortArray($conditions, 'title', 'DESC');
1346
1347 // Show obligatory and optional preconditions seperated
1348 $this->addPreconditionSection($obj, $conditions, true);
1349 $this->addPreconditionSection($obj, $conditions, false);
1350 }
1351 }
1352
1353 protected function addPreconditionSection($obj, $conditions, $obligatory = true)
1354 {
1355 $lng = $this->lng;
1357
1358 $num_required = ilConditionHandler::calculateEffectiveRequiredTriggers($obj->getRefId(), $obj->getId());
1359 $num_optional_required =
1360 $num_required - count($conditions) + count(ilConditionHandler::getEffectiveOptionalConditionsOfTarget($obj->getRefId(), $obj->getId()));
1361
1362 // Check if all conditions are fullfilled
1363 $visible_conditions = array();
1364 $passed_optional = 0;
1365 foreach ($conditions as $condition) {
1366 if ($obligatory and !$condition['obligatory']) {
1367 continue;
1368 }
1369 if (!$obligatory and $condition['obligatory']) {
1370 continue;
1371 }
1372
1373 if ($tree->isDeleted($condition['trigger_ref_id'])) {
1374 continue;
1375 }
1376
1378 !ilMemberViewSettings::getInstance()->isActive();
1379
1380 if (!$ok) {
1381 $visible_conditions[] = $condition['id'];
1382 }
1383
1384 if (!$obligatory and $ok) {
1385 ++$passed_optional;
1386 // optional passed
1387 if ($passed_optional >= $num_optional_required) {
1388 return true;
1389 }
1390 }
1391 }
1392
1393 $properties = [];
1394
1395 foreach ($conditions as $condition) {
1396 if (!in_array($condition['id'], $visible_conditions)) {
1397 continue;
1398 }
1399
1400 $missing_cond_exist = true;
1401
1402 $properties[] = [
1404 $condition['trigger_obj_id'],
1405 $condition['operator']
1406 ) . ' ' . $condition['value'],
1407 "title" => ilObject::_lookupTitle($condition['trigger_obj_id']),
1408 "link" => ilLink::_getLink($condition['trigger_ref_id'])
1409 ];
1410 }
1411
1412 if (count($properties) > 0) {
1413 if ($obligatory) {
1414 $this->addSection($lng->txt("preconditions_obligatory_hint"));
1415 } else {
1416 $this->addSection(sprintf($lng->txt("preconditions_optional_hint"), $num_optional_required));
1417 }
1418
1419 foreach ($properties as $p) {
1420 $this->addProperty(
1421 $p["condition"],
1422 "<a href='" . $p["link"] . "'>" . ilUtil::stripSlashes($p["title"]) . "</a>"
1423 );
1424 }
1425 }
1426 }
1427
1431 public function addAccessPeriodProperty() : void
1432 {
1433 $a_obj = $this->gui_object->object;
1434
1435 $this->lng->loadLanguageModule("rep");
1436 $this->lng->loadLanguageModule("crs");
1437
1438 // links to the object
1439 if (is_object($a_obj)) {
1440 $act = new ilObjectActivation();
1441 $act->read($a_obj->getRefId());
1442 if ($act->getTimingType() == ilObjectActivation::TIMINGS_ACTIVATION) {
1443 $this->addProperty(
1444 $this->lng->txt('rep_activation_access'),
1446 new ilDateTime($act->getTimingStart(), IL_CAL_UNIX),
1447 new ilDateTime($act->getTimingEnd(), IL_CAL_UNIX)
1448 )
1449 );
1450 } else {
1451 $this->addProperty(
1452 $this->lng->txt('rep_activation_access'),
1453 $this->lng->txt('crs_visibility_limitless')
1454 );
1455 }
1456 }
1457 }
1458}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_SIDE
const IL_COL_RIGHT
const IL_COL_CENTER
const IL_COL_LEFT
const IL_CAL_UNIX
const IL_CAL_DATETIME
Embeds booking information into info screen.
static _lookupReadEvents($obj_id, $usr_id=null)
Reads all read events which occured on the object which happened after the last time the user caught ...
static _isActive()
Returns true, if change event tracking is active.
Column user interface class.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static translateOperator($a_obj_id, $a_operator)
Translate operator.
static _checkCondition($condition, $a_usr_id=0)
checks wether a single condition is fulfilled every trigger object type must implement a static metho...
static getEffectiveOptionalConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_obj_type='')
Get optional conditions.
static calculateEffectiveRequiredTriggers($a_target_ref_id, $a_target_obj_id, $a_target_obj_type='')
calculate number of obligatory items
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
@classDescription Date and time handling
static getInstance()
Get singleton instance.
Class ilInfoScreenGUI.
enableBookingInfo($a_enable=true)
booking info
showLDAPRoleGroupMappingInfo($a_section='')
show LDAP role group mapping info
__construct($a_gui_object)
Constructor.
removeFormAction()
remove form action
addObjectSections()
add standard object section
getRightColumnHTML()
Display right column.
setFormAction($a_form_action)
set a form action
enableNewsEditing($a_enable=true)
enable news editing
addButton($a_title, $a_link, $a_frame="", $a_position="top", $a_primary=false)
add a property to current section
setBlockProperty($a_block_type, $a_property, $a_value)
This function is supposed to be used for block type specific properties, that should be passed to ilB...
enableAvailability($a_enable=true)
enable availability
addPropertyTextinput($a_name, $a_input_name, $a_input_value="", $a_input_size="", $direct_button_command="", $direct_button_label="", $direct_button_primary=false)
add a property to current section
addAvailability()
Add preconditions.
executeCommand()
execute command
$form_action
a form action parameter.
showSummary()
show summary page
getCenterColumnHTML()
Display center column.
hideFurtherSections($a_add_toggle=true)
addPreconditionSection($obj, $conditions, $obligatory=true)
enableFeedback($a_enable=true)
enable feedback
setTableClass($a_val)
Set table class.
addHiddenElement($a_name, $a_value)
enablePrivateNotes($a_enable=true)
enable notes
getTabs(&$tabs_gui)
get tabs
enableLearningProgress($a_enable=true)
enable learning progress
showNotesSection()
show notes section
addFormButton($a_command, $a_title, $a_position="top")
add a form button to the info screen the form buttons are only valid if a form action is set
setContextObjId(int $contextObjId)
setColumnSettings($column_gui)
Set column settings.
addAccessPeriodProperty()
Add access period property.
addPropertyCheckbox($a_name, $a_checkbox_name, $a_checkbox_value, $a_checkbox_label="", $a_checkbox_checked=false)
add a property to current section
enableNews($a_enable=true)
enable news
setContextRefId(int $contextRefId)
addPreconditions()
Add preconditions.
addProperty($a_name, $a_value, $a_link="")
add a property to current section
getTableClass()
Get table class.
addMetaDataSections($a_rep_obj_id, $a_obj_id, $a_type)
add standard meta data sections
saveProgress($redirect=true)
setContentObjType(string $contentObjType)
addSection($a_title)
add a new section
static _getInstance()
Get singleton instance of this class.
static _hasCompleted($a_usr_id, $a_obj_id)
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _getProgress($a_user_id, $a_obj_id)
locator handling class
static _parseCopyright($a_copyright)
Parse copyright.
static _getDefaultCopyright()
Notes GUI class.
static _enabledLearningProgress()
check wether learing progress is enabled or not
static userExists($a_usr_ids=array())
Class ilObjectActivation.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstance($a_obj_id)
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
Class for permanent links.
GUI class for public user profile presentation.
ILIAS Setting Class.
Class ilTaggingGUI.
special template class to simplify handling of ITX/PEAR
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
Class ilWebDAVLockBackend.
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:25
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
$i
Definition: metadata.php:24
global $ilSetting
Definition: privfeed.php:17
$type
settings()
Definition: settings.php:2