X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2FBarrel%2FOptions.php;fp=include%2FBarrel%2FOptions.php;h=c87f604d630914eade45aa5aee104ce472c8f982;hb=6855525e48fad5de270500a5445c4f4ff85d8bda;hp=0000000000000000000000000000000000000000;hpb=e69709aa8ee6108a1197e46b45367ba8dab55a52;p=diogenes.git diff --git a/include/Barrel/Options.php b/include/Barrel/Options.php new file mode 100644 index 0000000..c87f604 --- /dev/null +++ b/include/Barrel/Options.php @@ -0,0 +1,105 @@ +barrel = $alias; + $this->readOptions(); + } + + + /** Read options from database. + */ + function readOptions() { + global $globals; + + // we only accept options which already exist in this class + $res = $globals->db->query("select name,value from {$this->table_option} where barrel='{$this->barrel}'"); + while (list($key,$value) = mysql_fetch_row($res)) { + if (isset($this->$key) && ($key != "table_option")) + $this->$key = $value; + } + mysql_free_result($res); + + } + + + /** Update an option's value and write the new value to database. + */ + function updateOption($name, $value) { + global $globals; + + $this->$name = stripslashes($value); + $globals->db->query("replace into {$this->table_option} set barrel='{$this->barrel}',name='$name',value='$value'"); + } + +} + +?>