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

Services/Administration/classes/class.ilSetting.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 
00032 class ilSetting
00033 {
00034         var $setting = array();
00035         var $module = "";
00036         
00040         function ilSetting($a_module = "common")
00041         {
00042                 global $ilDB;
00043                 
00044                 $this->module = $a_module;
00045                 // check whether ini file object exists
00046                 if (!is_object($ilDB))
00047                 {
00048                         die ("Fatal Error: ilSettings object instantiated without DB initialisation.");
00049                 }
00050                 
00051                 $query = "SELECT * FROM settings WHERE module=" . $ilDB->quote($this->module);
00052                 $res = $ilDB->query($query);
00053 
00054                 while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
00055                 {
00056                         $this->setting[$row["keyword"]] = $row["value"];
00057                 }
00058 
00059         }
00060         
00071         function get($a_keyword, $a_default_value = false)
00072         {
00073                 if ($a_keyword == "ilias_version")
00074                 {
00075                         return ILIAS_VERSION;
00076                 }
00077                 
00078                 if (isset($this->setting[$a_keyword]))
00079                 {
00080                         return $this->setting[$a_keyword];
00081                 }
00082                 else
00083                 {
00084                         return $a_default_value;
00085                 }
00086         }
00087         
00094         public function deleteAll()
00095         {
00096                 global $ilDB;
00097                 
00098                 $query = "DELETE FROM settings WHERE module = ".$ilDB->quote($this->module)." ";
00099                 $ilDB->query($query);
00100                 $this->settings = array();
00101                 return true;
00102         }
00103         
00110         function delete($a_keyword)
00111         {
00112                 global $ilDB;
00113 
00114                 $query = "DELETE FROM settings WHERE keyword = ".
00115                         $ilDB->quote($a_keyword) . " AND module=" . $ilDB->quote($this->module);
00116                 $ilDB->query($query);
00117                 unset($this->setting[$a_keyword]);
00118 
00119                 return true;
00120         }
00121         
00122         
00123 
00129         function getAll()
00130         {
00131                 return $this->setting;
00132         }
00133 
00141         function set($a_key, $a_val)
00142         {
00143                 global $ilDB;
00144                 
00145                 $sql = "DELETE FROM settings WHERE keyword=".$ilDB->quote($a_key).
00146                         " AND module=" . $ilDB->quote($this->module);
00147                 $ilDB->query($sql);
00148 
00149                 $sql = "INSERT INTO settings (module, keyword, value) VALUES (".
00150                         $ilDB->quote($this->module) . ",".$ilDB->quote($a_key).",".$ilDB->quote($a_val).")";
00151                 $ilDB->query($sql);
00152                 
00153                 $this->setting[$a_key] = $a_val;
00154 
00155                 return true;
00156         }
00157 
00158 }
00159 ?>

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