ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAccessKey.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13 // function id constants
14 const NEXT = 1;
15 const PREVIOUS = 2;
16 const DELETE = 3;
17 const LAST_VISITED = 4;
18 const TREE_ON = 5;
19 const TREE_OFF = 6;
20 const REPLY = 7;
21 const FORWARD_MAIL = 8;
22 const MARK_ALL_READ = 9;
23 const PERSONAL_DESKTOP = 10;
24
25 public static $func_def = array(
26 ilAccessKey::NEXT => array(
27 "component" => array("global"),
28 "lang" => "acc_next"),
29 ilAccessKey::PREVIOUS => array(
30 "component" => array("global"),
31 "lang" => "acc_previous"),
32 ilAccessKey::DELETE => array(
33 "component" => array("global"),
34 "lang" => "acc_delete"),
36 "component" => array("global"),
37 "lang" => "acc_last_rep_visited"),
38 ilAccessKey::TREE_ON => array(
39 "component" => array("global"),
40 "lang" => "acc_tree_on"),
41 ilAccessKey::TREE_OFF => array(
42 "component" => array("global"),
43 "lang" => "acc_tree_off"),
44 ilAccessKey::REPLY => array(
45 "component" => array("mail"),
46 "lang" => "acc_reply"),
48 "component" => array("mail"),
49 "lang" => "acc_forward_mail"),
51 "component" => array("frm"),
52 "lang" => "acc_mark_all_read"),
54 "component" => array("global"),
55 "lang" => "acc_personal_desktop")
56 );
57
63 private static function getAllKeysEmpty()
64 {
65 $empty_keys = array();
66 foreach (self::$func_def as $f => $c) {
67 $empty_keys[$f] = "";
68 }
69
70 return $empty_keys;
71 }
72
76 public static function getFunctionName($a_func_id)
77 {
78 global $DIC;
79
80 $lng = $DIC->language();
81
82 return $lng->txt(self::$func_def[$a_func_id]["lang"]);
83 }
84
88 public static function getComponentNames($a_func_id)
89 {
90 global $DIC;
91
92 $lng = $DIC->language();
93
94 $c_str = $lim = "";
95 foreach (self::$func_def[$a_func_id]["component"] as $c) {
96 $c_str .= $lim . $lng->txt("acc_comp_" . $c);
97 $lim = ", ";
98 }
99 return $c_str;
100 }
101
102
108 public static function getKeys($lang_key = "0", $a_ignore_default = false)
109 {
110 global $DIC;
111
112 $ilDB = $DIC->database();
113
115
116 // get defaults
117 if ($lang_key != "0" && !$a_ignore_default) {
119 }
120
121 // get keys of selected language
122 $set = $ilDB->query(
123 "SELECT * FROM acc_access_key " .
124 " WHERE lang_key = " . $ilDB->quote($lang_key, "text")
125 );
126 while ($rec = $ilDB->fetchAssoc($set)) {
127 $keys[$rec["function_id"]] = $rec["access_key"];
128 }
129
130 return $keys;
131 }
132
138 public static function getKey($a_func_id, $lang_key = "0", $a_ignore_default = false)
139 {
140 global $DIC;
141
142 $ilDB = $DIC->database();
143
144 $key = "";
145
146 // get defaults
147 if ($lang_key != "0" && !$a_ignore_default) {
148 $key = ilAccessKey::getKey($a_func_id);
149 }
150
151 // get keys of selected language
152 $set = $ilDB->query(
153 "SELECT * FROM acc_access_key " .
154 " WHERE lang_key = " . $ilDB->quote($lang_key, "text") .
155 " AND function_id = " . $ilDB->quote($a_func_id, "integer")
156 );
157 if ($rec = $ilDB->fetchAssoc($set)) {
158 $key = $rec["access_key"];
159 }
160
161 return $key;
162 }
163
169 public static function writeKeys($a_keys, $a_lang_key = "0")
170 {
171 global $DIC;
172
173 $ilDB = $DIC->database();
174
175 $ilDB->manipulate(
176 "DELETE FROM acc_access_key WHERE " .
177 "lang_key = " . $ilDB->quote($a_lang_key, "text")
178 );
179
180 foreach ($a_keys as $func_id => $acc_key) {
181 $ilDB->manipulate("INSERT INTO acc_access_key " .
182 "(lang_key, function_id, access_key) VALUES (" .
183 $ilDB->quote($a_lang_key, "text") . "," .
184 $ilDB->quote($func_id, "integer") . "," .
185 $ilDB->quote(strtolower(trim($acc_key)), "text") .
186 ")");
187 }
188 }
189}
An exception for terminatinating execution or to throw for unit testing.
Access key handling.
static getAllKeysEmpty()
Get all function ids with empty keys.
static writeKeys($a_keys, $a_lang_key="0")
Write keys.
static getFunctionName($a_func_id)
Get Function Name.
static getKeys($lang_key="0", $a_ignore_default=false)
Get access keys for language.
static getKey($a_func_id, $lang_key="0", $a_ignore_default=false)
Get single access key.
static getComponentNames($a_func_id)
Get Component Names.
$key
Definition: croninfo.php:18
$keys
global $DIC
Definition: saml.php:7
$lng
global $ilDB