ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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{
29 public static function _checkTranslate()
30 {
31 global $DIC;
32 $lng = $DIC->language();
33 $ilSetting = $DIC->settings();
34 $ilUser = $DIC->user();
35 $rbacsystem = $DIC->rbac()->system();
36
37 if (!$ilSetting->get("lang_translate_" . $lng->getLangKey())) {
38 return false;
39 }
40
41 if ($ilUser->getId()) {
43 return $rbacsystem->checkAccess("read,write", (int) $ref_id);
44 }
45 return false;
46 }
47
48
56 public static function _checkMaintenance()
57 {
58 global $DIC;
59 $ilSetting = $DIC->settings();
60 $ilUser = $DIC->user();
61 $rbacsystem = $DIC->rbac()->system();
62
63 if ($ilUser->getId()) {
65 return $rbacsystem->checkAccess("read,write", (int) $ref_id);
66 }
67 return false;
68 }
69
70
76 public static function _lookupLangFolderRefId()
77 {
78 global $DIC;
79 $ilDB = $DIC->database();
80
81 $q = "SELECT ref_id FROM object_reference r, object_data d" .
82 " WHERE r.obj_id = d.obj_id AND d.type = " . $ilDB->quote("lngf", "text");
83 $set = $ilDB->query($q);
84 $row = $ilDB->fetchAssoc($set);
85 return $row['ref_id'];
86 }
87
88
95 public static function _lookupId($a_key)
96 {
97 global $DIC;
98 $ilDB = $DIC->database();
99
100 $q = "SELECT obj_id FROM object_data " .
101 " WHERE type = " . $ilDB->quote("lng", "text") .
102 " AND title = " . $ilDB->quote($a_key, "text");
103 $set = $ilDB->query($q);
104 $row = $ilDB->fetchAssoc($set);
105 return $row['obj_id'];
106 }
107
108
114 public static function _getTranslationLink()
115 {
116 // ref id must be given to prevent params being deleted by ilAdministrtionGUI
117 return "ilias.php"
118 . "?ref_id=" . self::_lookupLangFolderRefId()
119 . "&baseClass=ilAdministrationGUI"
120 . "&cmdClass=ilobjlanguageextgui"
121 . "&view_mode=translate"
122 . "&reset_offset=true";
123 }
124
135 public static function _isPageTranslation()
136 {
137 return (strtolower($_GET['cmdClass'] == 'ilobjlanguageextgui') and $_GET['view_mode'] == "translate");
138 }
139
140
144 public static function _saveUsages()
145 {
146 global $DIC;
147 $lng = $DIC->language();
148
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 public static function _getSavedModules()
159 {
160 $saved = $_SESSION['lang_ext_maintenance']['used_modules'];
161 return is_array($saved) ? $saved : array();
162 }
163
169 public static function _getSavedTopics()
170 {
171 $saved = $_SESSION['lang_ext_maintenance']['used_topics'];
172 return is_array($saved) ? $saved : array();
173 }
174}
$_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 usages in the user session.
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.
$row
global $ilSetting
Definition: privfeed.php:17
global $DIC
Definition: saml.php:7
$lng
global $ilDB
$ilUser
Definition: imgupload.php:18