diff options
author | Simon Rettberg | 2017-05-09 17:31:37 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-05-09 17:31:37 +0200 |
commit | dd497ba5a35285e9b41ee592095d3356480ed9d6 (patch) | |
tree | 61926f10ab25af423c901dc9ffe475950b467918 /modules-available/rebootcontrol/inc/rebootqueries.inc.php | |
parent | Update translations (diff) | |
download | slx-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/rebootqueries.inc.php')
-rw-r--r-- | modules-available/rebootcontrol/inc/rebootqueries.inc.php | 17 |
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; } /** |