ILIAS  Release_4_1_x_branch Revision 61804
 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  global $lng, $ilCtrl, $ilUser, $ilAccess, $tree, $ilSetting, $ilObjDataCache;
433 
434  $this->addSection($lng->txt("additional_info"));
435  $a_obj = $this->gui_object->object;
436 
437  // links to the object
438  if (is_object($a_obj))
439  {
440  // permanent link
441  $type = $a_obj->getType();
442  $ref_id = $a_obj->getRefId();
443 
444  include_once('classes/class.ilLink.php');
445  $href = ilLink::_getStaticLink($ref_id,$type,true);
446 
447  // delicous link
448  $d_set = new ilSetting("delicious");
449  if (true || $d_set->get("add_info_links") == "1")
450  {
451  $lng->loadLanguageModule("delic");
452  $del_link = '<br/><a class="small" href="http://del.icio.us/post?desc=nn&url='.
453  urlencode($href).'"><img border="0" src="'.ilUtil::getImagePath("icon_delicious_s.gif").
454  '" /> '.$lng->txt("delic_add_to_delicious").
455  '</a>';
456  }
457 
458  include_once('Services/WebServices/ECS/classes/class.ilECSSettings.php');
459  $settings = ilECSSettings::_getInstance();
460  if($settings->isEnabled())
461  {
462  $this->addProperty($lng->txt("object_id"),
463  $a_obj->getId()
464  );
465  }
466 
467  include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
468  $pm = new ilPermanentLinkGUI($type, $ref_id);
469  $pm->setIncludePermanentLinkText(false);
470  $pm->setAlignCenter(false);
471  $this->addProperty($lng->txt("perma_link"),
472  $pm->getHTML(),
473  ""
474  );
475 
476  // bookmarks
477 
478  $title = $ilObjDataCache->lookupTitle($a_obj->getId());
479 
481 
482  // links to resource
483  if ($ilAccess->checkAccess("write", "", $ref_id) ||
484  $ilAccess->checkAccess("edit_permissions", "", $ref_id))
485  {
486  $obj_id = $a_obj->getId();
487  $rs = ilObject::_getAllReferences($obj_id);
488  $refs = array();
489  foreach($rs as $r)
490  {
491  if ($tree->isInTree($r))
492  {
493  $refs[] = $r;
494  }
495  }
496  if (count($refs) > 1)
497  {
498  $links = $sep = "";
499  foreach($refs as $r)
500  {
501  $cont_loc = new ilLocatorGUI();
502  $cont_loc->addContextItems($r, true);
503  $links.= $sep.$cont_loc->getHTML();
504  $sep = "<br />";
505  }
506 
507  $this->addProperty($lng->txt("res_links"),
508  '<div class="small">'.$links.'</div>'
509  );
510  }
511  }
512  }
513 
514 
515  // creation date
516  $this->addProperty(
517  $lng->txt("create_date"),
518  ilDatePresentation::formatDate(new ilDateTime($a_obj->getCreateDate(),IL_CAL_DATETIME)));
519 
520  // owner
521  if ($ilUser->getId() != ANONYMOUS_USER_ID and $a_obj->getOwner())
522  {
523  include_once 'classes/class.ilObjectFactory.php';
524  if(!$ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(),false))
525  {
526  $ownerObj = ilObjectFactory::getInstanceByObjId(6, false);
527  }
528 
529  if (! is_object($ownerObj)) // root user deleted
530  {
531  $this->addProperty($lng->txt("owner"), $lng->txt("no_owner"));
532  }
533  else if ($ownerObj->hasPublicProfile())
534  {
535  $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $ownerObj->getId());
536  $this->addProperty($lng->txt("owner"),$ownerObj->getPublicName(),$ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML"));
537  }
538  else
539  {
540  $this->addProperty($lng->txt("owner"),$ownerObj->getPublicName());
541  }
542  }
543 
544  // disk usage
545  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
546  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
548  {
549  $size = $a_obj->getDiskUsage();
550  if ($size !== null) {
551  $this->addProperty($lng->txt("disk_usage"),ilFormat::formatSize($size,'long'));
552  }
553  }
554  // change event
555  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
557  {
558  if ($ilUser->getId() != ANONYMOUS_USER_ID)
559  {
560  $readEvents = ilChangeEvent::_lookupReadEvents($a_obj->getId());
561  $count_users = 0;
562  $count_members = 0;
563  $count_user_reads = 0;
564  $count_anonymous_reads = 0;
565  foreach ($readEvents as $evt)
566  {
567  if ($evt['usr_id'] == ANONYMOUS_USER_ID)
568  {
569  $count_anonymous_reads += $evt['read_count'];
570  }
571  else
572  {
573  $count_user_reads += $evt['read_count'];
574  $count_users++;
575  /* to do: if ($evt['user_id'] is member of $this->getRefId())
576  {
577  $count_members++;
578  }*/
579  }
580  }
581  if ($count_anonymous_reads > 0)
582  {
583  $this->addProperty($this->lng->txt("readcount_anonymous_users"),$count_anonymous_reads);
584  }
585  if ($count_user_reads > 0)
586  {
587  $this->addProperty($this->lng->txt("readcount_users"),$count_user_reads);
588  }
589  if ($count_users > 0)
590  {
591  $this->addProperty($this->lng->txt("accesscount_registered_users"),$count_users);
592  }
593  }
594  }
595  // END ChangeEvent: Display change event info
596 
597  // BEGIN WebDAV: Display locking information
598  require_once('Services/WebDAV/classes/class.ilDAVServer.php');
600  {
601  global $ilias, $ilUser;
602  if ($ilUser->getId() != ANONYMOUS_USER_ID)
603  {
604  $davLocks = new ilDAVLocks();
605 
606  // Show lock info
607  if ($ilias->account->getId() != ANONYMOUS_USER_ID)
608  {
609  $locks =& $davLocks->getLocksOnObjectObj($a_obj->getId());
610  if (count($locks) > 0)
611  {
612  $lockUser = new ilObjUser($locks[0]['ilias_owner']);
613  $this->addProperty($this->lng->txt("in_use_by"),
614  $lockUser->getPublicName()
615  ,
616  "./ilias.php?user=".$locks[0]['ilias_owner'].'&cmd=showUserProfile&cmdClass=ilpersonaldesktopgui&cmdNode=1&baseClass=ilPersonalDesktopGUI'
617  );
618  }
619  }
620  }
621  }
622  // END WebDAV: Display locking information
623 
624 
625  }
626  // END ChangeEvent: Display standard object info
630  function showSummary()
631  {
632  global $tpl, $ilAccess;
633 
634  $tpl->setContent($this->getCenterColumnHTML());
635  $tpl->setRightContent($this->getRightColumnHTML());
636  }
637 
638 
643  {
644  global $ilCtrl;
645 
646  include_once("Services/Block/classes/class.ilColumnGUI.php");
647  $column_gui = new ilColumnGUI("info", IL_COL_CENTER);
648  $this->setColumnSettings($column_gui);
649 
650  if (!$ilCtrl->isAsynch())
651  {
652  if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
653  {
654  // right column wants center
655  if ($column_gui->getCmdSide() == IL_COL_RIGHT)
656  {
657  $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
658  $this->setColumnSettings($column_gui);
659  $html = $ilCtrl->forwardCommand($column_gui);
660  }
661  // left column wants center
662  if ($column_gui->getCmdSide() == IL_COL_LEFT)
663  {
664  $column_gui = new ilColumnGUI("info", IL_COL_LEFT);
665  $this->setColumnSettings($column_gui);
666  $html = $ilCtrl->forwardCommand($column_gui);
667  }
668  }
669  else
670  {
671  $html = $this->getHTML();
672  }
673  }
674 
675  return $html;
676  }
677 
682  {
683  global $ilUser, $lng, $ilCtrl;
684 
685  include_once("Services/Block/classes/class.ilColumnGUI.php");
686  $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
687  $this->setColumnSettings($column_gui);
688 
689  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
690  $column_gui->getCmdSide() == IL_COL_RIGHT &&
691  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
692  {
693  $html = $ilCtrl->forwardCommand($column_gui);
694  }
695  else
696  {
697  if (!$ilCtrl->isAsynch())
698  {
699  if ($this->news_enabled)
700  {
701  $html = $ilCtrl->getHTML($column_gui);
702  }
703  }
704  }
705 
706  return $html;
707  }
708 
712  function setColumnSettings($column_gui)
713  {
714  global $lng, $ilAccess;
715 
716  $column_gui->setEnableEdit($this->news_editing);
717  $column_gui->setRepositoryMode(true);
718  $column_gui->setAllBlockProperties($this->getAllBlockProperties());
719  }
720 
724  function getHTML()
725  {
726  global $lng, $ilSetting, $tree, $ilAccess, $ilCtrl, $ilUser;
727 
728  $tpl = new ilTemplate("tpl.infoscreen.html" ,true, true, "Services/InfoScreen");
729 
730  // other class handles form action (@todo: this is not implemented/tested)
731  if ($this->form_action == "")
732  {
733  $this->setFormAction($ilCtrl->getFormAction($this));
734  }
735 
736  // add top buttons
737  if (count($this->top_buttons) > 0)
738  {
739  $tpl->addBlockfile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html");
740 
741  foreach($this->top_buttons as $button)
742  {
743  // view button
744  $tpl->setCurrentBlock("btn_cell");
745  $tpl->setVariable("BTN_LINK", $button["link"]);
746  $tpl->setVariable("BTN_TARGET", $button["target"]);
747  $tpl->setVariable("BTN_TXT", $button["title"]);
748  $tpl->parseCurrentBlock();
749  }
750  }
751 
752  // add top formbuttons
753  if ((count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0))
754  {
755  $tpl->addBlockfile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html");
756 
757  foreach($this->top_formbuttons as $button)
758  {
759  // view button
760  $tpl->setCurrentBlock("btn_submit_cell");
761  $tpl->setVariable("BTN_COMMAND", $button["command"]);
762  $tpl->setVariable("BTN_NAME", $button["title"]);
763  $tpl->parseCurrentBlock();
764  }
765  }
766 
767  // add form action
768  if (strlen($this->form_action) > 0)
769  {
770  $tpl->setCurrentBlock("formtop");
771  $tpl->setVariable("FORMACTION", $this->form_action);
772  $tpl->parseCurrentBlock();
773  $tpl->touchBlock("formbottom");
774  }
775 
776  if (count($this->hiddenelements))
777  {
778  foreach ($this->hiddenelements as $hidden)
779  {
780  $tpl->setCurrentBlock("hidden_element");
781  $tpl->setVariable("HIDDEN_NAME", $hidden["name"]);
782  $tpl->setVariable("HIDDEN_VALUE", $hidden["value"]);
783  $tpl->parseCurrentBlock();
784  }
785  }
786 
787  // learning progress
788  if($this->learning_progress_enabled and $html = $this->showLearningProgress($tpl))
789  {
790  $tpl->setCurrentBlock("learning_progress");
791  $tpl->setVariable("LP_TABLE",$html);
792  $tpl->parseCurrentBlock();
793  }
794 
795  // notes section
796  if ($this->private_notes_enabled && !$ilSetting->get('disable_notes'))
797  {
798  $html = $this->showNotesSection();
799  $tpl->setCurrentBlock("notes");
800  $tpl->setVariable("NOTES", $html);
801  $tpl->parseCurrentBlock();
802  }
803 
804  // tagging
805  if (is_object($this->gui_object->object))
806  {
807  $tags_set = new ilSetting("tags");
808  if ($tags_set->get("enable") && $ilUser->getId() != ANONYMOUS_USER_ID)
809  {
810  $this->addTagging();
811  }
812  }
813 
814  if(is_object($this->gui_object->object))
815  {
816  $this->addObjectSections();
817  }
818 
819  // render all sections
820  for($i = 1; $i <= $this->sec_nr; $i++)
821  {
822  if (is_array($this->section[$i]["properties"]))
823  {
824  // section header
825  $tpl->setCurrentBlock("header_row");
826  $tpl->setVariable("TXT_SECTION",
827  $this->section[$i]["title"]);
828  $tpl->parseCurrentBlock();
829  $tpl->touchBlock("row");
830 
831  // section properties
832  foreach($this->section[$i]["properties"] as $property)
833  {
834  if ($property["name"] != "")
835  {
836  if ($property["link"] == "")
837  {
838  $tpl->setCurrentBlock("pv");
839  $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]);
840  $tpl->parseCurrentBlock();
841  }
842  else
843  {
844  $tpl->setCurrentBlock("lpv");
845  $tpl->setVariable("TXT_PROPERTY_LVALUE", $property["value"]);
846  $tpl->setVariable("LINK_PROPERTY_VALUE", $property["link"]);
847  $tpl->parseCurrentBlock();
848  }
849  $tpl->setCurrentBlock("property_row");
850  $tpl->setVariable("TXT_PROPERTY", $property["name"]);
851  $tpl->parseCurrentBlock();
852  $tpl->touchBlock("row");
853  }
854  else
855  {
856  $tpl->setCurrentBlock("property_full_row");
857  $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]);
858  $tpl->parseCurrentBlock();
859  $tpl->touchBlock("row");
860  }
861  }
862  }
863  }
864 
865  $tpl->setVariable("TCLASS", $this->getTableClass());
866 
867  return $tpl->get();
868  }
869 
870  function showLearningProgress($a_tpl)
871  {
872  global $ilUser,$rbacsystem;
873 
874  if(!$rbacsystem->checkAccess('read',$this->gui_object->object->getRefId()))
875  {
876  return false;
877  }
878  if($ilUser->getId() == ANONYMOUS_USER_ID)
879  {
880  return false;
881  }
882 
883  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
884  if (!ilObjUserTracking::_enabledLearningProgress() and $ilUser->getId() != ANONYMOUS_USER_ID)
885  {
886  return false;
887  }
888 
889  include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
890  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
891 
892  if(ilLPObjSettings::_lookupMode($this->gui_object->object->getId()) != LP_MODE_MANUAL)
893  {
894  return false;
895  }
896 
897 
898 
899  $this->lng->loadLanguageModule('trac');
900 
901  // section header
902  $a_tpl->setCurrentBlock("header_row");
903  $a_tpl->setVariable("TXT_SECTION",
904  $this->lng->txt('learning_progress'));
905  $a_tpl->parseCurrentBlock();
906  $a_tpl->touchBlock("row");
907 
908  // status
909  $i_tpl = new ilTemplate("tpl.lp_edit_manual_info_page.html", true, true, "Services/Tracking");
910  $i_tpl->setVariable("INFO_EDITED", $this->lng->txt("trac_info_edited"));
911  $i_tpl->setVariable("SELECT_STATUS", ilUtil::formSelect((int) ilLPMarks::_hasCompleted($ilUser->getId(),
912  $this->gui_object->object->getId()),
913  'lp_edit',
914  array(0 => $this->lng->txt('trac_not_completed'),
915  1 => $this->lng->txt('trac_completed')),
916  false,
917  true));
918  $i_tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
919  $a_tpl->setCurrentBlock("pv");
920  $a_tpl->setVariable("TXT_PROPERTY_VALUE", $i_tpl->get());
921  $a_tpl->parseCurrentBlock();
922  $a_tpl->setCurrentBlock("property_row");
923  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_status'));
924  $a_tpl->parseCurrentBlock();
925  $a_tpl->touchBlock("row");
926 
927 
928  // More infos for lm's
929  if($this->gui_object->object->getType() == 'lm' ||
930  $this->gui_object->object->getType() == 'htlm')
931  {
932  $a_tpl->setCurrentBlock("pv");
933 
934  include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
935  $progress = ilLearningProgress::_getProgress($ilUser->getId(),$this->gui_object->object->getId());
936  if($progress['access_time'])
937  {
938  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
939  ilDatePresentation::formatDate(new ilDateTime($progress['access_time'],IL_CAL_DATETIME)));
940  }
941  else
942  {
943  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
944  $this->lng->txt('trac_not_accessed'));
945  }
946 
947  $a_tpl->parseCurrentBlock();
948  $a_tpl->setCurrentBlock("property_row");
949  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_last_access'));
950  $a_tpl->parseCurrentBlock();
951  $a_tpl->touchBlock("row");
952 
953  // tags of all users
954  $a_tpl->setCurrentBlock("pv");
955  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
956  (int) $progress['visits']);
957  $a_tpl->parseCurrentBlock();
958  $a_tpl->setCurrentBlock("property_row");
959  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_visits'));
960  $a_tpl->parseCurrentBlock();
961  $a_tpl->touchBlock("row");
962 
963 
964  if($this->gui_object->object->getType() == 'lm')
965  {
966  // tags of all users
967  $a_tpl->setCurrentBlock("pv");
968  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
969  ilFormat::_secondsToString($progress['spent_seconds']));
970  $a_tpl->parseCurrentBlock();
971  $a_tpl->setCurrentBlock("property_row");
972  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_spent_time'));
973  $a_tpl->parseCurrentBlock();
974  $a_tpl->touchBlock("row");
975  }
976  }
977  }
978 
979  function saveProgress()
980  {
981  global $ilUser;
982 
983  include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
984  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
985 
986  $lp_marks = new ilLPMarks($this->gui_object->object->getId(),$ilUser->getId());
987  $lp_marks->setCompleted((bool) $_POST['lp_edit']);
988  $lp_marks->update();
989 
990  require_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
991  ilLPStatusWrapper::_updateStatus($this->gui_object->object->getId(),$ilUser->getId());
992 
993  $this->lng->loadLanguageModule('trac');
994  ilUtil::sendSuccess($this->lng->txt('trac_updated_status'));
995 
996  $this->showSummary();
997  }
998 
999 
1003  function showNotesSection()
1004  {
1005  global $ilAccess;
1006 
1007  $next_class = $this->ctrl->getNextClass($this);
1008  include_once("Services/Notes/classes/class.ilNoteGUI.php");
1009  $notes_gui = new ilNoteGUI($this->gui_object->object->getId(), 0,
1010  $this->gui_object->object->getType());
1011 
1012  $ref_id = $this->gui_object->object->getRefId();
1013  if ($ilAccess->checkAccess("write", "", $ref_id) ||
1014  $ilAccess->checkAccess("edit_permissions", "", $ref_id))
1015  {
1016  $notes_gui->enableCommentsSettings();
1017  }
1018 
1019  $notes_gui->enablePrivateNotes();
1020  //$notes_gui->enablePublicNotes();
1021 
1022  if ($next_class == "ilnotegui")
1023  {
1024  $html = $this->ctrl->forwardCommand($notes_gui);
1025  }
1026  else
1027  {
1028  $html = $notes_gui->getNotesHTML();
1029  }
1030 
1031  return $html;
1032  }
1033 
1041  public function showLDAPRoleGroupMappingInfo($a_section = '')
1042  {
1043  if(strlen($a_section))
1044  {
1045  $this->addSection($a_section);
1046  }
1047  include_once('Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1048  $ldap_mapping = ilLDAPRoleGroupMapping::_getInstance();
1049  if($infos = $ldap_mapping->getInfoStrings($this->gui_object->object->getId()))
1050  {
1051  $info_combined = '<div style="color:green;">';
1052  $counter = 0;
1053  foreach($infos as $info_string)
1054  {
1055  if($counter++)
1056  {
1057  $info_combined .= '<br />';
1058  }
1059  $info_combined .= $info_string;
1060  }
1061  $info_combined .= '</div>';
1062  $this->addProperty($this->lng->txt('applications'),$info_combined);
1063  }
1064  return true;
1065  }
1066 
1067  function setTabs()
1068  {
1069  global $tpl;
1070 
1071  $this->getTabs($this->tabs_gui);
1072  }
1073 
1077  function getTabs(&$tabs_gui)
1078  {
1079  global $rbacsystem,$ilUser,$ilAccess;
1080 
1081  $next_class = $this->ctrl->getNextClass($this);
1082  $force_active = ($next_class == "ilnotegui")
1083  ? true
1084  : false;
1085 
1086  $tabs_gui->addSubTabTarget('summary',
1087  $this->ctrl->getLinkTarget($this, "showSummary"),
1088  array("showSummary", ""),
1089  get_class($this), "", $force_active);
1090 
1091  if ($this->feedback_enabled)
1092  {
1093  $show_feedback_tab=false;
1094  if($ilAccess->checkAccess('write','edit',$_GET['ref_id']))
1095  {
1096  $show_feedback_tab=true;
1097  }
1098  else
1099  {
1100  // this should work with feedback class available
1101  // maybe a line... "@ ilCtrl_Calls ilFeedbackGUI:"
1102  // in the header of feedbackgui is necessary
1103  include_once('Services/Feedback/classes/class.ilFeedback.php');
1104  $feedback = new ilFeedback();
1105  $feedback->setRefId($_GET['ref_id']);
1106  $barometers = $feedback->getAllBarometer(0);
1107  if(count($barometers))
1108  {
1109  foreach ($barometers as $barometer)
1110  {
1111  if($barometer->canVote($ilUser->getId(),$barometer->getId())==1)
1112  {
1113  $show_feedback_tab=true;
1114  break;
1115  }
1116  }
1117  }
1118  }
1119  if ($show_feedback_tab)
1120  {
1121  $tabs_gui->addSubTabTarget("feedback",
1122  $this->ctrl->getLinkTargetByClass("ilfeedbackgui", "fbList"),
1123  "", "ilfeedbackgui");
1124  }
1125 
1126  /*
1127  $tabs_gui->addSubTabTarget("feedb_feedback_settings",
1128  $this->ctrl->getLinkTargetByClass("ilfeedbackgui", "fbList"),
1129  "", "ilfeedbackgui");*/
1130  }
1131  }
1132 
1133 
1137  function addTagging()
1138  {
1139  global $lng, $ilCtrl;
1140 
1141  $lng->loadLanguageModule("tagging");
1142  $tags_set = new ilSetting("tags");
1143 
1144  include_once("Services/Tagging/classes/class.ilTaggingGUI.php");
1145  $tagging_gui = new ilTaggingGUI();
1146  $tagging_gui->setObject($this->gui_object->object->getId(),
1147  $this->gui_object->object->getType());
1148 
1149  $this->addSection($lng->txt("tagging_tags"));
1150 
1151  if ($tags_set->get("enable_all_users"))
1152  {
1153  $this->addProperty($lng->txt("tagging_all_users"),
1154  $tagging_gui->getAllUserTagsForObjectHTML());
1155  }
1156 
1157  $this->addProperty($lng->txt("tagging_my_tags"),
1158  $tagging_gui->getTaggingInputHTML());
1159  }
1160 
1161  function saveTags()
1162  {
1163  global $ilCtrl;
1164 
1165  include_once("Services/Tagging/classes/class.ilTaggingGUI.php");
1166  $tagging_gui = new ilTaggingGUI();
1167  $tagging_gui->setObject($this->gui_object->object->getId(),
1168  $this->gui_object->object->getType());
1169  $tagging_gui->saveInput();
1170 
1171  return $this->showSummary();
1172  }
1173 }
1174 
1175 ?>