• 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 
00074                 if ($a_keyword == "ilias_version")
00075                 {
00076                         return ILIAS_VERSION;
00077                 }
00078                 
00079                 if (isset($this->setting[$a_keyword]))
00080                 {
00081                         return $this->setting[$a_keyword];
00082                 }
00083                 else
00084                 {
00085                         return $a_default_value;
00086                 }
00087         }
00088         
00095         function delete($a_keyword)
00096         {
00097                 global $ilDB;
00098 
00099                 $query = "DELETE FROM settings WHERE keyword = ".
00100                         $ilDB->quote($a_keyword) . " AND module=" . $ilDB->quote($this->module);
00101                 $ilDB->query($query);
00102                 unset($this->setting[$a_keyword]);
00103 
00104                 return true;
00105         }
00106 
00107 
00113         function getAll()
00114         {
00115                 return $this->setting;
00116         }
00117 
00125         function set($a_key, $a_val)
00126         {
00127                 global $ilDB;
00128                 
00129                 $sql = "DELETE FROM settings WHERE keyword=".$ilDB->quote($a_key).
00130                         " AND module=" . $ilDB->quote($this->module);
00131                 $ilDB->query($sql);
00132 
00133                 $sql = "INSERT INTO settings (module, keyword, value) VALUES (".
00134                         $ilDB->quote($this->module) . ",".$ilDB->quote($a_key).",".$ilDB->quote($a_val).")";
00135                 $ilDB->query($sql);
00136                 
00137                 $this->setting[$a_key] = $a_val;
00138 
00139                 return true;
00140         }
00141 
00142 }
00143 ?>

Generated on Fri Dec 13 2013 13:52:11 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1