diff options
author | Simon Rettberg | 2019-11-05 18:01:37 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-11-05 18:01:37 +0100 |
commit | 50d28a0ad8dcf5d9fe697278b6ea05aa00f8fb87 (patch) | |
tree | 0418c774e8cbda6376f2f8a699af6e67a9055235 /modules-available/locations/inc | |
parent | [permissionmanager] Fix creating bogus negative cache entries (diff) | |
download | slx-admin-50d28a0ad8dcf5d9fe697278b6ea05aa00f8fb87.tar.gz slx-admin-50d28a0ad8dcf5d9fe697278b6ea05aa00f8fb87.tar.xz slx-admin-50d28a0ad8dcf5d9fe697278b6ea05aa00f8fb87.zip |
[baseconfig] Overhaul hook system
This enables us to finally properly show the inheritance flow
of all the config variables when editing the baseconfig for
a certain location or machine.
Diffstat (limited to 'modules-available/locations/inc')
-rw-r--r-- | modules-available/locations/inc/locationhooks.inc.php | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/modules-available/locations/inc/locationhooks.inc.php b/modules-available/locations/inc/locationhooks.inc.php index c15c34ab..5ce3bbfe 100644 --- a/modules-available/locations/inc/locationhooks.inc.php +++ b/modules-available/locations/inc/locationhooks.inc.php @@ -4,28 +4,26 @@ class LocationHooks { /** - * Used for baseconfig hook - * @param $locationId - * @return bool|array ('value' => x, 'display' => y), false if no parent or unknown id + * Resolve baseconfig id to locationid -- noop in this case */ - public static function getBaseconfigParent($locationId) + public static function baseconfigLocationResolver($id) { - $locationId = (int)$locationId; - $assoc = Location::getLocationsAssoc(); - if (!isset($assoc[$locationId])) - return false; - $locationId = (int)$assoc[$locationId]['parentlocationid']; - if (!isset($assoc[$locationId])) - return false; - return array('value' => $locationId, 'display' => $assoc[$locationId]['locationname']); + return $id; } /** - * Resolve baseconfig id to locationid -- noop in this case + * Hook to get inheritance tree for all config vars + * @param int $id Locationid currently being edited */ - public static function baseconfigLocationResolver($id) + public static function baseconfigInheritance($id) { - return $id; + $locs = Location::getLocationsAssoc(); + if ($locs === false || !isset($locs[$id])) + return []; + BaseConfig::prepareWithOverrides([ + 'locationid' => $locs[$id]['parentlocationid'] + ]); + return ConfigHolder::getRecursiveConfig(true); } }
\ No newline at end of file |