summaryrefslogtreecommitdiffstats
path: root/modules-available/remoteaccess/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2022-12-08 15:46:50 +0100
committerSimon Rettberg2022-12-08 15:46:50 +0100
commitacd63d1b88bf8605b3ef0f05ce9a2e25e10abcd0 (patch)
treeddb3bd392fe4cec3634fd740964a4c2bef39eff8 /modules-available/remoteaccess/page.inc.php
parent[statistics] Add ID45 partition size filter (diff)
downloadslx-admin-acd63d1b88bf8605b3ef0f05ce9a2e25e10abcd0.tar.gz
slx-admin-acd63d1b88bf8605b3ef0f05ce9a2e25e10abcd0.tar.xz
slx-admin-acd63d1b88bf8605b3ef0f05ce9a2e25e10abcd0.zip
[remoteaccess] Add list of active locations to overview page
References #3767
Diffstat (limited to 'modules-available/remoteaccess/page.inc.php')
-rw-r--r--modules-available/remoteaccess/page.inc.php54
1 files changed, 45 insertions, 9 deletions
diff --git a/modules-available/remoteaccess/page.inc.php b/modules-available/remoteaccess/page.inc.php
index fa94e193..ee9305dc 100644
--- a/modules-available/remoteaccess/page.inc.php
+++ b/modules-available/remoteaccess/page.inc.php
@@ -105,6 +105,36 @@ class Page_RemoteAccess extends Page
];
$data['plugin_version'] = Property::get(RemoteAccess::PROP_PLUGIN_VERSION);
Permission::addGlobalTags($data['perms'], null, ['group.locations', 'group.add', 'group.edit', 'set-proxy-ip']);
+ // List of locations used in at least one group
+ $res = Database::simpleQuery("SELECT l.locationid, l.locationname, g.groupid, g.groupname, g.active
+ FROM location l
+ INNER JOIN remoteaccess_x_location rxl USING (locationid)
+ INNER JOIN remoteaccess_group g USING (groupid)
+ ORDER BY locationname, locationid");
+ $data['locations'] = [];
+ $last = null;
+ foreach ($res as $row) {
+ if ($last === null || $last['locationid'] !== $row['locationid']) {
+ unset($last);
+ $last = [
+ 'locationid' => $row['locationid'],
+ 'locationname' => $row['locationname'],
+ 'lclass' => 'slx-strike',
+ 'groups' => [],
+ ];
+ $data['locations'][] =& $last;
+ }
+ $last['groups'][] = [
+ 'groupid' => $row['groupid'],
+ 'groupname' => $row['groupname'],
+ 'gclass' => $row['active'] ?: 'slx-strike',
+ ];
+ if ($row['active']) {
+ $last['lclass'] = '';
+ }
+ }
+ unset($last);
+ $this->addSchedulerTags($data['locations']);
Render::addTemplate('edit-settings', $data);
} else {
// Edit locations for group
@@ -117,19 +147,11 @@ class Page_RemoteAccess extends Page
$locationList[$lid]['checked'] = 'checked';
}
}
- $scheduler = Module::isAvailable('rebootcontrol');
+ $this->addSchedulerTags($locationList);
foreach ($locationList as $lid => &$loc) {
if (!in_array($lid, $allowed)) {
$loc['disabled'] = 'disabled';
}
- if ($scheduler) {
- $options = Scheduler::getLocationOptions($lid);
- if ($options['ra-mode'] === Scheduler::RA_SELECTIVE) {
- $loc['ra_selective'] = true;
- } elseif ($options['ra-mode'] === Scheduler::RA_NEVER) {
- $loc['ra_never'] = true;
- }
- }
}
$data = [
'groupid' => $groupid,
@@ -157,4 +179,18 @@ class Page_RemoteAccess extends Page
return empty($diff);
}
+ private function addSchedulerTags(array &$locationList)
+ {
+ if (!Module::isAvailable('rebootcontrol'))
+ return;
+ foreach ($locationList as $lid => &$loc) {
+ $options = Scheduler::getLocationOptions($loc['locationid'] ?? $lid);
+ if ($options['ra-mode'] === Scheduler::RA_SELECTIVE) {
+ $loc['ra_selective'] = true;
+ } elseif ($options['ra-mode'] === Scheduler::RA_NEVER) {
+ $loc['ra_never'] = true;
+ }
+ }
+ }
+
}