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