From a6a484ea37aeb91f848c11cb818e2d7d4351d391 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 22 Jun 2016 17:56:04 +0200 Subject: [locations/sysconfig] Implement location specific sysconfig --- modules-available/locations/inc/location.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules-available/locations/inc') diff --git a/modules-available/locations/inc/location.inc.php b/modules-available/locations/inc/location.inc.php index 788fc588..b1474279 100644 --- a/modules-available/locations/inc/location.inc.php +++ b/modules-available/locations/inc/location.inc.php @@ -64,7 +64,7 @@ class Location return $output; } - public static function getLocations($selected = 0, $excludeId = 0, $addNoParent = false) + public static function getLocations($selected = 0, $excludeId = 0, $addNoParent = false, $keepArrayKeys = false) { if (is_string($selected)) { settype($selected, 'int'); @@ -99,6 +99,8 @@ class Location 'selected' => $selected === 0 )); } + if ($keepArrayKeys) + return $rows; return array_values($rows); } @@ -129,14 +131,14 @@ class Location } $output = array(); foreach ($tree as $node) { - $output[] = array( + $output[(int)$node['locationid']] = array( 'locationid' => $node['locationid'], 'locationname' => $node['locationname'], 'locationpad' => str_repeat('--', $depth), 'depth' => $depth ); if (!empty($node['children'])) { - $output = array_merge($output, self::flattenTree($node['children'], $depth + 1)); + $output += self::flattenTree($node['children'], $depth + 1); } } return $output; -- cgit v1.2.3-55-g7522