Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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 ?>