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