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
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class aliroExtConfig {
00042 private $formalname = '';
00043 private $configs = array();
00044 private $remove = array();
00045 private $changed = array();
00046
00047 public function __construct ($formalname) {
00048 $this->formalname = $formalname;
00049 $database = aliroDatabase::getInstance();
00050 $database->setQuery("SELECT property, value FROM #__configurations WHERE system='Aliro' AND component='$formalname'");
00051 $results = $database->loadObjectList();
00052 if ($results) foreach ($results as $result) $this->configs[$result->property] = $result->value;
00053 }
00054
00055 public function get ($property) {
00056 return isset($this->configs[$property]) ? $this->configs[$property] : null;
00057 }
00058
00059 public function delete ($property) {
00060 if (isset($this->configs[$property])) unset ($this->configs[$property]);
00061 $this->remove[$property] = 1;
00062 }
00063
00064 public function set ($property, $value) {
00065 $this->configs[$property] = $value;
00066 if (isset($this->remove[$property])) unset ($this->remove[$property]);
00067 $this->changed[$property] = 1;
00068 }
00069
00070 public function update () {
00071 $database = aliroDatabase::getInstance();
00072 if (count($this->remove)) {
00073 $deletelist = "'".implode ("','", $this->remove)."'";
00074 $database->doSQL("DELETE FROM #__configurations WHERE system='Aliro' AND component='$this->formalname' AND property IN ($deletelist)");
00075 }
00076 if (count($this->changed)) {
00077 foreach (array_keys($this->changed) as $property) $setitem[] = " WHEN property = '$property' THEN '{$this->configs[$property]}'";
00078 $changelist = implode("\n", $setitem);
00079 $database->doSQL("UPDATE #__configurations SET value = CASE $changelist END WHERE system = 'Aliro' AND component='$this->formalname'");
00080 }
00081
00082 }
00083
00084 }