summaryrefslogtreecommitdiffstats
path: root/modules-available/rebootcontrol/inc
diff options
context:
space:
mode:
authorSimon Rettberg2017-05-09 17:31:37 +0200
committerSimon Rettberg2017-05-09 17:31:37 +0200
commitdd497ba5a35285e9b41ee592095d3356480ed9d6 (patch)
tree61926f10ab25af423c901dc9ffe475950b467918 /modules-available/rebootcontrol/inc
parentUpdate translations (diff)
downloadslx-admin-dd497ba5a35285e9b41ee592095d3356480ed9d6.tar.gz
slx-admin-dd497ba5a35285e9b41ee592095d3356480ed9d6.tar.xz
slx-admin-dd497ba5a35285e9b41ee592095d3356480ed9d6.zip
[rebootcontrol] Fix current session display, colors for on/off
Diffstat (limited to 'modules-available/rebootcontrol/inc')
-rw-r--r--modules-available/rebootcontrol/inc/rebootqueries.inc.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/modules-available/rebootcontrol/inc/rebootqueries.inc.php b/modules-available/rebootcontrol/inc/rebootqueries.inc.php
index 62092748..3b665e5b 100644
--- a/modules-available/rebootcontrol/inc/rebootqueries.inc.php
+++ b/modules-available/rebootcontrol/inc/rebootqueries.inc.php
@@ -19,12 +19,25 @@ class RebootQueries
}
$res = Database::simpleQuery("
SELECT machine.machineuuid, machine.hostname, machine.clientip,
- IF(machine.lastboot = 0 OR UNIX_TIMESTAMP() - machine.lastseen >= 600, 0, 1) AS status,
+ machine.lastboot, machine.lastseen, machine.logintime,
$sessionField, machine.currentuser, machine.locationid
FROM machine
$leftJoin
WHERE " . $where, array('locationid' => $locationId));
- return $res->fetchAll(PDO::FETCH_ASSOC);
+ $ret = $res->fetchAll(PDO::FETCH_ASSOC);
+ $NOW = time();
+ foreach ($ret as &$row) {
+ if ($row['lastboot'] == 0 || $NOW - $row['lastseen'] > 600) {
+ $row['status'] = 0;
+ } else {
+ $row['status'] = 1;
+ }
+ if ($row['status'] === 0 || $row['logintime'] == 0) {
+ $row['currentuser'] = '';
+ $row['currentsession'] = '';
+ }
+ }
+ return $ret;
}
/**