From 317db874e7964231ac33b5646cc33b1b400a4f29 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 19 Feb 2016 15:01:56 +0100 Subject: [locations] New module for managing locations --- apis/getconfig.inc.php | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'apis/getconfig.inc.php') diff --git a/apis/getconfig.inc.php b/apis/getconfig.inc.php index 5d5dbca8..2447d622 100644 --- a/apis/getconfig.inc.php +++ b/apis/getconfig.inc.php @@ -1,5 +1,10 @@ fetch(PDO::FETCH_ASSOC)) { + $tmp[(int)$row['locationid']][$row['setting']] = $row['value']; + } + // $matchingLocations contains the location ids sorted from closest to furthest, so we use it to make sure the order + // in which they override is correct (closest setting wins, e.g. room setting beats department setting) + foreach ($matchingLocations as $lid) { + if (!isset($tmp[$lid])) continue; + foreach ($tmp[$lid] as $setting => $value) { + if (!isset($configVars[$setting])) { + $configVars[$setting] = $value; + } + } + } + unset($tmp); +} + // Dump config from DB $res = Database::simpleQuery('SELECT setting.setting, setting.defaultvalue, tbl.value FROM setting LEFT JOIN setting_global AS tbl USING (setting) ORDER BY setting ASC'); // TODO: Add setting groups and sort order while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - if (is_null($row['value'])) $row['value'] = $row['defaultvalue']; + if (isset($configVars[$row['setting']])) { + $row['value'] = $configVars[$row['setting']]; + } elseif (is_null($row['value'])) { + $row['value'] = $row['defaultvalue']; + } echo $row['setting'] . "='" . escape($row['value']) . "'\n"; } @@ -47,6 +98,7 @@ if (is_array($vmstore)) { } } + // For quick testing or custom extensions: Include external file that should do nothing // more than outputting more key-value-pairs. It's expected in the webroot of slxadmin -if (file_exists('client_config_additional.php')) @include('client_config_additional.php'); \ No newline at end of file +if (file_exists('client_config_additional.php')) @include('client_config_additional.php'); -- cgit v1.2.3-55-g7522