ILIAS  Release_4_4_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 = "<input 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 = " emphsubmit";
267  }
268  $input .= " <input type=\"submit\" class=\"submit".$css."\" name=\"cmd[$direct_button_command]\" value=\"$direct_button_label\" />";
269  }
270  $this->section[$this->sec_nr]["properties"][] =
271  array("name" => "<label for=\"$a_input_name\">$a_name</label>", "value" => $input);
272  }
273 
277  function addButton($a_title, $a_link, $a_frame = "", $a_position = "top", $a_primary = false)
278  {
279  if ($a_position == "top")
280  {
281  $this->top_buttons[] =
282  array("title" => $a_title,"link" => $a_link,"target" => $a_frame,"primary" => $a_primary);
283  }
284  }
285 
290  function addFormButton($a_command, $a_title, $a_position = "top")
291  {
292  if ($a_position == "top")
293  {
294  array_push($this->top_formbuttons,
295  array("command" => $a_command, "title" => $a_title)
296  );
297  }
298  }
299 
300  function addHiddenElement($a_name, $a_value)
301  {
302  array_push($this->hiddenelements, array("name" => $a_name, "value" => $a_value));
303  }
304 
308  function addMetaDataSections($a_rep_obj_id,$a_obj_id, $a_type)
309  {
310  global $lng;
311 
312  $lng->loadLanguageModule("meta");
313 
314  include_once("./Services/MetaData/classes/class.ilMD.php");
315  $md = new ilMD($a_rep_obj_id,$a_obj_id, $a_type);
316 
317  if ($md_gen = $md->getGeneral())
318  {
319  // get first descrption
320  // The description is shown on the top of the page.
321  // Thus it is not necessary to show it again.
322  foreach($md_gen->getDescriptionIds() as $id)
323  {
324  $md_des = $md_gen->getDescription($id);
325  $description = $md_des->getDescription();
326  break;
327  }
328 
329  // get language(s)
330  $langs = array();
331  foreach($ids = $md_gen->getLanguageIds() as $id)
332  {
333  $md_lan = $md_gen->getLanguage($id);
334  if ($md_lan->getLanguageCode() != "")
335  {
336  $langs[] = $lng->txt("meta_l_".$md_lan->getLanguageCode());
337  }
338  }
339  $langs = implode($langs, ", ");
340 
341  // keywords
342  $keywords = array();
343  foreach($ids = $md_gen->getKeywordIds() as $id)
344  {
345  $md_key = $md_gen->getKeyword($id);
346  $keywords[] = $md_key->getKeyword();
347  }
348  $keywords = implode($keywords, ", ");
349  }
350 
351  // authors
352  if(is_object($lifecycle = $md->getLifecycle()))
353  {
354  $sep = $author = "";
355  foreach(($ids = $lifecycle->getContributeIds()) as $con_id)
356  {
357  $md_con = $lifecycle->getContribute($con_id);
358  if ($md_con->getRole() == "Author")
359  {
360  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
361  {
362  $md_ent = $md_con->getEntity($ent_id);
363  $author = $author.$sep.$md_ent->getEntity();
364  $sep = ", ";
365  }
366  }
367  }
368  }
369 
370  // copyright
371  $copyright = "";
372  if(is_object($rights = $md->getRights()))
373  {
374  include_once('Services/MetaData/classes/class.ilMDUtils.php');
375  $copyright = ilMDUtils::_parseCopyright($rights->getDescription());
376  }
377 
378  // learning time
379  #if(is_object($educational = $md->getEducational()))
380  #{
381  # $learning_time = $educational->getTypicalLearningTime();
382  #}
383  $learning_time = "";
384  if(is_object($educational = $md->getEducational()))
385  {
386  if($seconds = $educational->getTypicalLearningTimeSeconds())
387  {
388  $learning_time = ilFormat::_secondsToString($seconds);
389  }
390  }
391 
392 
393  // output
394 
395  // description
396  if ($description != "")
397  {
398  $this->addSection($lng->txt("description"));
399  $this->addProperty("", nl2br($description));
400  }
401 
402  // general section
403  $this->addSection($lng->txt("meta_general"));
404  if ($langs != "") // language
405  {
406  $this->addProperty($lng->txt("language"),
407  $langs);
408  }
409  if ($keywords != "") // keywords
410  {
411  $this->addProperty($lng->txt("keywords"),
412  $keywords);
413  }
414  if ($author != "") // author
415  {
416  $this->addProperty($lng->txt("author"),
417  $author);
418  }
419  if ($copyright != "") // copyright
420  {
421  $this->addProperty($lng->txt("meta_copyright"),
422  $copyright);
423  }
424  if ($learning_time != "") // typical learning time
425  {
426  $this->addProperty($lng->txt("meta_typical_learning_time"),
427  $learning_time);
428  }
429  }
430 
434  function addObjectSections()
435  {
436  global $lng, $ilCtrl, $ilUser, $ilAccess, $tree, $ilSetting, $ilObjDataCache;
437 
438  $this->addSection($lng->txt("additional_info"));
439  $a_obj = $this->gui_object->object;
440 
441  // links to the object
442  if (is_object($a_obj))
443  {
444  // permanent link
445  $type = $a_obj->getType();
446  $ref_id = $a_obj->getRefId();
447 
448  if($ref_id)
449  {
450  include_once('./Services/Link/classes/class.ilLink.php');
451  $href = ilLink::_getStaticLink($ref_id,$type,true);
452 
453  // delicous link
454  $d_set = new ilSetting("delicious");
455  if (true || $d_set->get("add_info_links") == "1")
456  {
457  $lng->loadLanguageModule("delic");
458  $del_link = '<br/><a class="small" href="http://del.icio.us/post?desc=nn&url='.
459  urlencode($href).'"><img border="0" src="'.ilUtil::getImagePath("icon_delicious_s.png").
460  '" /> '.$lng->txt("delic_add_to_delicious").
461  '</a>';
462  }
463 
464  include_once 'Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
465  if(ilECSServerSettings::getInstance()->activeServerExists())
466  {
467  $this->addProperty($lng->txt("object_id"),
468  $a_obj->getId()
469  );
470  }
471 
472  include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
473  $pm = new ilPermanentLinkGUI($type, $ref_id);
474  $pm->setIncludePermanentLinkText(false);
475  $pm->setAlignCenter(false);
476  $this->addProperty($lng->txt("perma_link"),
477  $pm->getHTML(),
478  ""
479  );
480 
481  // bookmarks
482 
483  $title = $ilObjDataCache->lookupTitle($a_obj->getId());
484 
486 
487  // links to resource
488  if ($ilAccess->checkAccess("write", "", $ref_id) ||
489  $ilAccess->checkAccess("edit_permissions", "", $ref_id))
490  {
491  $obj_id = $a_obj->getId();
492  $rs = ilObject::_getAllReferences($obj_id);
493  $refs = array();
494  foreach($rs as $r)
495  {
496  if ($tree->isInTree($r))
497  {
498  $refs[] = $r;
499  }
500  }
501  if (count($refs) > 1)
502  {
503  $links = $sep = "";
504  foreach($refs as $r)
505  {
506  $cont_loc = new ilLocatorGUI();
507  $cont_loc->addContextItems($r, true);
508  $links.= $sep.$cont_loc->getHTML();
509  $sep = "<br />";
510  }
511 
512  $this->addProperty($lng->txt("res_links"),
513  '<div class="small">'.$links.'</div>'
514  );
515  }
516  }
517  }
518  }
519 
520 
521  // creation date
522  $this->addProperty(
523  $lng->txt("create_date"),
524  ilDatePresentation::formatDate(new ilDateTime($a_obj->getCreateDate(),IL_CAL_DATETIME)));
525 
526  // owner
527  if ($ilUser->getId() != ANONYMOUS_USER_ID and $a_obj->getOwner())
528  {
529  include_once './Services/Object/classes/class.ilObjectFactory.php';
530  include_once './Services/User/classes/class.ilObjUser.php';
531 
532  if(ilObjUser::userExists(array($a_obj->getOwner())))
533  {
534  $ownerObj = ilObjectFactory::getInstanceByObjId($a_obj->getOwner(),false);
535  }
536  else
537  {
538  $ownerObj = ilObjectFactory::getInstanceByObjId(6, false);
539  }
540 
541  if (!is_object($ownerObj) || $ownerObj->getType() != "usr") // root user deleted
542  {
543  $this->addProperty($lng->txt("owner"), $lng->txt("no_owner"));
544  }
545  else if ($ownerObj->hasPublicProfile())
546  {
547  $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $ownerObj->getId());
548  $this->addProperty($lng->txt("owner"),$ownerObj->getPublicName(),$ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML"));
549  }
550  else
551  {
552  $this->addProperty($lng->txt("owner"),$ownerObj->getPublicName());
553  }
554  }
555 
556  // disk usage
557  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
558  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
560  {
561  $size = $a_obj->getDiskUsage();
562  if ($size !== null) {
563  $this->addProperty($lng->txt("disk_usage"),ilFormat::formatSize($size,'long'));
564  }
565  }
566  // change event
567  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
569  {
570  if ($ilUser->getId() != ANONYMOUS_USER_ID)
571  {
572  $readEvents = ilChangeEvent::_lookupReadEvents($a_obj->getId());
573  $count_users = 0;
574  $count_members = 0;
575  $count_user_reads = 0;
576  $count_anonymous_reads = 0;
577  foreach ($readEvents as $evt)
578  {
579  if ($evt['usr_id'] == ANONYMOUS_USER_ID)
580  {
581  $count_anonymous_reads += $evt['read_count'];
582  }
583  else
584  {
585  $count_user_reads += $evt['read_count'];
586  $count_users++;
587  /* to do: if ($evt['user_id'] is member of $this->getRefId())
588  {
589  $count_members++;
590  }*/
591  }
592  }
593  if ($count_anonymous_reads > 0)
594  {
595  $this->addProperty($this->lng->txt("readcount_anonymous_users"),$count_anonymous_reads);
596  }
597  if ($count_user_reads > 0)
598  {
599  $this->addProperty($this->lng->txt("readcount_users"),$count_user_reads);
600  }
601  if ($count_users > 0)
602  {
603  $this->addProperty($this->lng->txt("accesscount_registered_users"),$count_users);
604  }
605  }
606  }
607  // END ChangeEvent: Display change event info
608 
609  // BEGIN WebDAV: Display locking information
610  require_once('Services/WebDAV/classes/class.ilDAVServer.php');
612  {
613  global $ilias, $ilUser;
614  if ($ilUser->getId() != ANONYMOUS_USER_ID)
615  {
616  $davLocks = new ilDAVLocks();
617 
618  // Show lock info
619  if ($ilias->account->getId() != ANONYMOUS_USER_ID)
620  {
621  $locks =& $davLocks->getLocksOnObjectObj($a_obj->getId());
622  if (count($locks) > 0)
623  {
624  $lockUser = new ilObjUser($locks[0]['ilias_owner']);
625  $this->addProperty($this->lng->txt("in_use_by"),
626  $lockUser->getPublicName()
627  ,
628  "./ilias.php?user=".$locks[0]['ilias_owner'].'&cmd=showUserProfile&cmdClass=ilpersonaldesktopgui&cmdNode=1&baseClass=ilPersonalDesktopGUI'
629  );
630  }
631  }
632  }
633  }
634  // END WebDAV: Display locking information
635 
636 
637  }
638  // END ChangeEvent: Display standard object info
642  function showSummary()
643  {
644  global $tpl, $ilAccess;
645 
646  $tpl->setContent($this->getCenterColumnHTML());
647  $tpl->setRightContent($this->getRightColumnHTML());
648  }
649 
650 
655  {
656  global $ilCtrl;
657 
658  include_once("Services/Block/classes/class.ilColumnGUI.php");
659  $column_gui = new ilColumnGUI("info", IL_COL_CENTER);
660  $this->setColumnSettings($column_gui);
661 
662  if (!$ilCtrl->isAsynch())
663  {
664  if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
665  {
666  // right column wants center
667  if ($column_gui->getCmdSide() == IL_COL_RIGHT)
668  {
669  $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
670  $this->setColumnSettings($column_gui);
671  $html = $ilCtrl->forwardCommand($column_gui);
672  }
673  // left column wants center
674  if ($column_gui->getCmdSide() == IL_COL_LEFT)
675  {
676  $column_gui = new ilColumnGUI("info", IL_COL_LEFT);
677  $this->setColumnSettings($column_gui);
678  $html = $ilCtrl->forwardCommand($column_gui);
679  }
680  }
681  else
682  {
683  $html = $this->getHTML();
684  }
685  }
686 
687  return $html;
688  }
689 
694  {
695  global $ilUser, $lng, $ilCtrl;
696 
697  include_once("Services/Block/classes/class.ilColumnGUI.php");
698  $column_gui = new ilColumnGUI("info", IL_COL_RIGHT);
699  $this->setColumnSettings($column_gui);
700 
701  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
702  $column_gui->getCmdSide() == IL_COL_RIGHT &&
703  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
704  {
705  $html = $ilCtrl->forwardCommand($column_gui);
706  }
707  else
708  {
709  if (!$ilCtrl->isAsynch())
710  {
711  if ($this->news_enabled)
712  {
713  $html = $ilCtrl->getHTML($column_gui);
714  }
715  }
716  }
717 
718  return $html;
719  }
720 
724  function setColumnSettings($column_gui)
725  {
726  global $lng, $ilAccess;
727 
728  $column_gui->setEnableEdit($this->news_editing);
729  $column_gui->setRepositoryMode(true);
730  $column_gui->setAllBlockProperties($this->getAllBlockProperties());
731  }
732 
733  function setOpenFormTag($a_val)
734  {
735  $this->open_form_tag = $a_val;
736  }
737 
738  function setCloseFormTag($a_val)
739  {
740  $this->close_form_tag = $a_val;
741  }
742 
746  function getHTML()
747  {
748  global $lng, $ilSetting, $tree, $ilAccess, $ilCtrl, $ilUser;
749 
750  $tpl = new ilTemplate("tpl.infoscreen.html" ,true, true, "Services/InfoScreen");
751 
752  // other class handles form action (@todo: this is not implemented/tested)
753  if ($this->form_action == "")
754  {
755  $this->setFormAction($ilCtrl->getFormAction($this));
756  }
757 
758  require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
760 
761  if($this->hidden)
762  {
763  $tpl->touchBlock("hidden_js");
764  if($this->show_hidden_toggle)
765  {
766  $this->addButton($lng->txt("show_hidden_sections"), "JavaScript:toggleSections(this, '".$lng->txt("show_hidden_sections") ."', '".$lng->txt("hide_visible_sections") ."');");
767  }
768  }
769  // add top buttons
770  if (count($this->top_buttons) > 0)
771  {
772  $tpl->addBlockfile("TOP_BUTTONS", "top_buttons", "tpl.buttons.html");
773 
774  foreach($this->top_buttons as $button)
775  {
776  // view button
777  $tpl->setCurrentBlock("btn_cell");
778  $tpl->setVariable("BTN_LINK", $button["link"]);
779  $tpl->setVariable("BTN_TARGET", $button["target"]);
780  $tpl->setVariable("BTN_TXT", $button["title"]);
781  if($button["primary"])
782  {
783  $tpl->setVariable("BTN_CLASS", " emphsubmit");
784  }
785  $tpl->parseCurrentBlock();
786  }
787  }
788 
789  // add top formbuttons
790  if ((count($this->top_formbuttons) > 0) && (strlen($this->form_action) > 0))
791  {
792  $tpl->addBlockfile("TOP_FORMBUTTONS", "top_submitbuttons", "tpl.submitbuttons.html", "Services/InfoScreen");
793 
794  foreach($this->top_formbuttons as $button)
795  {
796  // view button
797  $tpl->setCurrentBlock("btn_submit_cell");
798  $tpl->setVariable("BTN_COMMAND", $button["command"]);
799  $tpl->setVariable("BTN_NAME", $button["title"]);
800  $tpl->parseCurrentBlock();
801  }
802  }
803 
804  // add form action
805  if (strlen($this->form_action) > 0)
806  {
807  if($this->open_form_tag)
808  {
809  $tpl->setCurrentBlock("formtop");
810  $tpl->setVariable("FORMACTION", $this->form_action);
811  $tpl->parseCurrentBlock();
812  }
813 
814  if($this->close_form_tag)
815  {
816  $tpl->touchBlock("formbottom");
817  }
818  }
819 
820  if (count($this->hiddenelements))
821  {
822  foreach ($this->hiddenelements as $hidden)
823  {
824  $tpl->setCurrentBlock("hidden_element");
825  $tpl->setVariable("HIDDEN_NAME", $hidden["name"]);
826  $tpl->setVariable("HIDDEN_VALUE", $hidden["value"]);
827  $tpl->parseCurrentBlock();
828  }
829  }
830 
831  // learning progress
832  if($this->learning_progress_enabled and $html = $this->showLearningProgress($tpl))
833  {
834  $tpl->setCurrentBlock("learning_progress");
835  $tpl->setVariable("LP_TABLE",$html);
836  $tpl->parseCurrentBlock();
837  }
838 
839  // notes section
840  if ($this->private_notes_enabled && !$ilSetting->get('disable_notes'))
841  {
842  $html = $this->showNotesSection();
843  $tpl->setCurrentBlock("notes");
844  $tpl->setVariable("NOTES", $html);
845  $tpl->parseCurrentBlock();
846  }
847 
848  // tagging
849  if (is_object($this->gui_object->object))
850  {
851  $tags_set = new ilSetting("tags");
852  if ($tags_set->get("enable") && $ilUser->getId() != ANONYMOUS_USER_ID)
853  {
854  $this->addTagging();
855  }
856  }
857 
858  if(is_object($this->gui_object->object))
859  {
860  $this->addObjectSections();
861  }
862 
863  // render all sections
864  for($i = 1; $i <= $this->sec_nr; $i++)
865  {
866  if (is_array($this->section[$i]["properties"]))
867  {
868  // section properties
869  foreach($this->section[$i]["properties"] as $property)
870  {
871  if ($property["name"] != "")
872  {
873  if ($property["link"] == "")
874  {
875  $tpl->setCurrentBlock("pv");
876  $tpl->setVariable("TXT_PROPERTY_VALUE", $property["value"]);
877  $tpl->parseCurrentBlock();
878  }
879  else
880  {
881  $tpl->setCurrentBlock("lpv");
882  $tpl->setVariable("TXT_PROPERTY_LVALUE", $property["value"]);
883  $tpl->setVariable("LINK_PROPERTY_VALUE", $property["link"]);
884  $tpl->parseCurrentBlock();
885  }
886  $tpl->setCurrentBlock("property_row");
887  $tpl->setVariable("TXT_PROPERTY", $property["name"]);
888  $tpl->parseCurrentBlock();
889  }
890  else
891  {
892  $tpl->setCurrentBlock("property_full_row");
893  $tpl->setVariable("TXT_PROPERTY_FULL_VALUE", $property["value"]);
894  $tpl->parseCurrentBlock();
895  }
896  }
897 
898  // section header
899  if($this->section[$i]["hidden"])
900  {
901  $tpl->setVariable("SECTION_HIDDEN", " style=\"display:none;\"");
902  $tpl->setVariable("SECTION_ID", "hidable_".$i);
903  }
904  else
905  {
906  $tpl->setVariable("SECTION_ID", $i);
907  }
908  $tpl->setVariable("TCLASS", $this->getTableClass());
909  $tpl->setVariable("TXT_SECTION", $this->section[$i]["title"]);
910  $tpl->touchBlock("row");
911  }
912  }
913 
914  return $tpl->get();
915  }
916 
917  function showLearningProgress($a_tpl)
918  {
919  global $ilUser,$rbacsystem;
920 
921  if(!$rbacsystem->checkAccess('read',$this->gui_object->object->getRefId()))
922  {
923  return false;
924  }
925  if($ilUser->getId() == ANONYMOUS_USER_ID)
926  {
927  return false;
928  }
929 
930  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
931  if (!ilObjUserTracking::_enabledLearningProgress() and $ilUser->getId() != ANONYMOUS_USER_ID)
932  {
933  return false;
934  }
935 
936  include_once './Services/Object/classes/class.ilObjectLP.php';
937  $olp = ilObjectLP::getInstance($this->gui_object->object->getId());
938  if($olp->getCurrentMode() != ilLPObjSettings::LP_MODE_MANUAL)
939  {
940  return false;
941  }
942 
943  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
944 
945  $this->lng->loadLanguageModule('trac');
946 
947  // section header
948 // $a_tpl->setCurrentBlock("header_row");
949  $a_tpl->setVariable("TXT_SECTION",
950  $this->lng->txt('learning_progress'));
951  $a_tpl->parseCurrentBlock();
952  // $a_tpl->touchBlock("row");
953 
954  // status
955  $i_tpl = new ilTemplate("tpl.lp_edit_manual_info_page.html", true, true, "Services/Tracking");
956  $i_tpl->setVariable("INFO_EDITED", $this->lng->txt("trac_info_edited"));
957  $i_tpl->setVariable("SELECT_STATUS", ilUtil::formSelect((int) ilLPMarks::_hasCompleted($ilUser->getId(),
958  $this->gui_object->object->getId()),
959  'lp_edit',
960  array(0 => $this->lng->txt('trac_not_completed'),
961  1 => $this->lng->txt('trac_completed')),
962  false,
963  true));
964  $i_tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
965  $a_tpl->setCurrentBlock("pv");
966  $a_tpl->setVariable("TXT_PROPERTY_VALUE", $i_tpl->get());
967  $a_tpl->parseCurrentBlock();
968  $a_tpl->setCurrentBlock("property_row");
969  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_status'));
970  $a_tpl->parseCurrentBlock();
971  // $a_tpl->touchBlock("row");
972 
973 
974  // More infos for lm's
975  if($this->gui_object->object->getType() == 'lm' ||
976  $this->gui_object->object->getType() == 'htlm')
977  {
978  $a_tpl->setCurrentBlock("pv");
979 
980  include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
981  $progress = ilLearningProgress::_getProgress($ilUser->getId(),$this->gui_object->object->getId());
982  if($progress['access_time'])
983  {
984  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
985  ilDatePresentation::formatDate(new ilDateTime($progress['access_time'],IL_CAL_DATETIME)));
986  }
987  else
988  {
989  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
990  $this->lng->txt('trac_not_accessed'));
991  }
992 
993  $a_tpl->parseCurrentBlock();
994  $a_tpl->setCurrentBlock("property_row");
995  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_last_access'));
996  $a_tpl->parseCurrentBlock();
997  // $a_tpl->touchBlock("row");
998 
999  // tags of all users
1000  $a_tpl->setCurrentBlock("pv");
1001  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
1002  (int) $progress['visits']);
1003  $a_tpl->parseCurrentBlock();
1004  $a_tpl->setCurrentBlock("property_row");
1005  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_visits'));
1006  $a_tpl->parseCurrentBlock();
1007  // $a_tpl->touchBlock("row");
1008 
1009 
1010  if($this->gui_object->object->getType() == 'lm')
1011  {
1012  // tags of all users
1013  $a_tpl->setCurrentBlock("pv");
1014  $a_tpl->setVariable("TXT_PROPERTY_VALUE",
1015  ilFormat::_secondsToString($progress['spent_seconds']));
1016  $a_tpl->parseCurrentBlock();
1017  $a_tpl->setCurrentBlock("property_row");
1018  $a_tpl->setVariable("TXT_PROPERTY", $this->lng->txt('trac_spent_time'));
1019  $a_tpl->parseCurrentBlock();
1020  // $a_tpl->touchBlock("row");
1021  }
1022  }
1023 
1024  // #10493
1025  $a_tpl->touchBlock("row");
1026  }
1027 
1028  function saveProgress()
1029  {
1030  global $ilUser;
1031 
1032  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
1033 
1034  $lp_marks = new ilLPMarks($this->gui_object->object->getId(),$ilUser->getId());
1035  $lp_marks->setCompleted((bool) $_POST['lp_edit']);
1036  $lp_marks->update();
1037 
1038  require_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
1039  ilLPStatusWrapper::_updateStatus($this->gui_object->object->getId(),$ilUser->getId());
1040 
1041  $this->lng->loadLanguageModule('trac');
1042  ilUtil::sendSuccess($this->lng->txt('trac_updated_status'));
1043 
1044  $this->showSummary();
1045  }
1046 
1047 
1051  function showNotesSection()
1052  {
1053  global $ilAccess, $ilSetting;
1054 
1055  $next_class = $this->ctrl->getNextClass($this);
1056  include_once("Services/Notes/classes/class.ilNoteGUI.php");
1057  $notes_gui = new ilNoteGUI($this->gui_object->object->getId(), 0,
1058  $this->gui_object->object->getType());
1059 
1060  // global switch
1061  if($ilSetting->get("disable_comments"))
1062  {
1063  $notes_gui->enablePublicNotes(false);
1064  }
1065  else
1066  {
1067  /* should probably be discussed further
1068  for now this will only work properly with comments settings
1069  (see ilNoteGUI constructor)
1070  */
1071  $ref_id = $this->gui_object->object->getRefId();
1072  if ($ilAccess->checkAccess("write", "", $ref_id) ||
1073  $ilAccess->checkAccess("edit_permissions", "", $ref_id))
1074  {
1075  $notes_gui->enableCommentsSettings();
1076  }
1077  }
1078 
1079  /* moved to action menu
1080  $notes_gui->enablePrivateNotes();
1081  */
1082 
1083  if ($next_class == "ilnotegui")
1084  {
1085  $html = $this->ctrl->forwardCommand($notes_gui);
1086  }
1087  else
1088  {
1089  $html = $notes_gui->getNotesHTML();
1090  }
1091 
1092  return $html;
1093  }
1094 
1102  public function showLDAPRoleGroupMappingInfo($a_section = '')
1103  {
1104  if(strlen($a_section))
1105  {
1106  $this->addSection($a_section);
1107  }
1108  include_once('Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
1109  $ldap_mapping = ilLDAPRoleGroupMapping::_getInstance();
1110  if($infos = $ldap_mapping->getInfoStrings($this->gui_object->object->getId()))
1111  {
1112  $info_combined = '<div style="color:green;">';
1113  $counter = 0;
1114  foreach($infos as $info_string)
1115  {
1116  if($counter++)
1117  {
1118  $info_combined .= '<br />';
1119  }
1120  $info_combined .= $info_string;
1121  }
1122  $info_combined .= '</div>';
1123  $this->addProperty($this->lng->txt('applications'),$info_combined);
1124  }
1125  return true;
1126  }
1127 
1128  function setTabs()
1129  {
1130  global $tpl;
1131 
1132  $this->getTabs($this->tabs_gui);
1133  }
1134 
1138  function getTabs(&$tabs_gui)
1139  {
1140  global $rbacsystem,$ilUser,$ilAccess;
1141 
1142  $next_class = $this->ctrl->getNextClass($this);
1143  $force_active = ($next_class == "ilnotegui")
1144  ? true
1145  : false;
1146 
1147  $tabs_gui->addSubTabTarget('summary',
1148  $this->ctrl->getLinkTarget($this, "showSummary"),
1149  array("showSummary", ""),
1150  get_class($this), "", $force_active);
1151  }
1152 
1153 
1157  function addTagging()
1158  {
1159  global $lng, $ilCtrl;
1160 
1161  $lng->loadLanguageModule("tagging");
1162  $tags_set = new ilSetting("tags");
1163 
1164  include_once("Services/Tagging/classes/class.ilTaggingGUI.php");
1165  $tagging_gui = new ilTaggingGUI();
1166  $tagging_gui->setObject($this->gui_object->object->getId(),
1167  $this->gui_object->object->getType());
1168 
1169  $this->addSection($lng->txt("tagging_tags"));
1170 
1171  if ($tags_set->get("enable_all_users"))
1172  {
1173  $this->addProperty($lng->txt("tagging_all_users"),
1174  $tagging_gui->getAllUserTagsForObjectHTML());
1175  }
1176 
1177  $this->addProperty($lng->txt("tagging_my_tags"),
1178  $tagging_gui->getTaggingInputHTML());
1179  }
1180 
1181  function saveTags()
1182  {
1183  global $ilCtrl;
1184 
1185  include_once("Services/Tagging/classes/class.ilTaggingGUI.php");
1186  $tagging_gui = new ilTaggingGUI();
1187  $tagging_gui->setObject($this->gui_object->object->getId(),
1188  $this->gui_object->object->getType());
1189  $tagging_gui->saveInput();
1190 
1191  return $this->showSummary();
1192  }
1193 
1194  function hideFurtherSections($a_add_toggle = true)
1195  {
1196  $this->hidden = true;
1197  $this->show_hidden_toggle = (bool)$a_add_toggle;
1198  }
1199 
1201  {
1202  global $lng;
1203 
1204  return "<a onClick=\"toggleSections(this, '".$lng->txt("show_hidden_sections") ."', '".$lng->txt("hide_visible_sections") ."');\" href=\"#\">".$lng->txt("show_hidden_sections")."</a>";
1205  }
1206 }
1207 
1208 ?>