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