summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/page.inc.php
diff options
context:
space:
mode:
authorUdo Walter2017-11-21 17:52:04 +0100
committerUdo Walter2017-11-21 17:52:04 +0100
commit653851f35d0eea172c2302e9f1b6f0d03c70096c (patch)
tree42f267c360104b98d2e3199273adba62a1e2023b /modules-available/statistics/page.inc.php
parent[internetaccess] reworked permission system from "click and you get error" to... (diff)
parent[statistics] Also adapt MAC-UUID fixing code to mltk changes (diff)
downloadslx-admin-653851f35d0eea172c2302e9f1b6f0d03c70096c.tar.gz
slx-admin-653851f35d0eea172c2302e9f1b6f0d03c70096c.tar.xz
slx-admin-653851f35d0eea172c2302e9f1b6f0d03c70096c.zip
Merge remote-tracking branch 'origin/master' into permission-manager
# Conflicts: # modules-available/backup/templates/_page.html # style/default.css
Diffstat (limited to 'modules-available/statistics/page.inc.php')
-rw-r--r--modules-available/statistics/page.inc.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php
index dd3e5ee6..a003a303 100644
--- a/modules-available/statistics/page.inc.php
+++ b/modules-available/statistics/page.inc.php
@@ -308,6 +308,14 @@ class Page_Statistics extends Page
}
}
+ private function redirectFirst($where, $join, $args)
+ {
+ $res = Database::queryFirst("SELECT machineuuid FROM machine $join WHERE ($where) LIMIT 1", $args);
+ if ($res !== false) {
+ Util::redirect('?do=statistics&uuid=' . $res['machineuuid']);
+ }
+ }
+
/**
* @param \FilterSet $filterSet
*/
@@ -316,6 +324,10 @@ class Page_Statistics extends Page
$filterSet->makeFragments($where, $join, $sort, $args);
$known = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE ($where)", $args);
+ // If we only have one machine, redirect to machine details
+ if ($known['val'] == 1) {
+ $this->redirectFirst($where, $join, $args);
+ }
$on = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE lastboot <> 0 AND ($where)", $args);
$used = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE lastboot <> 0 AND logintime <> 0 AND ($where)", $args);
$hdd = Database::queryFirst("SELECT Count(*) AS val FROM machine $join WHERE badsectors >= 10 AND ($where)", $args);
@@ -566,7 +578,13 @@ class Page_Statistics extends Page
. " $join WHERE $where $sort", $args);
$rows = array();
$NOW = time();
+ $singleMachine = 'none';
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ if ($singleMachine === 'none') {
+ $singleMachine = $row['machineuuid'];
+ } else {
+ $singleMachine = false;
+ }
if ($row['lastboot'] == 0) {
$row['state_off'] = true;
} elseif ($row['logintime'] == 0) {
@@ -598,6 +616,9 @@ class Page_Statistics extends Page
}
$rows[] = $row;
}
+ if ($singleMachine !== false && $singleMachine !== 'none') {
+ Util::redirect('?do=statistics&uuid=' . $singleMachine);
+ }
Render::addTemplate('clientlist', array(
'rowCount' => count($rows),
'rows' => $rows,