forked from opendcim/openDCIM
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.inc.php
63 lines (54 loc) · 1.47 KB
/
config.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
class Config{
var $ParameterArray;
var $defaults;
function Config ($db){
//Get parameter value pairs from fac_Config
$sql='select Parameter, Value, DefaultVal from fac_Config';
$result=mysql_query($sql,$db);
while ($row=mysql_fetch_array($result)){
if ($row['Parameter']== 'ClassList'){
$List = explode(', ', $row['Value']);
$this->ParameterArray[$row['Parameter']]=$List;
$this->defaults[$row['Parameter']]=$row['DefaultVal'];
}else{
$this->ParameterArray[$row['Parameter']]=$row['Value'];
$this->defaults[$row['Parameter']]=$row['DefaultVal'];
}
}
return;
}
function UpdateConfig($db){
foreach($this->ParameterArray as $key=>$value){
if ($key=='ClassList'){
$numItems=count($value);
$i=0;
$valueStr='';
foreach($value as $item){
$valueStr .= $item;
if($i+1 != $numItems){
$valueStr.=', ';
}
$i++;
}
$sql='update fac_Config set Value=\''.addslashes($valueStr).'\' where Parameter=\''.$key.'\'';
$result=mysql_query($sql,$db);
}else{
$sql='update fac_Config set Value=\''.addslashes($value).'\' where Parameter=\''.$key.'\'';
$result=mysql_query($sql,$db);
}
}
return;
}
static function RevertToDefault($db, $parameter){
if ($parameter=='none'){
$sql='update fac_Config set Value=DefaultVal';
}
else{
$sql='update fac_Config set Value=DefaultVal where Parameter = \''.$parameter.'\'';
}
$result=mysql_query($sql,$db);
return;
}
}
?>