summaryrefslogtreecommitdiffstats
path: root/modules-available/locations
diff options
context:
space:
mode:
authorSimon Rettberg2020-01-10 11:44:43 +0100
committerSimon Rettberg2020-01-10 11:44:43 +0100
commitc0e1411d154fdc235772a69a2fb7640da579c56e (patch)
tree16a335eed233eb2873e212a23764ece53d951a16 /modules-available/locations
parent[permissionmanager] Make default roles "builtin" i.e. not modifiable (diff)
downloadslx-admin-c0e1411d154fdc235772a69a2fb7640da579c56e.tar.gz
slx-admin-c0e1411d154fdc235772a69a2fb7640da579c56e.tar.xz
slx-admin-c0e1411d154fdc235772a69a2fb7640da579c56e.zip
[locations] Fix $selected array breakage
Fixes places like "edit exam" which wouldn't show already selected locations.
Diffstat (limited to 'modules-available/locations')
-rw-r--r--modules-available/locations/inc/location.inc.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules-available/locations/inc/location.inc.php b/modules-available/locations/inc/location.inc.php
index a29be5c3..37e6e720 100644
--- a/modules-available/locations/inc/location.inc.php
+++ b/modules-available/locations/inc/location.inc.php
@@ -119,9 +119,15 @@ class Location
return $output;
}
+ /**
+ * @param int|int[] $selected Which locationIDs to mark as selected
+ * @param int $excludeId Which locationID to explude
+ * @param bool $addNoParent Add entry for "no location" at the top
+ * @param bool $keepArrayKeys Keep location IDs as array index
+ * @return array Locations
+ */
public static function getLocations($selected = 0, $excludeId = 0, $addNoParent = false, $keepArrayKeys = false)
{
- $selected = (int)$selected;
if (self::$flatLocationCache === false) {
$rows = self::getTree();
$rows = self::flattenTree($rows);
@@ -142,7 +148,7 @@ class Location
unset($rows[$key]);
continue;
}
- if ((is_array($selected) && in_array($row['locationid'], $selected)) || (int)$row['locationid'] === $selected) {
+ if ((is_array($selected) && in_array($row['locationid'], $selected)) || $row['locationid'] == $selected) {
$row['selected'] = true;
}
$row['sortIndex'] = $index++;