summaryrefslogtreecommitdiffstats
path: root/modules-available/locations/inc
diff options
context:
space:
mode:
authorSimon Rettberg2016-06-17 18:54:18 +0200
committerSimon Rettberg2016-06-17 18:54:18 +0200
commit6ed298ccef579bed22152efd0b314bea52b98c17 (patch)
tree6d9dea4a1eee6629dfb38d03ac32f366213b8c9c /modules-available/locations/inc
parentAdded installation script. (diff)
downloadslx-admin-6ed298ccef579bed22152efd0b314bea52b98c17.tar.gz
slx-admin-6ed298ccef579bed22152efd0b314bea52b98c17.tar.xz
slx-admin-6ed298ccef579bed22152efd0b314bea52b98c17.zip
[location] Support passing array of selected locs to getLocations()
Diffstat (limited to 'modules-available/locations/inc')
-rw-r--r--modules-available/locations/inc/location.inc.php11
1 files changed, 6 insertions, 5 deletions
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'])) {