ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjLanguageAccess.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-20014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
18 {
30  static function _checkTranslate()
31  {
32  global $lng, $ilSetting, $ilUser, $rbacsystem;
33 
34  if (!$ilSetting->get("lang_ext_maintenance")
35  or !$ilSetting->get("lang_translate_".$lng->getLangKey()))
36  {
37  return false;
38  }
39 
40  if ($ilUser->getId())
41  {
43  return $rbacsystem->checkAccess("read,write", (int) $ref_id);
44  }
45  return false;
46  }
47 
48 
57  static function _checkMaintenance()
58  {
59  global $ilSetting, $ilUser, $rbacsystem;
60 
61  if (!$ilSetting->get("lang_ext_maintenance"))
62  {
63  return false;
64  }
65 
66  if ($ilUser->getId())
67  {
69  return $rbacsystem->checkAccess("read,write", (int) $ref_id);
70  }
71  return false;
72  }
73 
74 
80  static function _lookupLangFolderRefId()
81  {
82  global $ilDB;
83 
84  $q = "SELECT ref_id FROM object_reference r, object_data d".
85  " WHERE r.obj_id = d.obj_id AND d.type = ".$ilDB->quote("lngf", "text");
86  $set = $ilDB->query($q);
87  $row = $ilDB->fetchAssoc($set);
88  return $row['ref_id'];
89  }
90 
91 
98  static function _lookupId($a_key)
99  {
100  global $ilDB;
101 
102  $q = "SELECT obj_id FROM object_data ".
103  " WHERE type = ".$ilDB->quote("lng", "text").
104  " AND title = ".$ilDB->quote($a_key, "text");
105  $set = $ilDB->query($q);
106  $row = $ilDB->fetchAssoc($set);
107  return $row['obj_id'];
108  }
109 
110 
116  static function _getTranslationLink()
117  {
118  // ref id must be given to prevent params being deleted by ilAdministrtionGUI
119  return "ilias.php"
120  ."?ref_id=".self::_lookupLangFolderRefId()
121  ."&amp;baseClass=ilAdministrationGUI"
122  ."&amp;cmdClass=ilobjlanguageextgui"
123  ."&amp;view_mode=translate"
124  ."&amp;reset_offset=true";
125  }
126 
137  public static function _isPageTranslation()
138  {
139  return (strtolower($_GET['cmdClass'] == 'ilobjlanguageextgui') and $_GET['view_mode'] == "translate");
140  }
141 
142 
146  static function _saveUsages()
147  {
148  global $lng;
149  $_SESSION['lang_ext_maintenance']['used_modules'] = array_keys($lng->getUsedModules());
150  $_SESSION['lang_ext_maintenance']['used_topics'] = array_keys($lng->getUsedTopics());
151  }
152 
158  static function _getSavedModules()
159  {
160  $saved = $_SESSION['lang_ext_maintenance']['used_modules'];
161  return is_array($saved) ? $saved : array();
162  }
163 
169  static function _getSavedTopics()
170  {
171  $saved = $_SESSION['lang_ext_maintenance']['used_topics'];
172  return is_array($saved) ? $saved : array();
173  }
174 
175 }
176 
177 ?>