21 define(
"TITLE_FOCONFIG", _(
"Configuration Variables"));
29 var $CreateAttempts = 0;
33 function __construct()
35 $this->Name =
"foconfig";
36 $this->Title = TITLE_FOCONFIG;
37 $this->MenuList =
"Admin::Customize";
39 $this->PluginLevel = 50;
40 parent::__construct();
41 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
53 $sql =
"select * from sysconfig order by group_name, group_order";
54 $result = pg_query($PG_CONN, $sql);
58 $InputStyle =
"style='background-color:#dbf0f7'";
59 $OutBuf .=
"<form method='POST'>";
60 while ($row = pg_fetch_assoc($result)) {
61 if ($Group != $row[
'group_name']) {
63 $OutBuf .=
"</table><br>";
65 $Group = $row[
'group_name'];
66 $OutBuf .=
"<table border=1>";
69 $OutBuf .=
"<tr><td>$row[ui_label]</td><td>";
70 switch ($row[
'vartype']) {
73 $ConfVal = htmlentities($row[
'conf_value']);
74 $OutBuf .=
"<INPUT type='text' name='new[$row[variablename]]' size='70' value='$ConfVal' title='$row[description]' $InputStyle>";
75 $OutBuf .=
"<br>$row[description]";
78 $ConfVal = htmlentities($row[
'conf_value']);
79 $OutBuf .=
"<br><textarea name='new[$row[variablename]]' rows=3 cols=80 title='$row[description]' $InputStyle>$ConfVal</textarea>";
80 $OutBuf .=
"<br>$row[description]";
83 $ConfVal = htmlentities($row[
'conf_value']);
84 $OutBuf .=
"<INPUT type='password' name='new[$row[variablename]]' size='70' value='$ConfVal' title='$row[description]' $InputStyle>";
85 $OutBuf .=
"<br>$row[description]";
88 $ConfVal = htmlentities($row[
'conf_value']);
89 $Options = explode(
"|",$row[
'option_value']);
90 $OutBuf .=
"<select name='new[$row[variablename]]' title='$row[description]' $InputStyle>";
91 foreach ($Options as $Option) {
93 preg_match(
'/(\\w+)[{](.*)[}]/', $Option, $matches);
94 $Option_display = $matches[1];
95 $Option_value = $matches[2];
96 $OutBuf .=
"<option $InputStyle value='$Option_value' ";
97 if ($ConfVal == $Option_value) {
98 $OutBuf .=
"selected";
100 $OutBuf .=
">$Option_display</option>";
102 $OutBuf .=
"</select>";
103 $OutBuf .=
"<br>$row[description]";
106 $OutBuf .=
"Invalid configuration variable. Unknown type.";
108 $OutBuf .=
"</td></tr>";
109 $OutBuf .=
"<INPUT type='hidden' name='old[$row[variablename]]' value='$ConfVal'>";
111 $OutBuf .=
"</table>";
112 pg_free_result($result);
114 $btnlabel = _(
"Update");
115 $OutBuf .=
"<p><input type='submit' value='$btnlabel'>";
116 $OutBuf .=
"</form>";
126 if ($this->
State != PLUGIN_STATE_READY) {
136 if (! empty($newarray)) {
137 foreach ($newarray as $VarName => $VarValue) {
138 if ($VarValue != $oldarray[$VarName]) {
140 $sys_array = $this->
dbManager->getSingleRow(
"select validation_function, ui_label from sysconfig where variablename=$1",array($VarName),__METHOD__.
'.getVarNameData');
141 $validation_function = $sys_array[
'validation_function'];
142 $ui_label = $sys_array[
'ui_label'];
143 $is_empty = empty($validation_function);
148 if ($is_empty || (! $is_empty && (1 == $validation_function($VarValue)))) {
150 "update sysconfig set conf_value=$1 where variablename=$2",
151 array($VarValue, $VarName), __METHOD__ .
'.setVarNameData');
152 if (! empty($UpdateMsg)) {
155 $UpdateMsg .= $VarName;
156 }
else if (! $is_empty && (0 == $validation_function($VarValue))) {
161 if (! strcmp($validation_function,
'check_boolean')) {
163 "Error: You set $ui_label to $VarValue. Valid values are 'true' and 'false'.");
164 echo
"<script>alert('$warning_msg');</script>";
165 }
else if (strpos($validation_function,
"url")) {
167 "Error: $ui_label $VarValue, is not a reachable URL.");
168 echo
"<script>alert('$warning_msg');</script>";
173 if (! empty($UpdateMsg)) {
174 $UpdateMsg .= _(
" updated.");
179 if ($this->OutputType ==
'HTML') {
181 $OutBuf .=
"<span style='background-color:#ff8a8a'>$UpdateMsg</style><hr>";
185 $this->vars[
'content'] = $OutBuf;
190 $NewPlugin->Initialize();
const CONFIG_TYPE_TEXTAREA
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
const CONFIG_TYPE_PASSWORD
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
fo_dbManager * dbManager
fo_dbManager object
This is the Plugin class. All plugins should:
HTMLout()
Generate HTML output.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
display and set FOSSology configuration