• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Block/classes/class.ilBlockSetting.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00031 class ilBlockSetting
00032 {
00037         public static function _lookup($a_type, $a_setting, $a_user = 0, $a_block_id = 0)
00038         {
00039                 global $ilDB;
00040                 
00041                 $query = "SELECT * FROM il_block_setting WHERE type = ".
00042                         $ilDB->quote($a_type)." AND user = ".
00043                         $ilDB->quote($a_user)." AND setting = ".
00044                         $ilDB->quote($a_setting)." AND block_id = ".
00045                         $ilDB->quote($a_block_id);
00046                 $set = $ilDB->query($query);
00047                 if ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
00048                 {
00049                         return $rec["value"];
00050                 }
00051                 else
00052                 {
00053                         return false;
00054                 }
00055         }
00056 
00061         public static function _write($a_type, $a_setting, $a_value, $a_user = 0, $a_block_id = 0)
00062         {
00063                 global $ilDB;
00064                 
00065                 $query = "REPLACE INTO il_block_setting  (type, user, setting, block_id, value) VALUES (".
00066                         $ilDB->quote($a_type).", ".$ilDB->quote($a_user).",".
00067                         $ilDB->quote($a_setting).",".$ilDB->quote($a_block_id).",".$ilDB->quote($a_value).")";
00068                 $ilDB->query($query);
00069         }
00070 
00075         public static function _lookupDetailLevel($a_type, $a_user = 0, $a_block_id = 0)
00076         {
00077                 $detail = ilBlockSetting::_lookup($a_type, "detail", $a_user, $a_block_id);
00078 
00079                 if ($detail === false)          // return a level of 2 (standard value)
00080                 {                                                       // if record does not exist
00081                         return 2;
00082                 }
00083                 else
00084                 {
00085                         return $detail;
00086                 }
00087         }
00088 
00093         public static function _writeDetailLevel($a_type, $a_value, $a_user = 0, $a_block_id = 0)
00094         {
00095                 ilBlockSetting::_write($a_type, "detail", $a_value, $a_user, $a_block_id);
00096         }
00097 
00102         public static function _lookupNr($a_type, $a_user = 0, $a_block_id = 0)
00103         {
00104                 $nr = ilBlockSetting::_lookup($a_type, "nr", $a_user, $a_block_id);
00105 
00106                 return $nr;
00107         }
00108 
00113         public static function _writeNumber($a_type, $a_value, $a_user = 0, $a_block_id = 0)
00114         {
00115                 ilBlockSetting::_write($a_type, "nr", $a_value, $a_user, $a_block_id);
00116         }
00117 
00122         public static function _lookupSide($a_type, $a_user = 0, $a_block_id = 0)
00123         {
00124                 $side = ilBlockSetting::_lookup($a_type, "side", $a_user, $a_block_id);
00125 
00126                 return $side;
00127         }
00128 
00133         public static function _writeSide($a_type, $a_value, $a_user = 0, $a_block_id = 0)
00134         {
00135                 ilBlockSetting::_write($a_type, "side", $a_value, $a_user, $a_block_id);
00136         }
00137 
00142         public static function _deleteSettingsOfUser($a_user)
00143         {
00144                 global $ilDB;
00145                 
00146                 if ($a_user > 0)
00147                 {
00148                         $query = "DELETE FROM il_block_setting  WHERE user = ".
00149                                 $ilDB->quote($a_user);
00150 
00151                         $ilDB->query($query);
00152                 }
00153         }
00154 
00159         public static function _deleteSettingsOfBlock($a_block_id, $a_block_type)
00160         {
00161                 global $ilDB;
00162                 
00163                 if ($a_block_id > 0)
00164                 {
00165                         $query = "DELETE FROM il_block_setting  WHERE block_id = ".
00166                                 $ilDB->quote($a_block_id).
00167                                 " AND type = ".$ilDB->quote($a_block_type);
00168 
00169                         $ilDB->query($query);
00170                 }
00171         }
00172         
00173 }
00174 ?>

Generated on Fri Dec 13 2013 17:56:55 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1