From c0e1411d154fdc235772a69a2fb7640da579c56e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 10 Jan 2020 11:44:43 +0100 Subject: [locations] Fix $selected array breakage Fixes places like "edit exam" which wouldn't show already selected locations. --- modules-available/locations/inc/location.inc.php | 10 ++++++++-- 1 file 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++; -- cgit v1.2.3-55-g7522