From cfd4396321b6b03c6e099ea4117d8d3d1874c6f5 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 25 Jul 2022 10:58:27 +0200 Subject: [remoteaccess] Don't uncheck currently disabled locations in group edit --- modules-available/remoteaccess/inc/remoteaccess.inc.php | 10 +++++++++- modules-available/remoteaccess/page.inc.php | 5 +++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules-available/remoteaccess/inc/remoteaccess.inc.php b/modules-available/remoteaccess/inc/remoteaccess.inc.php index ce6bf0db..7bd0e966 100644 --- a/modules-available/remoteaccess/inc/remoteaccess.inc.php +++ b/modules-available/remoteaccess/inc/remoteaccess.inc.php @@ -11,7 +11,13 @@ class RemoteAccess const PROP_PLUGIN_VERSION = 'remoteaccess.plugin-version'; - public static function getEnabledLocations(int $group = 0) + /** + * Get a list of locationIds where remote access is enabled. If $filterOverridden is true, + * the list will not contain any locations where remote access is disabled via location override. + * @param int $group Group to get locations for, or '0' for all locations + * @param bool $filterOverridden iff true, remove any locations where remote access is currently disabled + */ + public static function getEnabledLocations(int $group = 0, bool $filterOverridden = true): array { if ($group === 0) { $list = Database::queryColumnArray("SELECT DISTINCT rxl.locationid FROM remoteaccess_x_location rxl @@ -20,6 +26,8 @@ class RemoteAccess $list = Database::queryColumnArray("SELECT DISTINCT locationid FROM remoteaccess_x_location WHERE groupid = :gid", ['gid' => $group]); } + if (!$filterOverridden || !Module::isAvailable('rebootcontrol')) + return $list; return array_filter($list, function (int $lid) { $mode = Scheduler::getLocationOptions($lid)['ra-mode']; return ($mode !== Scheduler::RA_NEVER diff --git a/modules-available/remoteaccess/page.inc.php b/modules-available/remoteaccess/page.inc.php index 05816beb..fa94e193 100644 --- a/modules-available/remoteaccess/page.inc.php +++ b/modules-available/remoteaccess/page.inc.php @@ -93,7 +93,8 @@ class Page_RemoteAccess extends Page // Edit list of groups and their settings $groups = Database::queryAll("SELECT g.groupid, g.groupname, g.wolcount, g.passwd, Count(l.locationid) AS locs, If(g.active, 'checked', '') AS checked, unwoken - FROM remoteaccess_group g LEFT JOIN remoteaccess_x_location l USING (groupid) + FROM remoteaccess_group g + LEFT JOIN remoteaccess_x_location l USING (groupid) GROUP BY g.groupid, g.groupname ORDER BY g.groupname ASC"); $data = [ @@ -109,7 +110,7 @@ class Page_RemoteAccess extends Page // Edit locations for group $group = $this->groupNameOrFail($groupid); $locationList = Location::getLocationsAssoc(); - $enabled = RemoteAccess::getEnabledLocations($groupid); + $enabled = RemoteAccess::getEnabledLocations($groupid, false); $allowed = User::getAllowedLocations('group.locations'); foreach ($enabled as $lid) { if (isset($locationList[$lid])) { -- cgit v1.2.3-55-g7522