ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 {
23  protected static $cached_check_translate;
24 
25 
36  public static function _checkTranslate()
37  {
38  global $DIC;
39  $lng = $DIC->language();
40  $ilSetting = $DIC->settings();
41  $ilUser = $DIC->user();
42  $rbacsystem = $DIC->rbac()->system();
43 
44  if (!$ilSetting->get("lang_translate_" . $lng->getLangKey())) {
45  return false;
46  }
47 
48  if ($ilUser->getId()) {
49  $ref_id = self::_lookupLangFolderRefId();
50  return $rbacsystem->checkAccess("read,write", (int) $ref_id);
51  }
52  return false;
53  }
54 
55 
63  public static function _checkMaintenance()
64  {
65  global $DIC;
66  $ilSetting = $DIC->settings();
67  $ilUser = $DIC->user();
68  $rbacsystem = $DIC->rbac()->system();
69 
70  if ($ilUser->getId()) {
71  $ref_id = self::_lookupLangFolderRefId();
72  return $rbacsystem->checkAccess("read,write", (int) $ref_id);
73  }
74  return false;
75  }
76 
77 
83  public static function _lookupLangFolderRefId()
84  {
85  global $DIC;
86  $ilDB = $DIC->database();
87 
88  $q = "SELECT ref_id FROM object_reference r, object_data d" .
89  " WHERE r.obj_id = d.obj_id AND d.type = " . $ilDB->quote("lngf", "text");
90  $set = $ilDB->query($q);
91  $row = $ilDB->fetchAssoc($set);
92  return $row['ref_id'];
93  }
94 
95 
102  public static function _lookupId($a_key)
103  {
104  global $DIC;
105  $ilDB = $DIC->database();
106 
107  $q = "SELECT obj_id FROM object_data " .
108  " WHERE type = " . $ilDB->quote("lng", "text") .
109  " AND title = " . $ilDB->quote($a_key, "text");
110  $set = $ilDB->query($q);
111  $row = $ilDB->fetchAssoc($set);
112  return $row['obj_id'];
113  }
114 
115 
121  public static function _getTranslationLink()
122  {
123  // ref id must be given to prevent params being deleted by ilAdministrtionGUI
124  return "ilias.php"
125  . "?ref_id=" . self::_lookupLangFolderRefId()
126  . "&baseClass=ilAdministrationGUI"
127  . "&cmdClass=ilobjlanguageextgui"
128  . "&view_mode=translate"
129  . "&reset_offset=true";
130  }
131 
142  public static function _isPageTranslation()
143  {
144  return (strtolower($_GET['cmdClass'] == 'ilobjlanguageextgui') and $_GET['view_mode'] == "translate");
145  }
146 
147 
152  public static function _saveUsages()
153  {
154  global $DIC;
155  $lng = $DIC->language();
156 
157  if (self::_checkTranslate() and !self::_isPageTranslation()) {
158  $_SESSION['lang_ext_maintenance']['used_modules'] = array_keys($lng->getUsedModules());
159  $_SESSION['lang_ext_maintenance']['used_topics'] = array_keys($lng->getUsedTopics());
160  }
161  }
162 
168  public static function _getSavedModules()
169  {
170  $saved = $_SESSION['lang_ext_maintenance']['used_modules'];
171  return is_array($saved) ? $saved : array();
172  }
173 
179  public static function _getSavedTopics()
180  {
181  $saved = $_SESSION['lang_ext_maintenance']['used_topics'];
182  return is_array($saved) ? $saved : array();
183  }
184 }
$_SESSION["AccountId"]
static _isPageTranslation()
Check if the current request is a page translation.
$_GET["client_id"]
static _getSavedModules()
Get the stored modules from the user session.
static _checkMaintenance()
Permission check for language maintenance (import/export)
static _lookupId($a_key)
Lookup the object ID for a language key.
static _getTranslationLink()
Get the link to translate the current page.
$lng
$ilUser
Definition: imgupload.php:18
static _lookupLangFolderRefId()
Lookup the ref_id of the global language folder.
static _getSavedTopics()
Get the stored topics from the user session.
global $ilSetting
Definition: privfeed.php:17
global $ilDB
$DIC
Definition: xapitoken.php:46
static _saveUsages()
Store the collected language variable usages in the user session This should be called as late as pos...
static _checkTranslate()
Permission check for translations.