From 8e729913a8f6258762f4e8049caebc9dbb42a71e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 17 May 2016 18:14:13 +0200 Subject: Modularized baseconfig fetching (api) --- .../locations/baseconfig/getconfig.inc.php | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 modules-available/locations/baseconfig/getconfig.inc.php (limited to 'modules-available/locations/baseconfig') diff --git a/modules-available/locations/baseconfig/getconfig.inc.php b/modules-available/locations/baseconfig/getconfig.inc.php new file mode 100644 index 00000000..2643ced6 --- /dev/null +++ b/modules-available/locations/baseconfig/getconfig.inc.php @@ -0,0 +1,43 @@ +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); +} -- cgit v1.2.3-55-g7522