ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
91 public function __construct($a_gui_object)
92 {
93 global $DIC;
94
95 $this->rbacsystem = $DIC->rbac()->system();
96 $this->tpl = $DIC["tpl"];
97 $this->access = $DIC->access();
98 $this->user = $DIC->user();
99 $this->tree = $DIC->repositoryTree();
100 $this->settings = $DIC->settings();
101 $ilCtrl = $DIC->ctrl();
102 $lng = $DIC->language();
103 $ilTabs = $DIC->tabs();
104
105 $this->ctrl = $ilCtrl;
106 $this->lng = $lng;
107 $this->tabs_gui = $ilTabs;
108 $this->gui_object = $a_gui_object;
109 $this->sec_nr = 0;
110 $this->private_notes_enabled = false;
111 $this->news_enabled = false;
112 $this->feedback_enabled = false;
113 $this->learning_progress_enabled = false;
114 $this->form_action = "";
115 $this->top_formbuttons = array();
116 $this->hiddenelements = array();
117 }
118
122 public function executeCommand()
123 {
126 $ilAccess = $this->access;
127
128 $next_class = $this->ctrl->getNextClass($this);
129
130 $cmd = $this->ctrl->getCmd("showSummary");
131 $this->ctrl->setReturn($this, "showSummary");
132
133 $this->setTabs();
134
135 switch ($next_class) {
136 case "ilnotegui":
137 $this->showSummary(); // forwards command
138 break;
139
140 case "ilcolumngui":
141 $this->showSummary();
142 break;
143
144 case "ilpublicuserprofilegui":
145 include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
146 $user_profile = new ilPublicUserProfileGUI($_GET["user_id"]);
147 $user_profile->setBackUrl($this->ctrl->getLinkTarget($this, "showSummary"));
148 $html = $this->ctrl->forwardCommand($user_profile);
149 $tpl->setContent($html);
150 break;
151
152 case "ilcommonactiondispatchergui":
153 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
155 $this->ctrl->forwardCommand($gui);
156 break;
157
158 default:
159 return $this->$cmd();
160 break;
161 }
162 return true;
163 }
164
170 public function setTableClass($a_val)
171 {
172 $this->table_class = $a_val;
173 }
174
180 public function getTableClass()
181 {
182 return $this->table_class;
183 }
184
188 public function enablePrivateNotes($a_enable = true)
189 {
190 $this->private_notes_enabled = $a_enable;
191 }
192
196 public function enableLearningProgress($a_enable = true)
197 {
198 $this->learning_progress_enabled = $a_enable;
199 }
200
201
205 public function enableFeedback($a_enable = true)
206 {
207 $this->feedback_enabled = $a_enable;
208 }
209
213 public function enableNews($a_enable = true)
214 {
215 $this->news_enabled = $a_enable;
216 }
217
221 public function enableNewsEditing($a_enable = true)
222 {
223 $this->news_editing = $a_enable;
224 }
225
233 public function setBlockProperty($a_block_type, $a_property, $a_value)
234 {
235 $this->block_property[$a_block_type][$a_property] = $a_value;
236 }
237
238 public function getAllBlockProperties()
239 {
240 return $this->block_property;
241 }
242
246 public function addSection($a_title)
247 {
248 $this->sec_nr++;
249 $this->section[$this->sec_nr]["title"] = $a_title;
250 $this->section[$this->sec_nr]["hidden"] = (bool) $this->hidden;
251 }
252
256 public function setFormAction($a_form_action)
257 {
258 $this->form_action = $a_form_action;
259 }
260
264 public function removeFormAction()
265 {
266 $this->form_action = "";
267 }
268
276 public function addProperty($a_name, $a_value, $a_link = "")
277 {
278 $this->section[$this->sec_nr]["properties"][] =
279 array("name" => $a_name, "value" => $a_value,
280 "link" => $a_link);
281 }
282
286 public function addPropertyCheckbox($a_name, $a_checkbox_name, $a_checkbox_value, $a_checkbox_label = "", $a_checkbox_checked = false)
287 {
288 $checkbox = "<input type=\"checkbox\" name=\"$a_checkbox_name\" value=\"$a_checkbox_value\" id=\"$a_checkbox_name$a_checkbox_value\"";
289 if ($a_checkbox_checked) {
290 $checkbox .= " checked=\"checked\"";
291 }
292 $checkbox .= " />";
293 if (strlen($a_checkbox_label)) {
294 $checkbox .= "&nbsp;<label for=\"$a_checkbox_name$a_checkbox_value\">$a_checkbox_label</label>";
295 }
296 $this->section[$this->sec_nr]["properties"][] =
297 array("name" => $a_name, "value" => $checkbox);
298 }
299
303 public function addPropertyTextinput($a_name, $a_input_name, $a_input_value = "", $a_input_size = "", $direct_button_command = "", $direct_button_label = "", $direct_button_primary = false)
304 {
305 $input = "<span class=\"form-inline\"><input class=\"form-control\" type=\"text\" name=\"$a_input_name\" id=\"$a_input_name\"";
306 if (strlen($a_input_value)) {
307 $input .= " value=\"" . ilUtil::prepareFormOutput($a_input_value) . "\"";
308 }
309 if (strlen($a_input_size)) {
310 $input .= " size=\"" . $a_input_size . "\"";
311 }
312 $input .= " />";
313 if (strlen($direct_button_command) && strlen($direct_button_label)) {
314 $css = "";
315 if ($direct_button_primary) {
316 $css = " btn-primary";
317 }
318 $input .= " <input type=\"submit\" class=\"btn btn-default" . $css . "\" name=\"cmd[$direct_button_command]\" value=\"$direct_button_label\" />";
319 }
320 $input .= "</span>";
321 $this->section[$this->sec_nr]["properties"][] =
322 array("name" => "<label for=\"$a_input_name\">$a_name</label>", "value" => $input);
323 }
324
328 public function addButton($a_title, $a_link, $a_frame = "", $a_position = "top", $a_primary = false)
329 {
330 if ($a_position == "top") {
331 $this->top_buttons[] =
332 array("title" => $a_title,"link" => $a_link,"target" => $a_frame,"primary" => $a_primary);
333 }
334 }
335
340 public function addFormButton($a_command, $a_title, $a_position = "top")
341 {
342 if ($a_position == "top") {
343 array_push(
344 $this->top_formbuttons,
345 array("command" => $a_command, "title" => $a_title)
346 );
347 }
348 }
349
350 public function addHiddenElement($a_name, $a_value)
351 {
352 array_push($this->hiddenelements, array("name" => $a_name, "value" => $a_value));
353 }
354
358 public function addMetaDataSections($a_rep_obj_id, $a_obj_id, $a_type)
359 {
361
362 $lng->loadLanguageModule("meta");
363
364 include_once("./Services/MetaData/classes/class.ilMD.php");
365 $md = new ilMD($a_rep_obj_id, $a_obj_id, $a_type);
366
367 if ($md_gen = $md->getGeneral()) {
368 // get first descrption
369 // The description is shown on the top of the page.
370 // Thus it is not necessary to show it again.
371 foreach ($md_gen->getDescriptionIds() as $id) {
372 $md_des = $md_gen->getDescription($id);
373 $description = $md_des->getDescription();
374 break;
375 }
376
377 // get language(s)
378 $langs = array();
379 foreach ($ids = $md_gen->getLanguageIds() as $id) {
380 $md_lan = $md_gen->getLanguage($id);
381 if ($md_lan->getLanguageCode() != "") {
382 $langs[] = $lng->txt("meta_l_" . $md_lan->getLanguageCode());
383 }
384 }
385 $langs = implode($langs, ", ");
386
387 // keywords
388 $keywords = array();
389 foreach ($ids = $md_gen->getKeywordIds() as $id) {
390 $md_key = $md_gen->getKeyword($id);
391 $keywords[] = $md_key->getKeyword();
392 }
393 $keywords = implode($keywords, ", ");
394 }
395
396 // authors
397 if (is_object($lifecycle = $md->getLifecycle())) {
398 $sep = $author = "";
399 foreach (($ids = $lifecycle->getContributeIds()) as $con_id) {
400 $md_con = $lifecycle->getContribute($con_id);
401 if ($md_con->getRole() == "Author") {
402 foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
403 $md_ent = $md_con->getEntity($ent_id);
404 $author = $author . $sep . $md_ent->getEntity();
405 $sep = ", ";
406 }
407 }
408 }
409 }
410
411 // copyright
412 $copyright = "";
413 if (is_object($rights = $md->getRights())) {
414 include_once('Services/MetaData/classes/class.ilMDUtils.php');
415 $copyright = ilMDUtils::_parseCopyright($rights->getDescription());
416 }
417
418 // learning time
419 #if(is_object($educational = $md->getEducational()))
420 #{
421 # $learning_time = $educational->getTypicalLearningTime();
422 #}
423 $learning_time = "";
424 if (is_object($educational = $md->getEducational())) {
425 if ($seconds = $educational->getTypicalLearningTimeSeconds()) {
426 $learning_time = ilDatePresentation::secondsToString($seconds);
427 }
428 }
429
430
431 // output
432
433 // description
434 if ($description != "") {
435 $this->addSection($lng->txt("description"));
436 $this->addProperty("", nl2br($description));
437 }
438
439 // general section
440 $this->addSection($lng->txt("meta_general"));
441 if ($langs != "") { // language
442 $this->addProperty(
443 $lng->txt("language"),
444 $langs
445 );
446 }
447 if ($keywords != "") { // keywords
448 $this->addProperty(
449 $lng->txt("keywords"),
450 $keywords
451 );
452 }
453 if ($author != "") { // author
454 $this->addProperty(
455 $lng->txt("author"),
456 $author
457 );
458 }
459 if ($copyright != "") { // copyright
460 $this->addProperty(
461 $lng->txt("meta_copyright"),
462 $copyright
463 );
464 }
465 if ($learning_time != "") { // typical learning time
466 $this->addProperty(
467 $lng->txt("meta_typical_learning_time"),
468 $learning_time
469 );
470 }
471 }
472
476 public function addObjectSections()
477 {
481 $ilAccess = $this->access;
483
484 $this->addSection($lng->txt("additional_info"));
485 $a_obj = $this->gui_object->object;
486
487 // links to the object
488 if (is_object($a_obj)) {
489 // permanent link
490 $type = $a_obj->getType();
491 $ref_id = $a_obj->getRefId();
492
493 if ($ref_id) {
494 include_once 'Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
495 if (ilECSServerSettings::getInstance()->activeServerExists()) {
496 $this->addProperty(
497 $lng->txt("object_id"),
498 $a_obj->getId()
499 );
500 }
501
502 include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
503 $pm = new ilPermanentLinkGUI($type, $ref_id);
504 $pm->setIncludePermanentLinkText(false);
505 $pm->setAlignCenter(false);
506 $this->addProperty(
507 $lng->txt("perma_link"),
508 $pm->getHTML(),
509 ""
510 );
511
512 // bookmarks
513
514 // links to resource
515 if ($ilAccess->checkAccess("write", "", $ref_id) ||
516 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
517 $obj_id = $a_obj->getId();
518 $rs = ilObject::_getAllReferences($obj_id);
519 $refs = array();
520 foreach ($rs as $r) {
521 if ($tree->isInTree($r)) {
522 $refs[] = $r;
523 }
524 }
525 if (count($refs) > 1) {
526 $links = $sep = "";
527 foreach ($refs as $r) {
528 $cont_loc = new ilLocatorGUI();
529 $cont_loc->addContextItems($r, true);
530 $links .= $sep . $cont_loc->getHTML();
531 $sep = "<br />";
532 }
533
534 $this->addProperty(
535 $lng->txt("res_links"),
536 '<div class="small">' . $links . '</div>'
537 );
538 }
539 }
540 }
541 }
542
543
544 // creation date
545 $this->addProperty(
546 $lng->txt("create_date"),
547 ilDatePresentation::formatDate(new ilDateTime($a_obj->getCreateDate(), IL_CAL_DATETIME))
548 );
549
550 // owner
551 if ($ilUser->getId() != ANONYMOUS_USER_ID and $a_obj->getOwner()) {
552 include_once './Services/Object/classes/class.ilObjectFactory.php';
553 include_once './Services/User/classes/class.ilObjUser.php';
554
555 if (ilObjUser::userExists(array($a_obj->getOwner()))) {
556 $ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(), false);
557 } else {
558 $ownerObj = ilObjectFactory::getInstanceByObjId(6, false);
559 }
560
561 if (!is_object($ownerObj) || $ownerObj->getType() != "usr") { // root user deleted
562 $this->addProperty($lng->txt("owner"), $lng->txt("no_owner"));
563 } elseif ($ownerObj->hasPublicProfile()) {
564 $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $ownerObj->getId());
565 $this->addProperty($lng->txt("owner"), $ownerObj->getPublicName(), $ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML"));
566 } else {
567 $this->addProperty($lng->txt("owner"), $ownerObj->getPublicName());
568 }
569 }
570
571 // disk usage
572 require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
573 if ($ilUser->getId() != ANONYMOUS_USER_ID &&
575 $size = $a_obj->getDiskUsage();
576 if ($size !== null) {
577 $this->addProperty($lng->txt("disk_usage"), ilUtil::formatSize($size, 'long'));
578 }
579 }
580 // change event
581 require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
583 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
584 $readEvents = ilChangeEvent::_lookupReadEvents($a_obj->getId());
585 $count_users = 0;
586 $count_members = 0;
587 $count_user_reads = 0;
588 $count_anonymous_reads = 0;
589 foreach ($readEvents as $evt) {
590 if ($evt['usr_id'] == ANONYMOUS_USER_ID) {
591 $count_anonymous_reads += $evt['read_count'];
592 } else {
593 $count_user_reads += $evt['read_count'];
594 $count_users++;
595 /* to do: if ($evt['user_id'] is member of $this->getRefId())
596 {
597 $count_members++;
598 }*/
599 }
600 }
601 if ($count_anonymous_reads > 0) {
602 $this->addProperty($this->lng->txt("readcount_anonymous_users"), $count_anonymous_reads);
603 }
604 if ($count_user_reads > 0) {
605 $this->addProperty($this->lng->txt("readcount_users"), $count_user_reads);
606 }
607 if ($count_users > 0) {
608 $this->addProperty($this->lng->txt("accesscount_registered_users"), $count_users);
609 }
610 }
611 }
612 // END ChangeEvent: Display change event info
613
614 // WebDAV: Display locking information
615 require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
617 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
618 require_once 'Services/WebDAV/classes/lock/class.ilWebDAVLockBackend.php';
619 $webdav_lock_backend = new ilWebDAVLockBackend();
620
621 // Show lock info
622 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
623 if ($lock = $webdav_lock_backend->getLocksOnObjectId($this->gui_object->object->getId())) {
624 $lock_user = new ilObjUser($lock->getIliasOwner());
625 $this->addProperty(
626 $this->lng->txt("in_use_by"),
627 $lock_user->getPublicName(),
628 "./ilias.php?user=" . $lock_user->getId() . '&cmd=showUserProfile&cmdClass=ilpersonaldesktopgui&cmdNode=1&baseClass=ilPersonalDesktopGUI'
629 );
630 }
631 }
632 }
633 }
634 }
635 // END ChangeEvent: Display standard object info
639 public function showSummary()
640 {
642 $ilAccess = $this->access;
643
644 $tpl->setContent($this->getCenterColumnHTML());
645 $tpl->setRightContent($this->getRightColumnHTML());
646 }
647
648
652 public function getCenterColumnHTML()
653 {
655
656 include_once("Services/Block/classes/class.ilColumnGUI.php");
657 $column_gui = new ilColumnGUI("info", IL_COL_CENTER);
658 $this->setColumnSettings($column_gui);
659
660 if (!$ilCtrl->isAsynch()) {
661 if ($column_gui->getScreenMode() != IL_SCREEN_SIDE) {
662 // right column wants center
663 if ($column_gui->getCmdSide() == IL_COL_RIGHT) {
664 $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
665 $this->setColumnSettings($column_gui);
666 $html = $ilCtrl->forwardCommand($column_gui);
667 }
668 // left column wants center
669 if ($column_gui->getCmdSide() == IL_COL_LEFT) {
670 $column_gui = new ilColumnGUI("info", IL_COL_LEFT);
671 $this->setColumnSettings($column_gui);
672 $html = $ilCtrl->forwardCommand($column_gui);
673 }
674 } else {
675 $html = $this->getHTML();
676 }
677 }
678
679 return $html;
680 }
681
685 public function getRightColumnHTML()
686 {
690
691 include_once("Services/Block/classes/class.ilColumnGUI.php");
692 $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
693 $this->setColumnSettings($column_gui);
694
695 if ($ilCtrl->getNextClass() == "ilcolumngui" &&
696 $column_gui->getCmdSide() == IL_COL_RIGHT &&
697 $column_gui->getScreenMode() == IL_SCREEN_SIDE) {
698 $html = $ilCtrl->forwardCommand($column_gui);
699 } else {
700 if (!$ilCtrl->isAsynch()) {
701 if ($this->news_enabled) {
702 $html = $ilCtrl->getHTML($column_gui);
703 }
704 }
705 }
706
707 return $html;
708 }
709
713 public function setColumnSettings($column_gui)
714 {
716 $ilAccess = $this->access;
717
718 $column_gui->setEnableEdit($this->news_editing);
719 $column_gui->setRepositoryMode(true);
720 $column_gui->setAllBlockProperties($this->getAllBlockProperties());
721 }
722
723 public function setOpenFormTag($a_val)
724 {
725 $this->open_form_tag = $a_val;
726 }
727
728 public function setCloseFormTag($a_val)
729 {
730 $this->close_form_tag = $a_val;
731 }
732
736 public function getHTML()
737 {
741 $ilAccess = $this->access;
744
745 $tpl = new ilTemplate("tpl.infoscreen.html", true, true, "Services/InfoScreen");
746
747 // other class handles form action (@todo: this is not implemented/tested)
748 if ($this->form_action == "") {
749 $this->setFormAction($ilCtrl->getFormAction($this));
750 }
751
752 require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
754
755 if ($this->hidden) {
756 $tpl->touchBlock("hidden_js");
757 if ($this->show_hidden_toggle) {
758 $this->addButton($lng->txt("show_hidden_sections"), "JavaScript:toggleSections(this, '" . $lng->txt("show_hidden_sections") . "', '" . $lng->txt("hide_visible_sections") . "');");
759 }
760 }
761
762
763 // DEPRECATED - use ilToolbarGUI
764
765 // add top buttons
766 if (count($this->top_buttons) > 0) {
767 $tpl->addBlockfile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html");
768
769 foreach ($this->top_buttons as $button) {
770 // view button
771 $tpl->setCurrentBlock("btn_cell");
772 $tpl->setVariable("BTN_LINK", $button["link"]);
773 $tpl->setVariable("BTN_TARGET", $button["target"]);
774 $tpl->setVariable("BTN_TXT", $button["title"]);
775 if ($button["primary"]) {
776 $tpl->setVariable("BTN_CLASS", " btn-primary");
777 }
778 $tpl->parseCurrentBlock();
779 }
780 }
781
782 // add top formbuttons
783 if ((count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0)) {
784 $tpl->addBlockfile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html", "Services/InfoScreen");
785
786 foreach ($this->top_formbuttons as $button) {
787 // view button
788 $tpl->setCurrentBlock("btn_submit_cell");
789 $tpl->setVariable("BTN_COMMAND", $button["command"]);
790 $tpl->setVariable("BTN_NAME", $button["title"]);
791 $tpl->parseCurrentBlock();
792 }
793 }
794
795 // add form action
796 if (strlen($this->form_action) > 0) {
797 if ($this->open_form_tag) {
798 $tpl->setCurrentBlock("formtop");
799 $tpl->setVariable("FORMACTION", $this->form_action);
800 $tpl->parseCurrentBlock();
801 }
802
803 if ($this->close_form_tag) {
804 $tpl->touchBlock("formbottom");
805 }
806 }
807
808 if (count($this->hiddenelements)) {
809 foreach ($this->hiddenelements as $hidden) {
810 $tpl->setCurrentBlock("hidden_element");
811 $tpl->setVariable("HIDDEN_NAME", $hidden["name"]);
812 $tpl->setVariable("HIDDEN_VALUE", $hidden["value"]);
813 $tpl->parseCurrentBlock();
814 }
815 }
816
817 $this->addPreconditions();
818
819 // learning progress
820 if ($this->learning_progress_enabled and $html = $this->showLearningProgress($tpl)) {
821 $tpl->setCurrentBlock("learning_progress");
822 $tpl->setVariable("LP_TABLE", $html);
823 $tpl->parseCurrentBlock();
824 }
825
826 // notes section
827 if ($this->private_notes_enabled && !$ilSetting->get('disable_notes')) {
828 $html = $this->showNotesSection();
829 $tpl->setCurrentBlock("notes");
830 $tpl->setVariable("NOTES", $html);
831 $tpl->parseCurrentBlock();
832 }
833
834 // tagging
835 if (is_object($this->gui_object->object)) {
836 $tags_set = new ilSetting("tags");
837 if ($tags_set->get("enable") && $ilUser->getId() != ANONYMOUS_USER_ID) {
838 $this->addTagging();
839 }
840 }
841
842 if (is_object($this->gui_object->object)) {
843 $this->addObjectSections();
844 }
845
846 // render all sections
847 for ($i = 1; $i <= $this->sec_nr; $i++) {
848 if (is_array($this->section[$i]["properties"])) {
849 // section properties
850 foreach ($this->section[$i]["properties"] as $property) {
851 if ($property["name"] != "") {
852 if ($property["link"] == "") {
853 $tpl->setCurrentBlock("pv");
854 $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]);
855 $tpl->parseCurrentBlock();
856 } else {
857 $tpl->setCurrentBlock("lpv");
858 $tpl->setVariable("TXT_PROPERTY_LVALUE", $property["value"]);
859 $tpl->setVariable("LINK_PROPERTY_VALUE", $property["link"]);
860 $tpl->parseCurrentBlock();
861 }
862 $tpl->setCurrentBlock("property_row");
863 $tpl->setVariable("TXT_PROPERTY", $property["name"]);
864 $tpl->parseCurrentBlock();
865 } else {
866 $tpl->setCurrentBlock("property_full_row");
867 $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]);
868 $tpl->parseCurrentBlock();
869 }
870 }
871
872 // section header
873 if ($this->section[$i]["hidden"]) {
874 $tpl->setVariable("SECTION_HIDDEN", " style=\"display:none;\"");
875 $tpl->setVariable("SECTION_ID", "hidable_" . $i);
876 } else {
877 $tpl->setVariable("SECTION_ID", $i);
878 }
879 $tpl->setVariable("TCLASS", $this->getTableClass());
880 $tpl->setVariable("TXT_SECTION", $this->section[$i]["title"]);
881 $tpl->setCurrentBlock("row");
882 $tpl->parseCurrentBlock();
883 }
884 }
885
886 return $tpl->get();
887 }
888
892 public function getContextRefId() : int
893 {
894 if ($this->contextRefId !== null) {
895 return $this->contextRefId;
896 }
897
898 return $this->gui_object->object->getRefId();
899 }
900
904 public function setContextRefId(int $contextRefId)
905 {
906 $this->contextRefId = $contextRefId;
907 }
908
912 public function getContextObjId() : int
913 {
914 if ($this->contextObjId !== null) {
915 return $this->contextObjId;
916 }
917
918 return $this->gui_object->object->getId();
919 }
920
924 public function setContextObjId(int $contextObjId)
925 {
926 $this->contextObjId = $contextObjId;
927 }
928
932 public function getContentObjType() : string
933 {
934 if ($this->contentObjType !== null) {
936 }
937
938 return $this->gui_object->object->getType();
939 }
940
944 public function setContentObjType(string $contentObjType)
945 {
946 $this->contentObjType = $contentObjType;
947 }
948
949 public function showLearningProgress($a_tpl)
950 {
953
954 if (!$rbacsystem->checkAccess('read', $this->getContextRefId())) {
955 return false;
956 }
957 if ($ilUser->getId() == ANONYMOUS_USER_ID) {
958 return false;
959 }
960
961 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
963 return false;
964 }
965
966 include_once './Services/Object/classes/class.ilObjectLP.php';
968 if ($olp->getCurrentMode() != ilLPObjSettings::LP_MODE_MANUAL) {
969 return false;
970 }
971
972 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
973
974 $this->lng->loadLanguageModule('trac');
975
976 // section header
977 // $a_tpl->setCurrentBlock("header_row");
978 $a_tpl->setVariable(
979 "TXT_SECTION",
980 $this->lng->txt('learning_progress')
981 );
982 $a_tpl->parseCurrentBlock();
983 // $a_tpl->touchBlock("row");
984
985 // status
986 $i_tpl = new ilTemplate("tpl.lp_edit_manual_info_page.html", true, true, "Services/Tracking");
987 $i_tpl->setVariable("INFO_EDITED", $this->lng->txt("trac_info_edited"));
988 $i_tpl->setVariable("SELECT_STATUS", ilUtil::formSelect(
990 $ilUser->getId(),
991 $this->getContextObjId()
992 ),
993 'lp_edit',
994 array(0 => $this->lng->txt('trac_not_completed'),
995 1 => $this->lng->txt('trac_completed')),
996 false,
997 true
998 ));
999 $i_tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1000 $a_tpl->setCurrentBlock("pv");
1001 $a_tpl->setVariable("TXT_PROPERTY_VALUE", $i_tpl->get());
1002 $a_tpl->parseCurrentBlock();
1003 $a_tpl->setCurrentBlock("property_row");
1004 $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_status'));
1005 $a_tpl->parseCurrentBlock();
1006 // $a_tpl->touchBlock("row");
1007
1008
1009 // More infos for lm's
1010 if ($this->getContentObjType() == 'lm' ||
1011 $this->getContentObjType() == 'htlm') {
1012 $a_tpl->setCurrentBlock("pv");
1013
1014 include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
1015 $progress = ilLearningProgress::_getProgress($ilUser->getId(), $this->getContextObjId());
1016 if ($progress['access_time']) {
1017 $a_tpl->setVariable(
1018 "TXT_PROPERTY_VALUE",
1019 ilDatePresentation::formatDate(new ilDateTime($progress['access_time'], IL_CAL_UNIX))
1020 );
1021 } else {
1022 $a_tpl->setVariable(
1023 "TXT_PROPERTY_VALUE",
1024 $this->lng->txt('trac_not_accessed')
1025 );
1026 }
1027
1028 $a_tpl->parseCurrentBlock();
1029 $a_tpl->setCurrentBlock("property_row");
1030 $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_last_access'));
1031 $a_tpl->parseCurrentBlock();
1032 // $a_tpl->touchBlock("row");
1033
1034 // tags of all users
1035 $a_tpl->setCurrentBlock("pv");
1036 $a_tpl->setVariable(
1037 "TXT_PROPERTY_VALUE",
1038 (int) $progress['visits']
1039 );
1040 $a_tpl->parseCurrentBlock();
1041 $a_tpl->setCurrentBlock("property_row");
1042 $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_visits'));
1043 $a_tpl->parseCurrentBlock();
1044 // $a_tpl->touchBlock("row");
1045
1046
1047 if ($this->getContentObjType() == 'lm') {
1048 // tags of all users
1049 $a_tpl->setCurrentBlock("pv");
1050 $a_tpl->setVariable(
1051 "TXT_PROPERTY_VALUE",
1052 ilDatePresentation::secondsToString($progress['spent_seconds'])
1053 );
1054 $a_tpl->parseCurrentBlock();
1055 $a_tpl->setCurrentBlock("property_row");
1056 $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_spent_time'));
1057 $a_tpl->parseCurrentBlock();
1058 // $a_tpl->touchBlock("row");
1059 }
1060 }
1061
1062 // #10493
1063 $a_tpl->touchBlock("row");
1064 }
1065
1066 public function saveProgress($redirect = true)
1067 {
1069
1070 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
1071
1072 $lp_marks = new ilLPMarks($this->getContextObjId(), $ilUser->getId());
1073 $lp_marks->setCompleted((bool) $_POST['lp_edit']);
1074 $lp_marks->update();
1075
1076 require_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
1078
1079 $this->lng->loadLanguageModule('trac');
1080 ilUtil::sendSuccess($this->lng->txt('trac_updated_status'), true);
1081
1082 if ($redirect) {
1083 $this->ctrl->redirect($this, ""); // #14993
1084 }
1085 }
1086
1087
1091 public function showNotesSection()
1092 {
1093 $ilAccess = $this->access;
1095
1096 $next_class = $this->ctrl->getNextClass($this);
1097 include_once("Services/Notes/classes/class.ilNoteGUI.php");
1098 $notes_gui = new ilNoteGUI(
1099 $this->gui_object->object->getId(),
1100 0,
1101 $this->gui_object->object->getType()
1102 );
1103
1104 // global switch
1105 if ($ilSetting->get("disable_comments")) {
1106 $notes_gui->enablePublicNotes(false);
1107 } else {
1108 $ref_id = $this->gui_object->object->getRefId();
1109 $has_write = $ilAccess->checkAccess("write", "", $ref_id);
1110
1111 if ($has_write && $ilSetting->get("comments_del_tutor", 1)) {
1112 $notes_gui->enablePublicNotesDeletion(true);
1113 }
1114
1115 /* should probably be discussed further
1116 for now this will only work properly with comments settings
1117 (see ilNoteGUI constructor)
1118 */
1119 if ($has_write ||
1120 $ilAccess->checkAccess("edit_permissions", "", $ref_id)) {
1121 $notes_gui->enableCommentsSettings();
1122 }
1123 }
1124
1125 /* moved to action menu
1126 $notes_gui->enablePrivateNotes();
1127 */
1128
1129 if ($next_class == "ilnotegui") {
1130 $html = $this->ctrl->forwardCommand($notes_gui);
1131 } else {
1132 $html = $notes_gui->getNotesHTML();
1133 }
1134
1135 return $html;
1136 }
1137
1145 public function showLDAPRoleGroupMappingInfo($a_section = '')
1146 {
1147 if (strlen($a_section)) {
1148 $this->addSection($a_section);
1149 }
1150 include_once('Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1151 $ldap_mapping = ilLDAPRoleGroupMapping::_getInstance();
1152 if ($infos = $ldap_mapping->getInfoStrings($this->gui_object->object->getId())) {
1153 $info_combined = '<div style="color:green;">';
1154 $counter = 0;
1155 foreach ($infos as $info_string) {
1156 if ($counter++) {
1157 $info_combined .= '<br />';
1158 }
1159 $info_combined .= $info_string;
1160 }
1161 $info_combined .= '</div>';
1162 $this->addProperty($this->lng->txt('applications'), $info_combined);
1163 }
1164 return true;
1165 }
1166
1167 public function setTabs()
1168 {
1169 $tpl = $this->tpl;
1170
1171 $this->getTabs($this->tabs_gui);
1172 }
1173
1177 public function getTabs(&$tabs_gui)
1178 {
1181 $ilAccess = $this->access;
1182
1183 $next_class = $this->ctrl->getNextClass($this);
1184 $force_active = ($next_class == "ilnotegui")
1185 ? true
1186 : false;
1187
1188 $tabs_gui->addSubTabTarget(
1189 'summary',
1190 $this->ctrl->getLinkTarget($this, "showSummary"),
1191 array("showSummary", ""),
1192 get_class($this),
1193 "",
1194 $force_active
1195 );
1196 }
1197
1198
1202 public function addTagging()
1203 {
1204 $lng = $this->lng;
1206
1207 $lng->loadLanguageModule("tagging");
1208 $tags_set = new ilSetting("tags");
1209
1210 include_once("Services/Tagging/classes/class.ilTaggingGUI.php");
1211 $tagging_gui = new ilTaggingGUI();
1212 $tagging_gui->setObject(
1213 $this->gui_object->object->getId(),
1214 $this->gui_object->object->getType()
1215 );
1216
1217 $this->addSection($lng->txt("tagging_tags"));
1218
1219 if ($tags_set->get("enable_all_users")) {
1220 $this->addProperty(
1221 $lng->txt("tagging_all_users"),
1222 $tagging_gui->getAllUserTagsForObjectHTML()
1223 );
1224 }
1225
1226 $this->addProperty(
1227 $lng->txt("tagging_my_tags"),
1228 $tagging_gui->getTaggingInputHTML()
1229 );
1230 }
1231
1232 public function saveTags()
1233 {
1234 include_once("Services/Tagging/classes/class.ilTaggingGUI.php");
1235 $tagging_gui = new ilTaggingGUI();
1236 $tagging_gui->setObject(
1237 $this->gui_object->object->getId(),
1238 $this->gui_object->object->getType()
1239 );
1240 $tagging_gui->saveInput();
1241
1242 ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
1243 $this->ctrl->redirect($this, ""); // #14993
1244
1245 // return $this->showSummary();
1246 }
1247
1248 public function hideFurtherSections($a_add_toggle = true)
1249 {
1250 $this->hidden = true;
1251 $this->show_hidden_toggle = (bool) $a_add_toggle;
1252 }
1253
1254 public function getHiddenToggleButton()
1255 {
1256 $lng = $this->lng;
1257
1258 return "<a onClick=\"toggleSections(this, '" . $lng->txt("show_hidden_sections") . "', '" . $lng->txt("hide_visible_sections") . "'); return false;\" href=\"#\">" . $lng->txt("show_hidden_sections") . "</a>";
1259 }
1260
1264 protected function addPreconditions()
1265 {
1266 if (!is_object($this->gui_object) || !is_object($this->gui_object->object)) {
1267 return;
1268 }
1269 $obj = $this->gui_object->object;
1270 if ($obj->getRefId() <= 0) {
1271 return;
1272 }
1273
1274 $conditions = ilConditionHandler::_getEffectiveConditionsOfTarget($obj->getRefId(), $obj->getId());
1275
1276 if (sizeof($conditions)) {
1277 for ($i = 0; $i < count($conditions); $i++) {
1278 $conditions[$i]['title'] = ilObject::_lookupTitle($conditions[$i]['trigger_obj_id']);
1279 }
1280 $conditions = ilUtil::sortArray($conditions, 'title', 'DESC');
1281
1282 // Show obligatory and optional preconditions seperated
1283 $this->addPreconditionSection($obj, $conditions, true);
1284 $this->addPreconditionSection($obj, $conditions, false);
1285 }
1286 }
1287
1288 protected function addPreconditionSection($obj, $conditions, $obligatory = true)
1289 {
1290 $lng = $this->lng;
1292
1293 $num_required = ilConditionHandler::calculateEffectiveRequiredTriggers($obj->getRefId(), $obj->getId());
1294 $num_optional_required =
1295 $num_required - count($conditions) + count(ilConditionHandler::getEffectiveOptionalConditionsOfTarget($obj->getRefId(), $obj->getId()));
1296
1297 // Check if all conditions are fullfilled
1298 $visible_conditions = array();
1299 $passed_optional = 0;
1300 foreach ($conditions as $condition) {
1301 if ($obligatory and !$condition['obligatory']) {
1302 continue;
1303 }
1304 if (!$obligatory and $condition['obligatory']) {
1305 continue;
1306 }
1307
1308 if ($tree->isDeleted($condition['trigger_ref_id'])) {
1309 continue;
1310 }
1311
1313 !ilMemberViewSettings::getInstance()->isActive();
1314
1315 if (!$ok) {
1316 $visible_conditions[] = $condition['id'];
1317 }
1318
1319 if (!$obligatory and $ok) {
1320 ++$passed_optional;
1321 // optional passed
1322 if ($passed_optional >= $num_optional_required) {
1323 return true;
1324 }
1325 }
1326 }
1327
1328 $properties = [];
1329
1330 foreach ($conditions as $condition) {
1331 if (!in_array($condition['id'], $visible_conditions)) {
1332 continue;
1333 }
1334
1335 $missing_cond_exist = true;
1336
1337 $properties[] = [
1339 $condition['trigger_obj_id'],
1340 $condition['operator']
1341 ) . ' ' . $condition['value'],
1342 "title" => ilObject::_lookupTitle($condition['trigger_obj_id']),
1343 "link" => ilLink::_getLink($condition['trigger_ref_id'])
1344 ];
1345 }
1346
1347 if (count($properties) > 0) {
1348 if ($obligatory) {
1349 $this->addSection($lng->txt("preconditions_obligatory_hint"));
1350 } else {
1351 $this->addSection(sprintf($lng->txt("preconditions_optional_hint"), $num_optional_required));
1352 }
1353
1354 foreach ($properties as $p) {
1355 $this->addProperty(
1356 $p["condition"],
1357 "<a href='".$p["link"]."'>".$p["title"]."</a>"
1358 );
1359 }
1360
1361 }
1362 }
1363
1364}
user()
Definition: user.php:4
$size
Definition: RandomTest.php:84
$_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
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.
@classDescription Date and time handling
static getInstance()
Get singleton instance.
Class ilInfoScreenGUI.
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...
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
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.
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 getInstance()
Get instance.
Notes GUI class.
static _enabledLearningProgress()
check wether learing progress is enabled or not
static userExists($a_usr_ids=array())
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 formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
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($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
$i
Definition: disco.tpl.php:19
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79
if(!array_key_exists('StateId', $_REQUEST)) $id
$links
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
$type
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92