diff --git a/src/www/ui/admin-config.php b/src/www/ui/admin-config.php index 956598e2..af74f08a 100644 --- a/src/www/ui/admin-config.php +++ b/src/www/ui/admin-config.php @@ -1,173 +1,165 @@ Name = "foconfig"; $this->Title = TITLE_foconfig; $this->MenuList = "Admin::Customize"; $this->DBaccess = PLUGIN_DB_ADMIN; $this->PluginLevel = 50; // run before 'regular' plugins parent::__construct(); + $this->dbManager = $GLOBALS['container']->get('db.manager'); } /** * \brief Generate HTML output. */ function HTMLout() { global $PG_CONN; $OutBuf=""; /* get config rows from sysconfig table */ $sql = "select * from sysconfig order by group_name, group_order"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $Group = ""; $InputStyle = "style='background-color:#dbf0f7'"; $OutBuf .= "
"; return $OutBuf; } /** * \brief Generate output. */ function Output() { - global $PG_CONN; - global $Plugins; - if ($this->State != PLUGIN_STATE_READY) { return; } - if (empty($PG_CONN)) return; $newarray = GetParm("new", PARM_RAW); $oldarray = GetParm("old", PARM_RAW); /* Compare new and old array * and update DB with new values */ $UpdateMsg = ""; if (!empty($newarray)) { foreach($newarray as $VarName => $VarValue) { if ($VarValue != $oldarray[$VarName]) { /* get validation_function row from sysconfig table */ - $sql = "select validation_function, ui_label from sysconfig where variablename='".pg_escape_string($VarName)."';"; - $result = pg_query($PG_CONN, $sql); - DBCheckResult($result, $sql, __FILE__, __LINE__); - $sys_array = pg_fetch_assoc($result); + $sys_array = $this->dbManager->getSingleRow("select validation_function, ui_label from sysconfig where variablename=$1",array($VarName),__METHOD__.'.getVarNameData'); $validation_function = $sys_array['validation_function']; $ui_label = $sys_array['ui_label']; - pg_free_result($result); $is_empty = empty($validation_function); /* 1. the validation_function is empty 2. the validation_function is not empty, and after checking, the value is valid update sysconfig table */ if ($is_empty || (!$is_empty && (1 == $validation_function($VarValue)))) { - $sql = "update sysconfig set conf_value='" . - pg_escape_string($VarValue) . - "' where variablename='$VarName'"; - $result = pg_query($PG_CONN, $sql); - DBCheckResult($result, $sql, __FILE__, __LINE__); - pg_free_result($result); + $this->dbManager->getSingleRow("update sysconfig set conf_value=$1 where variablename=$2",array($VarValue,$VarName),__METHOD__.'.setVarNameData'); if (!empty($UpdateMsg)) $UpdateMsg .= ", "; $UpdateMsg .= $VarName; } /* the validation_function is not empty, but after checking, the value is invalid */ else if (!$is_empty && (0 == $validation_function($VarValue))) { if (!strcmp($validation_function, 'check_boolean')) { - $warning_msg = _("Error: You set $ui_label to $VarValue. Valid values are \'true\' and \'false\'."); + $warning_msg = _("Error: You set $ui_label to $VarValue. Valid values are \\'true\\' and \\'false\\'."); echo ""; } else if (strpos($validation_function, "url")) { $warning_msg = _("Error: $ui_label $VarValue, is not a reachable URL."); echo ""; } } } } - if (!empty($UpdateMsg)) $UpdateMsg .= " updated."; + if (!empty($UpdateMsg)) $UpdateMsg .= _(" updated."); } $OutBuf = ''; if($this->OutputType=='HTML') { if ($UpdateMsg) $OutBuf .= "$UpdateMsg