ILIAS  release_7 Revision v7.30-3-g800a261c036
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 (isset(self::$cached_check_translate)) {
46 }
47
48 if (!$ilSetting->get("lang_translate_" . $lng->getLangKey())) {
49 self::$cached_check_translate = false;
51 }
52
53 if ($ilUser->getId()) {
55 self::$cached_check_translate = $rbacsystem->checkAccess("read,write", (int) $ref_id);
56 }
57 else {
58 self::$cached_check_translate = false;
59 }
60
62 }
63
64
72 public static function _checkMaintenance()
73 {
74 global $DIC;
75 $ilSetting = $DIC->settings();
76 $ilUser = $DIC->user();
77 $rbacsystem = $DIC->rbac()->system();
78
79 if ($ilUser->getId()) {
81 return $rbacsystem->checkAccess("read,write", (int) $ref_id);
82 }
83 return false;
84 }
85
86
92 public static function _lookupLangFolderRefId()
93 {
94 global $DIC;
95 $ilDB = $DIC->database();
96
97 $q = "SELECT ref_id FROM object_reference r, object_data d" .
98 " WHERE r.obj_id = d.obj_id AND d.type = " . $ilDB->quote("lngf", "text");
99 $set = $ilDB->query($q);
100 $row = $ilDB->fetchAssoc($set);
101 return $row['ref_id'];
102 }
103
104
111 public static function _lookupId($a_key)
112 {
113 global $DIC;
114 $ilDB = $DIC->database();
115
116 $q = "SELECT obj_id FROM object_data " .
117 " WHERE type = " . $ilDB->quote("lng", "text") .
118 " AND title = " . $ilDB->quote($a_key, "text");
119 $set = $ilDB->query($q);
120 $row = $ilDB->fetchAssoc($set);
121 return $row['obj_id'];
122 }
123
124
130 public static function _getTranslationLink()
131 {
132 // ref id must be given to prevent params being deleted by ilAdministrtionGUI
133 return "ilias.php"
134 . "?ref_id=" . self::_lookupLangFolderRefId()
135 . "&baseClass=ilAdministrationGUI"
136 . "&cmdClass=ilobjlanguageextgui"
137 . "&view_mode=translate"
138 . "&reset_offset=true";
139 }
140
151 public static function _isPageTranslation()
152 {
153 return (strtolower($_GET['cmdClass'] == 'ilobjlanguageextgui') and $_GET['view_mode'] == "translate");
154 }
155
156
161 public static function _saveUsages()
162 {
163 global $DIC;
164 $lng = $DIC->language();
165
166 if (self::_checkTranslate() and !self::_isPageTranslation()) {
167 $_SESSION['lang_ext_maintenance']['used_modules'] = array_keys($lng->getUsedModules());
168 $_SESSION['lang_ext_maintenance']['used_topics'] = array_keys($lng->getUsedTopics());
169 }
170 }
171
177 public static function _getSavedModules()
178 {
179 $saved = $_SESSION['lang_ext_maintenance']['used_modules'];
180 return is_array($saved) ? $saved : array();
181 }
182
188 public static function _getSavedTopics()
189 {
190 $saved = $_SESSION['lang_ext_maintenance']['used_topics'];
191 return is_array($saved) ? $saved : array();
192 }
193}
$_GET["client_id"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
static _getSavedTopics()
Get the stored topics from the user session.
static _lookupId($a_key)
Lookup the object ID for a language key.
static _getSavedModules()
Get the stored modules from the user session.
static _saveUsages()
Store the collected language variable usages in the user session This should be called as late as pos...
static _checkMaintenance()
Permission check for language maintenance (import/export)
static _lookupLangFolderRefId()
Lookup the ref_id of the global language folder.
static _checkTranslate()
Permission check for translations.
static _isPageTranslation()
Check if the current request is a page translation.
static _getTranslationLink()
Get the link to translate the current page.
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
global $ilSetting
Definition: privfeed.php:17
$lng
global $ilDB