', function($id) { return [ 'name' => Dictionary::translate('source-global'), 'locationid' => 0, ]; }); $res = Database::simpleQuery('SELECT setting, value, displayvalue FROM setting_global'); foreach ($res as $row) { if (!isset($defaults[$row['setting']])) continue; // Setting is not defined in any /baseconfig/settings.json ConfigHolder::add($row['setting'], $row, -1); } // Fallback to default values from json files self::addDefaults($defaults); } private static function addDefaults($defaults) { ConfigHolder::setContext('', function($id) { return [ 'name' => Dictionary::translate('source-default'), 'locationid' => 0, ]; }); foreach ($defaults as $setting => $value) { ConfigHolder::add($setting, $value['defaultvalue'], -1000); } } private static function handleModule(string $name, ?string $ip, ?string $uuid, bool $needJsonHook): void { // Pass ip and uuid instead of global to make them read only if (isset(self::$modulesDone[$name])) return; self::$modulesDone[$name] = true; // Module has getconfig hook $file = 'modules/' . $name . '/baseconfig/getconfig.inc.php'; if (!is_file($file)) return; // We want only static hooks that have a json config (currently used for displaying inheritance tree) if ($needJsonHook && !is_file('modules/' . $name . '/baseconfig/hook.json')) return; // Properly registered and can be activated $mod = Module::get($name); if ($mod === false) return; if (!$mod->activate(1, false)) return; // Process dependencies first foreach ($mod->getDependencies() as $dep) { self::handleModule($dep, $ip, $uuid, $needJsonHook); } ConfigHolder::setContext($name); (function (string $file, ?string $ip, ?string $uuid) { include_once($file); })($file, $ip, $uuid); } public static function hasOverride($key): bool { return array_key_exists($key, self::$overrides); } public static function getOverride($key) { return self::$overrides[$key]; } }