From 6ed298ccef579bed22152efd0b314bea52b98c17 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 17 Jun 2016 18:54:18 +0200 Subject: [location] Support passing array of selected locs to getLocations() --- modules-available/locations/inc/location.inc.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 bd642a57..788fc588 100644 --- a/modules-available/locations/inc/location.inc.php +++ b/modules-available/locations/inc/location.inc.php @@ -64,8 +64,11 @@ class Location return $output; } - public static function getLocations($default = 0, $excludeId = 0, $addNoParent = false) + public static function getLocations($selected = 0, $excludeId = 0, $addNoParent = false) { + if (is_string($selected)) { + settype($selected, 'int'); + } if (self::$flatLocationCache === false) { $rows = self::getTree(); $rows = self::flattenTree($rows); @@ -85,7 +88,7 @@ class Location unset($rows[$key]); continue; } - if ($row['locationid'] == $default) { + if ((is_array($selected) && in_array($row['locationid'], $selected)) || (int)$row['locationid'] === $selected) { $row['selected'] = true; } } @@ -93,7 +96,7 @@ class Location array_unshift($rows, array( 'locationid' => 0, 'locationname' => '-----', - 'selected' => $default == 0 + 'selected' => $selected === 0 )); } return array_values($rows); @@ -130,8 +133,6 @@ class Location 'locationid' => $node['locationid'], 'locationname' => $node['locationname'], 'locationpad' => str_repeat('--', $depth), - 'locationspan1' => $depth + 1, - 'locationspan2' => 10 - $depth, 'depth' => $depth ); if (!empty($node['children'])) { -- cgit v1.2.3-55-g7522