From 2a368cb3e597e35b467a6aebbaf35d42747681f5 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 26 Apr 2017 15:34:58 +0200 Subject: [baseconfig] Display inherited value and source when editing module specific settings This optionally requires a callback to find the inheritance source in the module in question. The locations module was updated accordingly. This implements #3120 --- modules-available/locations/baseconfig/hook.json | 3 ++- modules-available/locations/inc/location.inc.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'modules-available/locations') diff --git a/modules-available/locations/baseconfig/hook.json b/modules-available/locations/baseconfig/hook.json index c295e0f6..b7b3581b 100644 --- a/modules-available/locations/baseconfig/hook.json +++ b/modules-available/locations/baseconfig/hook.json @@ -1,5 +1,6 @@ { "table": "setting_location", "field": "locationid", - "tostring": "Location::getName" + "tostring": "Location::getName", + "getfallback": "Location::getBaseconfigParent" } \ No newline at end of file diff --git a/modules-available/locations/inc/location.inc.php b/modules-available/locations/inc/location.inc.php index 73080094..9977379f 100644 --- a/modules-available/locations/inc/location.inc.php +++ b/modules-available/locations/inc/location.inc.php @@ -279,6 +279,22 @@ class Location return $matchingLocations; } + /** + * @param $locationId + * @return bool|array ('value' => x, 'display' => y), false if no parent or unknown id + */ + public static function getBaseconfigParent($locationId) + { + settype($locationId, 'integer'); + $locations = Location::getLocationsAssoc(); + if (!isset($locations[$locationId])) + return false; + $locationId = (int)$locations[$locationId]['parentlocationid']; + if (!isset($locations[$locationId])) + return false; + return array('value' => $locationId, 'display' => $locations[$locationId]['locationname']); + } + /** * @return array list of subnets as numeric array */ -- cgit v1.2.3-55-g7522