summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorSimon Rettberg2017-01-20 12:19:27 +0100
committerSimon Rettberg2017-01-20 12:19:27 +0100
commitc2affca145984d46056f91c0f7730275907cca0a (patch)
tree659fb2d1c41199601128044a19b84d3887453f2c /modules-available
parentDeleted the pcsubtable. Bugs/Usability fixes. (diff)
downloadslx-admin-c2affca145984d46056f91c0f7730275907cca0a.tar.gz
slx-admin-c2affca145984d46056f91c0f7730275907cca0a.tar.xz
slx-admin-c2affca145984d46056f91c0f7730275907cca0a.zip
[locationinfo] Take lastboot into account when calcing pc state
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/locationinfo/api.inc.php7
-rw-r--r--modules-available/locationinfo/inc/locationinfo.inc.php11
-rw-r--r--modules-available/locationinfo/page.inc.php4
3 files changed, 12 insertions, 10 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php
index 60537d5b..ddbd1304 100644
--- a/modules-available/locationinfo/api.inc.php
+++ b/modules-available/locationinfo/api.inc.php
@@ -225,9 +225,9 @@ function getRoomInfoJson($locationID, $coords) {
function getPcInfos($locationID, $coords) {
if ($coords == '1') {
- $dbquery = Database::simpleQuery("SELECT machineuuid, position, logintime, lastseen FROM `machine` WHERE locationid = :locationID" , array('locationID' => $locationID));
+ $dbquery = Database::simpleQuery("SELECT machineuuid, position, logintime, lastseen, lastboot FROM `machine` WHERE locationid = :locationID" , array('locationID' => $locationID));
} else {
- $dbquery = Database::simpleQuery("SELECT machineuuid, logintime, lastseen FROM `machine` WHERE locationid = :locationID" , array('locationID' => $locationID));
+ $dbquery = Database::simpleQuery("SELECT machineuuid, logintime, lastseen, lastboot FROM `machine` WHERE locationid = :locationID" , array('locationID' => $locationID));
}
$pcs = array();
@@ -244,13 +244,12 @@ function getPcInfos($locationID, $coords) {
$computer['y'] = $position['gridRow'];
}
- $computer['pcState'] = LocationInfo::getPcState((int)$pc['logintime'], (int)$pc['lastseen']);
+ $computer['pcState'] = LocationInfo::getPcState($pc);
$pcs[] = $computer;
}
$str = json_encode($pcs, true);
- error_log($str);
return $str;
}
diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php
index f81d79f6..d4bd2b0a 100644
--- a/modules-available/locationinfo/inc/locationinfo.inc.php
+++ b/modules-available/locationinfo/inc/locationinfo.inc.php
@@ -3,7 +3,7 @@
class LocationInfo
{
- public static function getPcState($logintime, $lastseen)
+ public static function getPcState($pc)
{
/* pcState:
* [0] = IDLE (NOT IN USE)
@@ -12,13 +12,16 @@ class LocationInfo
* [3] = 10 days offline (BROKEN?)
*/
+ $logintime = (int)$pc['logintime'];
+ $lastseen = (int)$pc['lastseen'];
+ $lastboot = (int)$pc['lastboot'];
$NOW = time();
- if ($NOW - $lastseen > 864000) {
+ if ($NOW - $lastseen > 14*86400) {
return 3;
- } elseif ($NOW - $lastseen > 610) {
+ } elseif (($NOW - $lastseen > 610) || $lastboot === 0) {
return 2;
- } elseif ($logintime == 0) {
+ } elseif ($logintime === 0) {
return 0;
} elseif ($logintime > 0) {
return 1;
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index e9ce1159..20df023c 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -384,7 +384,7 @@ class Page_LocationInfo extends Page
//TODO REMOVE FUNCTION. NOT NECCESSARY BUT AFTER TESTING pcSTATE
private function ajaxShowLocation($id)
{
- $dbquery = Database::simpleQuery("SELECT machineuuid, clientip, position, logintime, lastseen FROM `machine` WHERE locationid = :id", array('id' => $id));
+ $dbquery = Database::simpleQuery("SELECT machineuuid, clientip, position, logintime, lastseen, lastboot FROM `machine` WHERE locationid = :id", array('id' => $id));
$data = array();
@@ -392,7 +392,7 @@ class Page_LocationInfo extends Page
$pc = array();
$pc['id'] = $dbdata['machineuuid'];
$pc['ip'] = $dbdata['clientip'];
- $pc['pcState'] = LocationInfo::getPcState($dbdata['logintime'], $dbdata['lastseen']);
+ $pc['pcState'] = LocationInfo::getPcState($dbdata);
$position = json_decode($dbdata['position'], true);
$pc['x'] = $position['gridRow'];