ILIAS  Release_4_1_x_branch Revision 61804
 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 
24  public static $func_def = array(
25  ilAccessKey::NEXT => array(
26  "component" => array("global"),
27  "lang" => "acc_next"),
28  ilAccessKey::PREVIOUS => array(
29  "component" => array("global"),
30  "lang" => "acc_previous"),
31  ilAccessKey::DELETE => array(
32  "component" => array("global"),
33  "lang" => "acc_delete"),
35  "component" => array("global"),
36  "lang" => "acc_last_visited"),
37  ilAccessKey::TREE_ON => array(
38  "component" => array("global"),
39  "lang" => "acc_tree_on"),
40  ilAccessKey::TREE_OFF => array(
41  "component" => array("global"),
42  "lang" => "acc_tree_off"),
43  ilAccessKey::REPLY => array(
44  "component" => array("mail"),
45  "lang" => "acc_reply"),
47  "component" => array("mail"),
48  "lang" => "acc_forward_mail"),
50  "component" => array("frm"),
51  "lang" => "acc_mark_all_read")
52  );
53 
59  private static function getAllKeysEmpty()
60  {
61  $empty_keys = array();
62  foreach (self::$func_def as $f => $c)
63  {
64  $empty_keys[$f] = "";
65  }
66 
67  return $empty_keys;
68  }
69 
73  static function getFunctionName($a_func_id)
74  {
75  global $lng;
76 
77  return $lng->txt(self::$func_def[$a_func_id]["lang"]);
78  }
79 
83  static function getComponentNames($a_func_id)
84  {
85  global $lng;
86 
87  $c_str = $lim = "";
88  foreach (self::$func_def[$a_func_id]["component"] as $c)
89  {
90  $c_str.= $lim.$lng->txt("acc_comp_".$c);
91  $lim = ", ";
92  }
93  return $c_str;
94  }
95 
96 
102  static function getKeys($lang_key = "0", $a_ignore_default = false)
103  {
104  global $ilDB;
105 
107 
108  // get defaults
109  if ($lang_key != "0" && !$a_ignore_default)
110  {
111  $keys = ilAccessKey::getKeys();
112  }
113 
114  // get keys of selected language
115  $set = $ilDB->query("SELECT * FROM acc_access_key ".
116  " WHERE lang_key = ".$ilDB->quote($lang_key, "text")
117  );
118  while ($rec = $ilDB->fetchAssoc($set))
119  {
120  $keys[$rec["function_id"]] = $rec["access_key"];
121  }
122 
123  return $keys;
124  }
125 
131  static function getKey($a_func_id, $lang_key = "0", $a_ignore_default = false)
132  {
133  global $ilDB;
134 
135  $key = "";
136 
137  // get defaults
138  if ($lang_key != "0" && !$a_ignore_default)
139  {
140  $key = ilAccessKey::getKey($a_func_id);
141  }
142 
143  // get keys of selected language
144  $set = $ilDB->query("SELECT * FROM acc_access_key ".
145  " WHERE lang_key = ".$ilDB->quote($lang_key, "text").
146  " AND function_id = ".$ilDB->quote($a_func_id, "integer")
147  );
148  if ($rec = $ilDB->fetchAssoc($set))
149  {
150  $key = $rec["access_key"];
151  }
152 
153  return $key;
154  }
155 
161  static function writeKeys($a_keys, $a_lang_key = "0")
162  {
163  global $ilDB;
164 
165  $ilDB->manipulate("DELETE FROM acc_access_key WHERE ".
166  "lang_key = ".$ilDB->quote($a_lang_key, "text")
167  );
168 
169  foreach ($a_keys as $func_id => $acc_key)
170  {
171  $ilDB->manipulate("INSERT INTO acc_access_key ".
172  "(lang_key, function_id, access_key) VALUES (".
173  $ilDB->quote($a_lang_key, "text").",".
174  $ilDB->quote($func_id, "integer").",".
175  $ilDB->quote(strtolower(trim($acc_key)), "text").
176  ")");
177  }
178  }
179 
180 }