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