From f01ffbb57a11a4665a0e0fb2cc4dca9069a6554f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 1 Aug 2019 13:57:28 +0200 Subject: [locations] Remove list filtering depending on permissions Locations where the user isn't allowed to do anything were supposed to be hidden while at the same time making sure that any parent locations would still be shown. That code was buggy and could display nonsensical ordering of locations, and even sometimes hide locations where the user was actually allowed to e.g. edit the assigned config module. Since the location names aren't secret anyways, just get rid of this broken code. --- .../locations/pages/locations.inc.php | 30 +++++----------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/modules-available/locations/pages/locations.inc.php b/modules-available/locations/pages/locations.inc.php index 275aafdb..b1fd77d4 100644 --- a/modules-available/locations/pages/locations.inc.php +++ b/modules-available/locations/pages/locations.inc.php @@ -92,39 +92,21 @@ class SubPage $unassigned = false; $unassignedLoad = 0; - // Filter view: Remove locations we can't reach at all, but show parents to locations - // we have permission to, so the tree doesn't look all weird - $visibleLocationIds = $allowedLocationIds = User::getAllowedLocations("location.view"); - foreach ($allowedLocationIds as $lid) { - if (!isset($locationList[$lid])) - continue; - $visibleLocationIds = array_merge($visibleLocationIds, $locationList[$lid]['parents']); - } - $visibleLocationIds = array_unique($visibleLocationIds); + $allowedLocationIds = User::getAllowedLocations("location.view"); foreach (array_keys($locationList) as $lid) { - if (User::hasPermission('.baseconfig.view', $lid)) { - $visibleLocationIds[] = $lid; - } else { + if (!User::hasPermission('.baseconfig.view', $lid)) { $locationList[$lid]['havebaseconfig'] = false; } - if (User::hasPermission('.sysconfig.config.view-list', $lid)) { - $visibleLocationIds[] = $lid; - } else { + if (!User::hasPermission('.sysconfig.config.view-list', $lid)) { $locationList[$lid]['havesysconfig'] = false; } - if (User::hasPermission('.statistics.view.list', $lid)) { - $visibleLocationIds[] = $lid; - } else { + if (!User::hasPermission('.statistics.view.list', $lid)) { $locationList[$lid]['havestatistics'] = false; } - if (User::hasPermission('.serversetup.ipxe.menu.assign', $lid)) { - $visibleLocationIds[] = $lid; - } else { + if (!User::hasPermission('.serversetup.ipxe.menu.assign', $lid)) { $locationList[$lid]['haveipxe'] = false; } - if (!in_array($lid, $visibleLocationIds)) { - unset($locationList[$lid]); - } elseif (!in_array($lid, $allowedLocationIds)) { + if (!in_array($lid, $allowedLocationIds)) { $locationList[$lid]['show-only'] = true; } } -- cgit v1.2.3-55-g7522