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) --- apis/getconfig.inc.php | 104 +++---------------------------------------------- 1 file changed, 6 insertions(+), 98 deletions(-) (limited to 'apis/getconfig.inc.php') diff --git a/apis/getconfig.inc.php b/apis/getconfig.inc.php index 2447d622..3fe05ed1 100644 --- a/apis/getconfig.inc.php +++ b/apis/getconfig.inc.php @@ -1,104 +1,12 @@ 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 (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"; -} - -// Additional "intelligent" config - -// Remote log URL -echo "SLX_REMOTE_LOG='http://" . escape($_SERVER['SERVER_ADDR']) . escape($_SERVER['SCRIPT_NAME']) . "?do=clientlog'\n"; -// vm list url -echo "SLX_VMCHOOSER_BASE_URL='http://" . escape($_SERVER['SERVER_ADDR']) . "/vmchooser/'\n"; - -// VMStore path and type -$vmstore = Property::getVmStoreConfig(); -if (is_array($vmstore)) { - switch ($vmstore['storetype']) { - case 'internal'; - echo "SLX_VM_NFS='" . escape($_SERVER['SERVER_ADDR']) . ":/srv/openslx/nfs'\n"; - break; - case 'nfs'; - echo "SLX_VM_NFS='" . escape($vmstore['nfsaddr']) . "'\n"; - break; - case 'cifs'; - echo "SLX_VM_NFS='" . escape($vmstore['cifsaddr']) . "'\n"; - echo "SLX_VM_NFS_USER='" . escape($vmstore['cifsuserro']) . "'\n"; - echo "SLX_VM_NFS_PASSWD='" . escape($vmstore['cifspasswdro']) . "'\n"; - break; - } -} - - -// 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'); +require 'modules/baseconfig/api.inc.php'; \ No newline at end of file -- cgit v1.2.3-55-g7522