ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 {
20  var $ilias;
21  var $lng;
22  var $ctrl;
24  var $top_buttons = array();
25  var $top_formbuttons = array();
26  var $hiddenelements = array();
27  var $table_class = "il_InfoScreen";
28  var $open_form_tag = true;
29  var $close_form_tag = true;
30 
35 
42  function ilInfoScreenGUI($a_gui_object)
43  {
44  global $ilias, $ilCtrl, $lng,$ilTabs;
45 
46  $this->ilias =& $ilias;
47  $this->ctrl =& $ilCtrl;
48  $this->lng =& $lng;
49  $this->tabs_gui =& $ilTabs;
50  $this->gui_object =& $a_gui_object;
51  $this->sec_nr = 0;
52  $this->private_notes_enabled = false;
53  $this->news_enabled = false;
54  $this->feedback_enabled = false;
55  $this->learning_progress_enabled = false;
56  $this->form_action = "";
57  $this->top_formbuttons = array();
58  $this->hiddenelements = array();
59  }
60 
64  function &executeCommand()
65  {
66  global $rbacsystem, $tpl, $ilAccess;
67 
68  // load additional language modules
69  $this->lng->loadLanguageModule("barometer");
70 
71  $next_class = $this->ctrl->getNextClass($this);
72 
73  $cmd = $this->ctrl->getCmd("showSummary");
74  $this->ctrl->setReturn($this, "showSummary");
75 
76  $this->setTabs();
77 
78  switch($next_class)
79  {
80  case "ilnotegui":
81  $this->showSummary(); // forwards command
82  break;
83 
84  case "ilcolumngui":
85  $this->showSummary();
86  break;
87 
88  case "ilpublicuserprofilegui":
89  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
90  $user_profile = new ilPublicUserProfileGUI($_GET["user_id"]);
91  $user_profile->setBackUrl($this->ctrl->getLinkTarget($this, "showSummary"));
92  $html = $this->ctrl->forwardCommand($user_profile);
93  $tpl->setContent($html);
94  break;
95 
96  case "ilcommonactiondispatchergui":
97  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
99  $this->ctrl->forwardCommand($gui);
100  break;
101 
102  default:
103  return $this->$cmd();
104  break;
105  }
106  return true;
107  }
108 
114  function setTableClass($a_val)
115  {
116  $this->table_class = $a_val;
117  }
118 
124  function getTableClass()
125  {
126  return $this->table_class;
127  }
128 
132  function enablePrivateNotes($a_enable = true)
133  {
134  $this->private_notes_enabled = $a_enable;
135  }
136 
140  function enableLearningProgress($a_enable = true)
141  {
142  $this->learning_progress_enabled = $a_enable;
143  }
144 
145 
149  function enableFeedback($a_enable = true)
150  {
151  $this->feedback_enabled = $a_enable;
152  }
153 
157  function enableNews($a_enable = true)
158  {
159  $this->news_enabled = $a_enable;
160  }
161 
165  function enableNewsEditing($a_enable = true)
166  {
167  $this->news_editing = $a_enable;
168  }
169 
177  function setBlockProperty($a_block_type, $a_property, $a_value)
178  {
179  $this->block_property[$a_block_type][$a_property] = $a_value;
180  }
181 
183  {
184  return $this->block_property;
185  }
186 
190  function addSection($a_title)
191  {
192  $this->sec_nr++;
193  $this->section[$this->sec_nr]["title"] = $a_title;
194  $this->section[$this->sec_nr]["hidden"] = (bool)$this->hidden;
195  }
196 
200  function setFormAction($a_form_action)
201  {
202  $this->form_action = $a_form_action;
203  }
204 
208  function removeFormAction()
209  {
210  $this->form_action = "";
211  }
212 
220  function addProperty($a_name, $a_value, $a_link = "")
221  {
222  $this->section[$this->sec_nr]["properties"][] =
223  array("name" => $a_name, "value" => $a_value,
224  "link" => $a_link);
225  }
226 
230  function addPropertyCheckbox($a_name, $a_checkbox_name, $a_checkbox_value, $a_checkbox_label = "", $a_checkbox_checked = false)
231  {
232  $checkbox = "<input type=\"checkbox\" name=\"$a_checkbox_name\" value=\"$a_checkbox_value\" id=\"$a_checkbox_name$a_checkbox_value\"";
233  if ($a_checkbox_checked)
234  {
235  $checkbox .= " checked=\"checked\"";
236  }
237  $checkbox .= " />";
238  if (strlen($a_checkbox_label))
239  {
240  $checkbox .= "&nbsp;<label for=\"$a_checkbox_name$a_checkbox_value\">$a_checkbox_label</label>";
241  }
242  $this->section[$this->sec_nr]["properties"][] =
243  array("name" => $a_name, "value" => $checkbox);
244  }
245 
249  function addPropertyTextinput($a_name, $a_input_name, $a_input_value = "", $a_input_size = "", $direct_button_command = "", $direct_button_label = "", $direct_button_primary = false)
250  {
251  $input = "<span class=\"form-inline\"><input class=\"form-control\" type=\"text\" name=\"$a_input_name\" id=\"$a_input_name\"";
252  if (strlen($a_input_value))
253  {
254  $input .= " value=\"" . ilUtil::prepareFormOutput($a_input_value) . "\"";
255  }
256  if (strlen($a_input_size))
257  {
258  $input .= " size=\"" . $a_input_size . "\"";
259  }
260  $input .= " />";
261  if (strlen($direct_button_command) && strlen($direct_button_label))
262  {
263  $css = "";
264  if($direct_button_primary)
265  {
266  $css = " btn-primary";
267  }
268  $input .= " <input type=\"submit\" class=\"btn btn-default".$css."\" name=\"cmd[$direct_button_command]\" value=\"$direct_button_label\" />";
269  }
270  $input .= "</span>";
271  $this->section[$this->sec_nr]["properties"][] =
272  array("name" => "<label for=\"$a_input_name\">$a_name</label>", "value" => $input);
273  }
274 
278  function addButton($a_title, $a_link, $a_frame = "", $a_position = "top", $a_primary = false)
279  {
280  if ($a_position == "top")
281  {
282  $this->top_buttons[] =
283  array("title" => $a_title,"link" => $a_link,"target" => $a_frame,"primary" => $a_primary);
284  }
285  }
286 
291  function addFormButton($a_command, $a_title, $a_position = "top")
292  {
293  if ($a_position == "top")
294  {
295  array_push($this->top_formbuttons,
296  array("command" => $a_command, "title" => $a_title)
297  );
298  }
299  }
300 
301  function addHiddenElement($a_name, $a_value)
302  {
303  array_push($this->hiddenelements, array("name" => $a_name, "value" => $a_value));
304  }
305 
309  function addMetaDataSections($a_rep_obj_id,$a_obj_id, $a_type)
310  {
311  global $lng;
312 
313  $lng->loadLanguageModule("meta");
314 
315  include_once("./Services/MetaData/classes/class.ilMD.php");
316  $md = new ilMD($a_rep_obj_id,$a_obj_id, $a_type);
317 
318  if ($md_gen = $md->getGeneral())
319  {
320  // get first descrption
321  // The description is shown on the top of the page.
322  // Thus it is not necessary to show it again.
323  foreach($md_gen->getDescriptionIds() as $id)
324  {
325  $md_des = $md_gen->getDescription($id);
326  $description = $md_des->getDescription();
327  break;
328  }
329 
330  // get language(s)
331  $langs = array();
332  foreach($ids = $md_gen->getLanguageIds() as $id)
333  {
334  $md_lan = $md_gen->getLanguage($id);
335  if ($md_lan->getLanguageCode() != "")
336  {
337  $langs[] = $lng->txt("meta_l_".$md_lan->getLanguageCode());
338  }
339  }
340  $langs = implode($langs, ", ");
341 
342  // keywords
343  $keywords = array();
344  foreach($ids = $md_gen->getKeywordIds() as $id)
345  {
346  $md_key = $md_gen->getKeyword($id);
347  $keywords[] = $md_key->getKeyword();
348  }
349  $keywords = implode($keywords, ", ");
350  }
351 
352  // authors
353  if(is_object($lifecycle = $md->getLifecycle()))
354  {
355  $sep = $author = "";
356  foreach(($ids = $lifecycle->getContributeIds()) as $con_id)
357  {
358  $md_con = $lifecycle->getContribute($con_id);
359  if ($md_con->getRole() == "Author")
360  {
361  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
362  {
363  $md_ent = $md_con->getEntity($ent_id);
364  $author = $author.$sep.$md_ent->getEntity();
365  $sep = ", ";
366  }
367  }
368  }
369  }
370 
371  // copyright
372  $copyright = "";
373  if(is_object($rights = $md->getRights()))
374  {
375  include_once('Services/MetaData/classes/class.ilMDUtils.php');
376  $copyright = ilMDUtils::_parseCopyright($rights->getDescription());
377  }
378 
379  // learning time
380  #if(is_object($educational = $md->getEducational()))
381  #{
382  # $learning_time = $educational->getTypicalLearningTime();
383  #}
384  $learning_time = "";
385  if(is_object($educational = $md->getEducational()))
386  {
387  if($seconds = $educational->getTypicalLearningTimeSeconds())
388  {
389  $learning_time = ilFormat::_secondsToString($seconds);
390  }
391  }
392 
393 
394  // output
395 
396  // description
397  if ($description != "")
398  {
399  $this->addSection($lng->txt("description"));
400  $this->addProperty("", nl2br($description));
401  }
402 
403  // general section
404  $this->addSection($lng->txt("meta_general"));
405  if ($langs != "") // language
406  {
407  $this->addProperty($lng->txt("language"),
408  $langs);
409  }
410  if ($keywords != "") // keywords
411  {
412  $this->addProperty($lng->txt("keywords"),
413  $keywords);
414  }
415  if ($author != "") // author
416  {
417  $this->addProperty($lng->txt("author"),
418  $author);
419  }
420  if ($copyright != "") // copyright
421  {
422  $this->addProperty($lng->txt("meta_copyright"),
423  $copyright);
424  }
425  if ($learning_time != "") // typical learning time
426  {
427  $this->addProperty($lng->txt("meta_typical_learning_time"),
428  $learning_time);
429  }
430  }
431 
435  function addObjectSections()
436  {
437  global $lng, $ilCtrl, $ilUser, $ilAccess, $tree, $ilSetting, $ilObjDataCache;
438 
439  $this->addSection($lng->txt("additional_info"));
440  $a_obj = $this->gui_object->object;
441 
442  // links to the object
443  if (is_object($a_obj))
444  {
445  // permanent link
446  $type = $a_obj->getType();
447  $ref_id = $a_obj->getRefId();
448 
449  if($ref_id)
450  {
451  include_once('./Services/Link/classes/class.ilLink.php');
452  $href = ilLink::_getStaticLink($ref_id,$type,true);
453 
454  include_once 'Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
455  if(ilECSServerSettings::getInstance()->activeServerExists())
456  {
457  $this->addProperty($lng->txt("object_id"),
458  $a_obj->getId()
459  );
460  }
461 
462  include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
463  $pm = new ilPermanentLinkGUI($type, $ref_id);
464  $pm->setIncludePermanentLinkText(false);
465  $pm->setAlignCenter(false);
466  $this->addProperty($lng->txt("perma_link"),
467  $pm->getHTML(),
468  ""
469  );
470 
471  // bookmarks
472 
473  $title = $ilObjDataCache->lookupTitle($a_obj->getId());
474 
476 
477  // links to resource
478  if ($ilAccess->checkAccess("write", "", $ref_id) ||
479  $ilAccess->checkAccess("edit_permissions", "", $ref_id))
480  {
481  $obj_id = $a_obj->getId();
482  $rs = ilObject::_getAllReferences($obj_id);
483  $refs = array();
484  foreach($rs as $r)
485  {
486  if ($tree->isInTree($r))
487  {
488  $refs[] = $r;
489  }
490  }
491  if (count($refs) > 1)
492  {
493  $links = $sep = "";
494  foreach($refs as $r)
495  {
496  $cont_loc = new ilLocatorGUI();
497  $cont_loc->addContextItems($r, true);
498  $links.= $sep.$cont_loc->getHTML();
499  $sep = "<br />";
500  }
501 
502  $this->addProperty($lng->txt("res_links"),
503  '<div class="small">'.$links.'</div>'
504  );
505  }
506  }
507  }
508  }
509 
510 
511  // creation date
512  $this->addProperty(
513  $lng->txt("create_date"),
514  ilDatePresentation::formatDate(new ilDateTime($a_obj->getCreateDate(),IL_CAL_DATETIME)));
515 
516  // owner
517  if ($ilUser->getId() != ANONYMOUS_USER_ID and $a_obj->getOwner())
518  {
519  include_once './Services/Object/classes/class.ilObjectFactory.php';
520  include_once './Services/User/classes/class.ilObjUser.php';
521 
522  if(ilObjUser::userExists(array($a_obj->getOwner())))
523  {
524  $ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(),false);
525  }
526  else
527  {
528  $ownerObj = ilObjectFactory::getInstanceByObjId(6, false);
529  }
530 
531  if (!is_object($ownerObj) || $ownerObj->getType() != "usr") // root user deleted
532  {
533  $this->addProperty($lng->txt("owner"), $lng->txt("no_owner"));
534  }
535  else if ($ownerObj->hasPublicProfile())
536  {
537  $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $ownerObj->getId());
538  $this->addProperty($lng->txt("owner"),$ownerObj->getPublicName(),$ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML"));
539  }
540  else
541  {
542  $this->addProperty($lng->txt("owner"),$ownerObj->getPublicName());
543  }
544  }
545 
546  // disk usage
547  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
548  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
550  {
551  $size = $a_obj->getDiskUsage();
552  if ($size !== null) {
553  $this->addProperty($lng->txt("disk_usage"),ilFormat::formatSize($size,'long'));
554  }
555  }
556  // change event
557  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
559  {
560  if ($ilUser->getId() != ANONYMOUS_USER_ID)
561  {
562  $readEvents = ilChangeEvent::_lookupReadEvents($a_obj->getId());
563  $count_users = 0;
564  $count_members = 0;
565  $count_user_reads = 0;
566  $count_anonymous_reads = 0;
567  foreach ($readEvents as $evt)
568  {
569  if ($evt['usr_id'] == ANONYMOUS_USER_ID)
570  {
571  $count_anonymous_reads += $evt['read_count'];
572  }
573  else
574  {
575  $count_user_reads += $evt['read_count'];
576  $count_users++;
577  /* to do: if ($evt['user_id'] is member of $this->getRefId())
578  {
579  $count_members++;
580  }*/
581  }
582  }
583  if ($count_anonymous_reads > 0)
584  {
585  $this->addProperty($this->lng->txt("readcount_anonymous_users"),$count_anonymous_reads);
586  }
587  if ($count_user_reads > 0)
588  {
589  $this->addProperty($this->lng->txt("readcount_users"),$count_user_reads);
590  }
591  if ($count_users > 0)
592  {
593  $this->addProperty($this->lng->txt("accesscount_registered_users"),$count_users);
594  }
595  }
596  }
597  // END ChangeEvent: Display change event info
598 
599  // BEGIN WebDAV: Display locking information
600  require_once('Services/WebDAV/classes/class.ilDAVServer.php');
602  {
603  global $ilias, $ilUser;
604  if ($ilUser->getId() != ANONYMOUS_USER_ID)
605  {
606  $davLocks = new ilDAVLocks();
607 
608  // Show lock info
609  if ($ilias->account->getId() != ANONYMOUS_USER_ID)
610  {
611  $locks =& $davLocks->getLocksOnObjectObj($a_obj->getId());
612  if (count($locks) > 0)
613  {
614  $lockUser = new ilObjUser($locks[0]['ilias_owner']);
615  $this->addProperty($this->lng->txt("in_use_by"),
616  $lockUser->getPublicName()
617  ,
618  "./ilias.php?user=".$locks[0]['ilias_owner'].'&cmd=showUserProfile&cmdClass=ilpersonaldesktopgui&cmdNode=1&baseClass=ilPersonalDesktopGUI'
619  );
620  }
621  }
622  }
623  }
624  // END WebDAV: Display locking information
625 
626 
627  }
628  // END ChangeEvent: Display standard object info
632  function showSummary()
633  {
634  global $tpl, $ilAccess;
635 
636  $tpl->setContent($this->getCenterColumnHTML());
637  $tpl->setRightContent($this->getRightColumnHTML());
638  }
639 
640 
645  {
646  global $ilCtrl;
647 
648  include_once("Services/Block/classes/class.ilColumnGUI.php");
649  $column_gui = new ilColumnGUI("info", IL_COL_CENTER);
650  $this->setColumnSettings($column_gui);
651 
652  if (!$ilCtrl->isAsynch())
653  {
654  if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
655  {
656  // right column wants center
657  if ($column_gui->getCmdSide() == IL_COL_RIGHT)
658  {
659  $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
660  $this->setColumnSettings($column_gui);
661  $html = $ilCtrl->forwardCommand($column_gui);
662  }
663  // left column wants center
664  if ($column_gui->getCmdSide() == IL_COL_LEFT)
665  {
666  $column_gui = new ilColumnGUI("info", IL_COL_LEFT);
667  $this->setColumnSettings($column_gui);
668  $html = $ilCtrl->forwardCommand($column_gui);
669  }
670  }
671  else
672  {
673  $html = $this->getHTML();
674  }
675  }
676 
677  return $html;
678  }
679 
684  {
685  global $ilUser, $lng, $ilCtrl;
686 
687  include_once("Services/Block/classes/class.ilColumnGUI.php");
688  $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
689  $this->setColumnSettings($column_gui);
690 
691  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
692  $column_gui->getCmdSide() == IL_COL_RIGHT &&
693  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
694  {
695  $html = $ilCtrl->forwardCommand($column_gui);
696  }
697  else
698  {
699  if (!$ilCtrl->isAsynch())
700  {
701  if ($this->news_enabled)
702  {
703  $html = $ilCtrl->getHTML($column_gui);
704  }
705  }
706  }
707 
708  return $html;
709  }
710 
714  function setColumnSettings($column_gui)
715  {
716  global $lng, $ilAccess;
717 
718  $column_gui->setEnableEdit($this->news_editing);
719  $column_gui->setRepositoryMode(true);
720  $column_gui->setAllBlockProperties($this->getAllBlockProperties());
721  }
722 
723  function setOpenFormTag($a_val)
724  {
725  $this->open_form_tag = $a_val;
726  }
727 
728  function setCloseFormTag($a_val)
729  {
730  $this->close_form_tag = $a_val;
731  }
732 
736  function getHTML()
737  {
738  global $lng, $ilSetting, $tree, $ilAccess, $ilCtrl, $ilUser;
739 
740  $tpl = new ilTemplate("tpl.infoscreen.html" ,true, true, "Services/InfoScreen");
741 
742  // other class handles form action (@todo: this is not implemented/tested)
743  if ($this->form_action == "")
744  {
745  $this->setFormAction($ilCtrl->getFormAction($this));
746  }
747 
748  require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
750 
751  if($this->hidden)
752  {
753  $tpl->touchBlock("hidden_js");
754  if($this->show_hidden_toggle)
755  {
756  $this->addButton($lng->txt("show_hidden_sections"), "JavaScript:toggleSections(this, '".$lng->txt("show_hidden_sections") ."', '".$lng->txt("hide_visible_sections") ."');");
757  }
758  }
759 
760 
761  // DEPRECATED - use ilToolbarGUI
762 
763  // add top buttons
764  if (count($this->top_buttons) > 0)
765  {
766  $tpl->addBlockfile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html");
767 
768  foreach($this->top_buttons as $button)
769  {
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  {
777  $tpl->setVariable("BTN_CLASS", " btn-primary");
778  }
779  $tpl->parseCurrentBlock();
780  }
781  }
782 
783  // add top formbuttons
784  if ((count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0))
785  {
786  $tpl->addBlockfile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html", "Services/InfoScreen");
787 
788  foreach($this->top_formbuttons as $button)
789  {
790  // view button
791  $tpl->setCurrentBlock("btn_submit_cell");
792  $tpl->setVariable("BTN_COMMAND", $button["command"]);
793  $tpl->setVariable("BTN_NAME", $button["title"]);
794  $tpl->parseCurrentBlock();
795  }
796  }
797 
798  // add form action
799  if (strlen($this->form_action) > 0)
800  {
801  if($this->open_form_tag)
802  {
803  $tpl->setCurrentBlock("formtop");
804  $tpl->setVariable("FORMACTION", $this->form_action);
805  $tpl->parseCurrentBlock();
806  }
807 
808  if($this->close_form_tag)
809  {
810  $tpl->touchBlock("formbottom");
811  }
812  }
813 
814  if (count($this->hiddenelements))
815  {
816  foreach ($this->hiddenelements as $hidden)
817  {
818  $tpl->setCurrentBlock("hidden_element");
819  $tpl->setVariable("HIDDEN_NAME", $hidden["name"]);
820  $tpl->setVariable("HIDDEN_VALUE", $hidden["value"]);
821  $tpl->parseCurrentBlock();
822  }
823  }
824 
825 
826  // learning progress
827  if($this->learning_progress_enabled and $html = $this->showLearningProgress($tpl))
828  {
829  $tpl->setCurrentBlock("learning_progress");
830  $tpl->setVariable("LP_TABLE",$html);
831  $tpl->parseCurrentBlock();
832  }
833 
834  // notes section
835  if ($this->private_notes_enabled && !$ilSetting->get('disable_notes'))
836  {
837  $html = $this->showNotesSection();
838  $tpl->setCurrentBlock("notes");
839  $tpl->setVariable("NOTES", $html);
840  $tpl->parseCurrentBlock();
841  }
842 
843  // tagging
844  if (is_object($this->gui_object->object))
845  {
846  $tags_set = new ilSetting("tags");
847  if ($tags_set->get("enable") && $ilUser->getId() != ANONYMOUS_USER_ID)
848  {
849  $this->addTagging();
850  }
851  }
852 
853  if(is_object($this->gui_object->object))
854  {
855  $this->addObjectSections();
856  }
857 
858  // render all sections
859  for($i = 1; $i <= $this->sec_nr; $i++)
860  {
861  if (is_array($this->section[$i]["properties"]))
862  {
863  // section properties
864  foreach($this->section[$i]["properties"] as $property)
865  {
866  if ($property["name"] != "")
867  {
868  if ($property["link"] == "")
869  {
870  $tpl->setCurrentBlock("pv");
871  $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]);
872  $tpl->parseCurrentBlock();
873  }
874  else
875  {
876  $tpl->setCurrentBlock("lpv");
877  $tpl->setVariable("TXT_PROPERTY_LVALUE", $property["value"]);
878  $tpl->setVariable("LINK_PROPERTY_VALUE", $property["link"]);
879  $tpl->parseCurrentBlock();
880  }
881  $tpl->setCurrentBlock("property_row");
882  $tpl->setVariable("TXT_PROPERTY", $property["name"]);
883  $tpl->parseCurrentBlock();
884  }
885  else
886  {
887  $tpl->setCurrentBlock("property_full_row");
888  $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]);
889  $tpl->parseCurrentBlock();
890  }
891  }
892 
893  // section header
894  if($this->section[$i]["hidden"])
895  {
896  $tpl->setVariable("SECTION_HIDDEN", " style=\"display:none;\"");
897  $tpl->setVariable("SECTION_ID", "hidable_".$i);
898  }
899  else
900  {
901  $tpl->setVariable("SECTION_ID", $i);
902  }
903  $tpl->setVariable("TCLASS", $this->getTableClass());
904  $tpl->setVariable("TXT_SECTION", $this->section[$i]["title"]);
905  $tpl->touchBlock("row");
906  }
907  }
908 
909  return $tpl->get();
910  }
911 
912  function showLearningProgress($a_tpl)
913  {
914  global $ilUser,$rbacsystem;
915 
916  if(!$rbacsystem->checkAccess('read',$this->gui_object->object->getRefId()))
917  {
918  return false;
919  }
920  if($ilUser->getId() == ANONYMOUS_USER_ID)
921  {
922  return false;
923  }
924 
925  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
926  if (!ilObjUserTracking::_enabledLearningProgress() and $ilUser->getId() != ANONYMOUS_USER_ID)
927  {
928  return false;
929  }
930 
931  include_once './Services/Object/classes/class.ilObjectLP.php';
932  $olp = ilObjectLP::getInstance($this->gui_object->object->getId());
933  if($olp->getCurrentMode() != ilLPObjSettings::LP_MODE_MANUAL)
934  {
935  return false;
936  }
937 
938  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
939 
940  $this->lng->loadLanguageModule('trac');
941 
942  // section header
943 // $a_tpl->setCurrentBlock("header_row");
944  $a_tpl->setVariable("TXT_SECTION",
945  $this->lng->txt('learning_progress'));
946  $a_tpl->parseCurrentBlock();
947  // $a_tpl->touchBlock("row");
948 
949  // status
950  $i_tpl = new ilTemplate("tpl.lp_edit_manual_info_page.html", true, true, "Services/Tracking");
951  $i_tpl->setVariable("INFO_EDITED", $this->lng->txt("trac_info_edited"));
952  $i_tpl->setVariable("SELECT_STATUS", ilUtil::formSelect((int) ilLPMarks::_hasCompleted($ilUser->getId(),
953  $this->gui_object->object->getId()),
954  'lp_edit',
955  array(0 => $this->lng->txt('trac_not_completed'),
956  1 => $this->lng->txt('trac_completed')),
957  false,
958  true));
959  $i_tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
960  $a_tpl->setCurrentBlock("pv");
961  $a_tpl->setVariable("TXT_PROPERTY_VALUE", $i_tpl->get());
962  $a_tpl->parseCurrentBlock();
963  $a_tpl->setCurrentBlock("property_row");
964  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_status'));
965  $a_tpl->parseCurrentBlock();
966  // $a_tpl->touchBlock("row");
967 
968 
969  // More infos for lm's
970  if($this->gui_object->object->getType() == 'lm' ||
971  $this->gui_object->object->getType() == 'htlm')
972  {
973  $a_tpl->setCurrentBlock("pv");
974 
975  include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
976  $progress = ilLearningProgress::_getProgress($ilUser->getId(),$this->gui_object->object->getId());
977  if($progress['access_time'])
978  {
979  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
980  ilDatePresentation::formatDate(new ilDateTime($progress['access_time'],IL_CAL_DATETIME)));
981  }
982  else
983  {
984  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
985  $this->lng->txt('trac_not_accessed'));
986  }
987 
988  $a_tpl->parseCurrentBlock();
989  $a_tpl->setCurrentBlock("property_row");
990  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_last_access'));
991  $a_tpl->parseCurrentBlock();
992  // $a_tpl->touchBlock("row");
993 
994  // tags of all users
995  $a_tpl->setCurrentBlock("pv");
996  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
997  (int) $progress['visits']);
998  $a_tpl->parseCurrentBlock();
999  $a_tpl->setCurrentBlock("property_row");
1000  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_visits'));
1001  $a_tpl->parseCurrentBlock();
1002  // $a_tpl->touchBlock("row");
1003 
1004 
1005  if($this->gui_object->object->getType() == 'lm')
1006  {
1007  // tags of all users
1008  $a_tpl->setCurrentBlock("pv");
1009  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
1010  ilFormat::_secondsToString($progress['spent_seconds']));
1011  $a_tpl->parseCurrentBlock();
1012  $a_tpl->setCurrentBlock("property_row");
1013  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_spent_time'));
1014  $a_tpl->parseCurrentBlock();
1015  // $a_tpl->touchBlock("row");
1016  }
1017  }
1018 
1019  // #10493
1020  $a_tpl->touchBlock("row");
1021  }
1022 
1023  function saveProgress()
1024  {
1025  global $ilUser;
1026 
1027  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
1028 
1029  $lp_marks = new ilLPMarks($this->gui_object->object->getId(),$ilUser->getId());
1030  $lp_marks->setCompleted((bool) $_POST['lp_edit']);
1031  $lp_marks->update();
1032 
1033  require_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
1034  ilLPStatusWrapper::_updateStatus($this->gui_object->object->getId(),$ilUser->getId());
1035 
1036  $this->lng->loadLanguageModule('trac');
1037  ilUtil::sendSuccess($this->lng->txt('trac_updated_status'), true);
1038  $this->ctrl->redirect($this, ""); // #14993
1039 
1040  // $this->showSummary();
1041  }
1042 
1043 
1047  function showNotesSection()
1048  {
1049  global $ilAccess, $ilSetting;
1050 
1051  $next_class = $this->ctrl->getNextClass($this);
1052  include_once("Services/Notes/classes/class.ilNoteGUI.php");
1053  $notes_gui = new ilNoteGUI($this->gui_object->object->getId(), 0,
1054  $this->gui_object->object->getType());
1055 
1056  // global switch
1057  if($ilSetting->get("disable_comments"))
1058  {
1059  $notes_gui->enablePublicNotes(false);
1060  }
1061  else
1062  {
1063  $ref_id = $this->gui_object->object->getRefId();
1064  $has_write = $ilAccess->checkAccess("write", "", $ref_id);
1065 
1066  if($has_write && $ilSetting->get("comments_del_tutor", 1))
1067  {
1068  $notes_gui->enablePublicNotesDeletion(true);
1069  }
1070 
1071  /* should probably be discussed further
1072  for now this will only work properly with comments settings
1073  (see ilNoteGUI constructor)
1074  */
1075  if ($has_write ||
1076  $ilAccess->checkAccess("edit_permissions", "", $ref_id))
1077  {
1078  $notes_gui->enableCommentsSettings();
1079  }
1080  }
1081 
1082  /* moved to action menu
1083  $notes_gui->enablePrivateNotes();
1084  */
1085 
1086  if ($next_class == "ilnotegui")
1087  {
1088  $html = $this->ctrl->forwardCommand($notes_gui);
1089  }
1090  else
1091  {
1092  $html = $notes_gui->getNotesHTML();
1093  }
1094 
1095  return $html;
1096  }
1097 
1105  public function showLDAPRoleGroupMappingInfo($a_section = '')
1106  {
1107  if(strlen($a_section))
1108  {
1109  $this->addSection($a_section);
1110  }
1111  include_once('Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1112  $ldap_mapping = ilLDAPRoleGroupMapping::_getInstance();
1113  if($infos = $ldap_mapping->getInfoStrings($this->gui_object->object->getId()))
1114  {
1115  $info_combined = '<div style="color:green;">';
1116  $counter = 0;
1117  foreach($infos as $info_string)
1118  {
1119  if($counter++)
1120  {
1121  $info_combined .= '<br />';
1122  }
1123  $info_combined .= $info_string;
1124  }
1125  $info_combined .= '</div>';
1126  $this->addProperty($this->lng->txt('applications'),$info_combined);
1127  }
1128  return true;
1129  }
1130 
1131  function setTabs()
1132  {
1133  global $tpl;
1134 
1135  $this->getTabs($this->tabs_gui);
1136  }
1137 
1141  function getTabs(&$tabs_gui)
1142  {
1143  global $rbacsystem,$ilUser,$ilAccess;
1144 
1145  $next_class = $this->ctrl->getNextClass($this);
1146  $force_active = ($next_class == "ilnotegui")
1147  ? true
1148  : false;
1149 
1150  $tabs_gui->addSubTabTarget('summary',
1151  $this->ctrl->getLinkTarget($this, "showSummary"),
1152  array("showSummary", ""),
1153  get_class($this), "", $force_active);
1154  }
1155 
1156 
1160  function addTagging()
1161  {
1162  global $lng, $ilCtrl;
1163 
1164  $lng->loadLanguageModule("tagging");
1165  $tags_set = new ilSetting("tags");
1166 
1167  include_once("Services/Tagging/classes/class.ilTaggingGUI.php");
1168  $tagging_gui = new ilTaggingGUI();
1169  $tagging_gui->setObject($this->gui_object->object->getId(),
1170  $this->gui_object->object->getType());
1171 
1172  $this->addSection($lng->txt("tagging_tags"));
1173 
1174  if ($tags_set->get("enable_all_users"))
1175  {
1176  $this->addProperty($lng->txt("tagging_all_users"),
1177  $tagging_gui->getAllUserTagsForObjectHTML());
1178  }
1179 
1180  $this->addProperty($lng->txt("tagging_my_tags"),
1181  $tagging_gui->getTaggingInputHTML());
1182  }
1183 
1184  function saveTags()
1185  {
1186  include_once("Services/Tagging/classes/class.ilTaggingGUI.php");
1187  $tagging_gui = new ilTaggingGUI();
1188  $tagging_gui->setObject($this->gui_object->object->getId(),
1189  $this->gui_object->object->getType());
1190  $tagging_gui->saveInput();
1191 
1192  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
1193  $this->ctrl->redirect($this, ""); // #14993
1194 
1195  // return $this->showSummary();
1196  }
1197 
1198  function hideFurtherSections($a_add_toggle = true)
1199  {
1200  $this->hidden = true;
1201  $this->show_hidden_toggle = (bool)$a_add_toggle;
1202  }
1203 
1205  {
1206  global $lng;
1207 
1208  return "<a onClick=\"toggleSections(this, '".$lng->txt("show_hidden_sections") ."', '".$lng->txt("hide_visible_sections") ."'); return false;\" href=\"#\">".$lng->txt("show_hidden_sections")."</a>";
1209  }
1210 }
1211 
1212 ?>