ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBlockSetting.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
32 {
37  public static function _lookup($a_type, $a_setting, $a_user = 0, $a_block_id = 0)
38  {
39  global $ilDB;
40 
41 
42  $set = $ilDB->query(sprintf("SELECT * FROM il_block_setting WHERE type = %s ".
43  "AND user_id = %s AND setting = %s AND block_id = %s",
44  $ilDB->quote($a_type, "text"),
45  $ilDB->quote($a_user, "integer"),
46  $ilDB->quote($a_setting, "text"),
47  $ilDB->quote($a_block_id, "integer")));
48  if ($rec = $ilDB->fetchAssoc($set))
49  {
50  return $rec["value"];
51  }
52  else
53  {
54  return false;
55  }
56  }
57 
62  public static function _write($a_type, $a_setting, $a_value, $a_user = 0, $a_block_id = 0)
63  {
64  global $ilDB;
65 
66  $ilDB->manipulate(sprintf("DELETE FROM il_block_setting WHERE type = %s AND user_id = %s AND block_id = %s AND setting = %s",
67  $ilDB->quote($a_type, "text"),
68  $ilDB->quote($a_user, "integer"),
69  $ilDB->quote((int) $a_block_id, "integer"),
70  $ilDB->quote($a_setting, "text")));
71  $ilDB->manipulate(sprintf("INSERT INTO il_block_setting (type, user_id, setting, block_id, value) VALUES (%s,%s,%s,%s,%s)",
72  $ilDB->quote($a_type, "text"),
73  $ilDB->quote($a_user, "integer"),
74  $ilDB->quote($a_setting, "text"),
75  $ilDB->quote((int) $a_block_id, "integer"),
76  $ilDB->quote($a_value, "text")));
77  }
78 
83  public static function _lookupDetailLevel($a_type, $a_user = 0, $a_block_id = 0)
84  {
85  $detail = ilBlockSetting::_lookup($a_type, "detail", $a_user, $a_block_id);
86 
87  if ($detail === false) // return a level of 2 (standard value)
88  { // if record does not exist
89  return 2;
90  }
91  else
92  {
93  return $detail;
94  }
95  }
96 
101  public static function _writeDetailLevel($a_type, $a_value, $a_user = 0, $a_block_id = 0)
102  {
103  ilBlockSetting::_write($a_type, "detail", $a_value, $a_user, $a_block_id);
104  }
105 
110  public static function _lookupNr($a_type, $a_user = 0, $a_block_id = 0)
111  {
112  $nr = ilBlockSetting::_lookup($a_type, "nr", $a_user, $a_block_id);
113 
114  return $nr;
115  }
116 
121  public static function _writeNumber($a_type, $a_value, $a_user = 0, $a_block_id = 0)
122  {
123  ilBlockSetting::_write($a_type, "nr", $a_value, $a_user, $a_block_id);
124  }
125 
130  public static function _lookupSide($a_type, $a_user = 0, $a_block_id = 0)
131  {
132  $side = ilBlockSetting::_lookup($a_type, "side", $a_user, $a_block_id);
133 
134  return $side;
135  }
136 
141  public static function _writeSide($a_type, $a_value, $a_user = 0, $a_block_id = 0)
142  {
143  ilBlockSetting::_write($a_type, "side", $a_value, $a_user, $a_block_id);
144  }
145 
150  public static function _deleteSettingsOfUser($a_user)
151  {
152  global $ilDB;
153 
154  if ($a_user > 0)
155  {
156  $ilDB->manipulate("DELETE FROM il_block_setting WHERE user_id = ".
157  $ilDB->quote($a_user, "integer"));
158  }
159  }
160 
165  public static function _deleteSettingsOfBlock($a_block_id, $a_block_type)
166  {
167  global $ilDB;
168 
169  if ($a_block_id > 0)
170  {
171  $ilDB->manipulate("DELETE FROM il_block_setting WHERE block_id = ".
172  $ilDB->quote($a_block_id, "integer").
173  " AND type = ".$ilDB->quote($a_block_type, "text"));
174  }
175  }
176 
177 }
178 ?>