summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/infopanel.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/locationinfo/inc/infopanel.inc.php')
-rw-r--r--modules-available/locationinfo/inc/infopanel.inc.php26
1 files changed, 22 insertions, 4 deletions
diff --git a/modules-available/locationinfo/inc/infopanel.inc.php b/modules-available/locationinfo/inc/infopanel.inc.php
index 1e2e7313..b0ee0d56 100644
--- a/modules-available/locationinfo/inc/infopanel.inc.php
+++ b/modules-available/locationinfo/inc/infopanel.inc.php
@@ -65,7 +65,7 @@ class InfoPanel
$config['locations'][$lid]['config'] = $overrides[$lid];
}
}
- self::appendMachineData($config['locations'], $lids, true);
+ self::appendMachineData($config['locations'], $lids, true, $config['hostname']);
}
self::appendOpeningTimes($config['locations'], $lids);
@@ -87,7 +87,7 @@ class InfoPanel
* @param array $array location list to populate with machine data
* @param bool $withPosition Defines if coords should be included or not.
*/
- public static function appendMachineData(&$array, $idList = false, $withPosition = false)
+ public static function appendMachineData(&$array, $idList = false, $withPosition = false, $withHostname = false)
{
if (empty($array) && $idList === false)
return;
@@ -101,8 +101,14 @@ class InfoPanel
$ignoreList = RunMode::getAllClients(false, false);
}
- $positionCol = $withPosition ? 'm.position,' : '';
- $query = "SELECT m.locationid, m.machineuuid, $positionCol m.logintime, m.lastseen, m.lastboot, m.state FROM machine m
+ $extraCols = '';
+ if ($withPosition) {
+ $extraCols .= 'm.position,';
+ }
+ if ($withHostname) {
+ $extraCols .= 'm.hostname,';
+ }
+ $query = "SELECT m.locationid, m.machineuuid, m.hostname, $extraCols m.logintime, m.lastseen, m.lastboot, m.state FROM machine m
WHERE m.locationid IN (:idlist)";
$dbquery = Database::simpleQuery($query, array('idlist' => $idList));
@@ -129,6 +135,18 @@ class InfoPanel
}
}
}
+ if ($withHostname) {
+ if (ip2long($row['hostname']) !== false) {
+ $pc['host'] = $row['hostname'];
+ } else {
+ $i = strpos($row['hostname'], '.');
+ if ($i === false) {
+ $pc['host'] = $row['hostname'];
+ } else {
+ $pc['host'] = substr($row['hostname'], 0, $i);
+ }
+ }
+ }
$pc['pcState'] = LocationInfo::getPcState($row);
//$pc['pcState'] = ['BROKEN', 'OFFLINE', 'IDLE', 'OCCUPIED', 'STANDBY'][mt_rand(0,4)]; // XXX