ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  {
68  $empty_keys[$f] = "";
69  }
70 
71  return $empty_keys;
72  }
73 
77  static function getFunctionName($a_func_id)
78  {
79  global $lng;
80 
81  return $lng->txt(self::$func_def[$a_func_id]["lang"]);
82  }
83 
87  static function getComponentNames($a_func_id)
88  {
89  global $lng;
90 
91  $c_str = $lim = "";
92  foreach (self::$func_def[$a_func_id]["component"] as $c)
93  {
94  $c_str.= $lim.$lng->txt("acc_comp_".$c);
95  $lim = ", ";
96  }
97  return $c_str;
98  }
99 
100 
106  static function getKeys($lang_key = "0", $a_ignore_default = false)
107  {
108  global $ilDB;
109 
111 
112  // get defaults
113  if ($lang_key != "0" && !$a_ignore_default)
114  {
115  $keys = ilAccessKey::getKeys();
116  }
117 
118  // get keys of selected language
119  $set = $ilDB->query("SELECT * FROM acc_access_key ".
120  " WHERE lang_key = ".$ilDB->quote($lang_key, "text")
121  );
122  while ($rec = $ilDB->fetchAssoc($set))
123  {
124  $keys[$rec["function_id"]] = $rec["access_key"];
125  }
126 
127  return $keys;
128  }
129 
135  static function getKey($a_func_id, $lang_key = "0", $a_ignore_default = false)
136  {
137  global $ilDB;
138 
139  $key = "";
140 
141  // get defaults
142  if ($lang_key != "0" && !$a_ignore_default)
143  {
144  $key = ilAccessKey::getKey($a_func_id);
145  }
146 
147  // get keys of selected language
148  $set = $ilDB->query("SELECT * FROM acc_access_key ".
149  " WHERE lang_key = ".$ilDB->quote($lang_key, "text").
150  " AND function_id = ".$ilDB->quote($a_func_id, "integer")
151  );
152  if ($rec = $ilDB->fetchAssoc($set))
153  {
154  $key = $rec["access_key"];
155  }
156 
157  return $key;
158  }
159 
165  static function writeKeys($a_keys, $a_lang_key = "0")
166  {
167  global $ilDB;
168 
169  $ilDB->manipulate("DELETE FROM acc_access_key WHERE ".
170  "lang_key = ".$ilDB->quote($a_lang_key, "text")
171  );
172 
173  foreach ($a_keys as $func_id => $acc_key)
174  {
175  $ilDB->manipulate("INSERT INTO acc_access_key ".
176  "(lang_key, function_id, access_key) VALUES (".
177  $ilDB->quote($a_lang_key, "text").",".
178  $ilDB->quote($func_id, "integer").",".
179  $ilDB->quote(strtolower(trim($acc_key)), "text").
180  ")");
181  }
182  }
183 
184 }