8 namespace Fossology\Lib\Dao;
17 const TYPE_MAP = array(
30 function __construct(
DbManager $dbManager, Logger $logger)
33 $this->logger = $logger;
41 $sql =
"select * from sysconfig order by group_name, group_order";
50 return $this->
dbManager->getSingleRow(
"SELECT conf_value FROM sysconfig
51 WHERE variablename = 'BannerMsg'")[
"conf_value"];
62 foreach ($data as $row) {
63 $type = self::TYPE_MAP[$row[
'vartype']];
64 if ($apiVersion == ApiVersion::V2) {
66 "key" => $row[
'variablename'],
67 "value" => $row[
'conf_value'],
69 "label" => $row[
'ui_label'],
70 "groupName" => $row[
'group_name'],
71 "groupOrder" => intval($row[
'group_order']),
72 "optionValue" => $row[
"option_value"]
76 "key" => $row[
'variablename'],
77 "value" => $row[
'conf_value'],
79 "label" => $row[
'ui_label'],
80 "group_name" => $row[
'group_name'],
81 "group_order" => intval($row[
'group_order']),
82 "option_value" => $row[
"option_value"]
98 $key = strval($data[
'key']);
99 $value = strval($data[
'value']);
103 foreach ($sysconfigData as $item) {
104 $oldarray[$item[
'variablename']] = $item[
'conf_value'];
107 if ($value != $oldarray[$key]) {
109 $sys_array = $this->
dbManager->getSingleRow(
"SELECT validation_function,
110 ui_label FROM sysconfig WHERE variablename = $1", [$key],__METHOD__.
'.getVarNameData');
111 $validation_function = $sys_array[
'validation_function'];
112 $ui_label = $sys_array[
'ui_label'];
113 $is_empty = empty($validation_function);
119 if ($is_empty || (! $is_empty && (1 == $validation_function($value)))) {
121 "UPDATE sysconfig SET conf_value=$1 WHERE variablename=$2",
122 [$value, $key], __METHOD__ .
'.setVarNameData');
124 }
else if (! $is_empty && (0 == $validation_function($value))) {
129 $warning_msg =
"Error: Unable to update $key.";
130 if (! strcmp($validation_function,
'check_boolean')) {
132 "Error: You set $ui_label to $value. Valid values are 'true' and 'false'.");
133 }
else if (strpos($validation_function,
"url")) {
135 "Error: $ui_label $value, is not a reachable URL.");
137 return [
false, $warning_msg];
getCustomiseData($data, $apiVersion=ApiVersion::V1)
getBannerData()
Fetch banner message.
getConfigData()
Fetch configuration rows.
UpdateConfigData($data)
Update Configuration Data.
fo_dbManager * dbManager
fo_dbManager object