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 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 ?>