summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/inc/filter.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2016-12-06 16:21:56 +0100
committerSimon Rettberg2016-12-06 16:21:56 +0100
commit8fa66377a1c97d42d83d91ef0821f37f1b885617 (patch)
tree6386a99f2947194b89eac27127fe1805b25423d9 /modules-available/statistics/inc/filter.inc.php
parent[statistics] Check if module 'syslog' is active before showing client log (diff)
downloadslx-admin-8fa66377a1c97d42d83d91ef0821f37f1b885617.tar.gz
slx-admin-8fa66377a1c97d42d83d91ef0821f37f1b885617.tar.xz
slx-admin-8fa66377a1c97d42d83d91ef0821f37f1b885617.zip
[statistics/locations/..] Cache calculated locationid of machine in machine table
We now have three columns for the locationid: - subnetlocationid Updated whenever the clientip of a client changes on bootup, or when locations/subnets are edited in the locations module. - fixedlocationid Takes the role of the old locationid field - set when a machine is placed in a room via roomplanner, set to NULL otherwise. - locationid Set to fixedlocationid if it's not NULL, to subnetlocationid otherwise. The field is updated by a BEFORE UPDATE trigger.
Diffstat (limited to 'modules-available/statistics/inc/filter.inc.php')
-rw-r--r--modules-available/statistics/inc/filter.inc.php8
1 files changed, 3 insertions, 5 deletions
diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php
index 03dba6c3..6af6eed1 100644
--- a/modules-available/statistics/inc/filter.inc.php
+++ b/modules-available/statistics/inc/filter.inc.php
@@ -214,13 +214,11 @@ class LocationFilter extends Filter
{
settype($this->argument, 'int');
if ($this->argument === 0) {
- $joins[] = 'LEFT JOIN subnet s ON (INET_ATON(machine.clientip) BETWEEN s.startaddr AND s.endaddr)';
- return 'machine.locationid IS NULL AND s.locationid IS NULL';
+ $neg = $this->operator === '=' ? '' : 'NOT';
+ return "machine.locationid IS $neg NULL";
} else {
- $joins[] = ' LEFT JOIN subnet ON (INET_ATON(clientip) BETWEEN startaddr AND endaddr AND machine.locationid IS NULL) ';
$args['lid'] = $this->argument;
- $neg = $this->operator == '=' ? '' : 'NOT';
- return "$neg ((subnet.locationid = :lid) OR (machine.locationid = :lid))";
+ return "machine.locationid {$this->operator} :lid";
}
}
}