ILIAS  Release_3_10_x_branch Revision 61812
 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  $query = "SELECT * FROM il_block_setting WHERE type = ".
42  $ilDB->quote($a_type)." AND user = ".
43  $ilDB->quote($a_user)." AND setting = ".
44  $ilDB->quote($a_setting)." AND block_id = ".
45  $ilDB->quote($a_block_id);
46  $set = $ilDB->query($query);
47  if ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
48  {
49  return $rec["value"];
50  }
51  else
52  {
53  return false;
54  }
55  }
56 
61  public static function _write($a_type, $a_setting, $a_value, $a_user = 0, $a_block_id = 0)
62  {
63  global $ilDB;
64 
65  $query = "REPLACE INTO il_block_setting (type, user, setting, block_id, value) VALUES (".
66  $ilDB->quote($a_type).", ".$ilDB->quote($a_user).",".
67  $ilDB->quote($a_setting).",".$ilDB->quote($a_block_id).",".$ilDB->quote($a_value).")";
68  $ilDB->query($query);
69  }
70 
75  public static function _lookupDetailLevel($a_type, $a_user = 0, $a_block_id = 0)
76  {
77  $detail = ilBlockSetting::_lookup($a_type, "detail", $a_user, $a_block_id);
78 
79  if ($detail === false) // return a level of 2 (standard value)
80  { // if record does not exist
81  return 2;
82  }
83  else
84  {
85  return $detail;
86  }
87  }
88 
93  public static function _writeDetailLevel($a_type, $a_value, $a_user = 0, $a_block_id = 0)
94  {
95  ilBlockSetting::_write($a_type, "detail", $a_value, $a_user, $a_block_id);
96  }
97 
102  public static function _lookupNr($a_type, $a_user = 0, $a_block_id = 0)
103  {
104  $nr = ilBlockSetting::_lookup($a_type, "nr", $a_user, $a_block_id);
105 
106  return $nr;
107  }
108 
113  public static function _writeNumber($a_type, $a_value, $a_user = 0, $a_block_id = 0)
114  {
115  ilBlockSetting::_write($a_type, "nr", $a_value, $a_user, $a_block_id);
116  }
117 
122  public static function _lookupSide($a_type, $a_user = 0, $a_block_id = 0)
123  {
124  $side = ilBlockSetting::_lookup($a_type, "side", $a_user, $a_block_id);
125 
126  return $side;
127  }
128 
133  public static function _writeSide($a_type, $a_value, $a_user = 0, $a_block_id = 0)
134  {
135  ilBlockSetting::_write($a_type, "side", $a_value, $a_user, $a_block_id);
136  }
137 
142  public static function _deleteSettingsOfUser($a_user)
143  {
144  global $ilDB;
145 
146  if ($a_user > 0)
147  {
148  $query = "DELETE FROM il_block_setting WHERE user = ".
149  $ilDB->quote($a_user);
150 
151  $ilDB->query($query);
152  }
153  }
154 
159  public static function _deleteSettingsOfBlock($a_block_id, $a_block_type)
160  {
161  global $ilDB;
162 
163  if ($a_block_id > 0)
164  {
165  $query = "DELETE FROM il_block_setting WHERE block_id = ".
166  $ilDB->quote($a_block_id).
167  " AND type = ".$ilDB->quote($a_block_type);
168 
169  $ilDB->query($query);
170  }
171  }
172 
173 }
174 ?>