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