diff options
author | Simon Rettberg | 2019-02-12 14:55:49 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-02-12 14:55:49 +0100 |
commit | ec4ac82adaabe55cb9c3c40fad66d3451cb5f4d9 (patch) | |
tree | 0134ad4e33aa259250fb46a82e7da44b091db88e /modules-available/statistics/inc/filter.inc.php | |
parent | [serversetup*] PXELinux and iPXE side-by-side (diff) | |
parent | [inc/Dictionary] Teh evil unvalidated redirects must die! (diff) | |
download | slx-admin-ec4ac82adaabe55cb9c3c40fad66d3451cb5f4d9.tar.gz slx-admin-ec4ac82adaabe55cb9c3c40fad66d3451cb5f4d9.tar.xz slx-admin-ec4ac82adaabe55cb9c3c40fad66d3451cb5f4d9.zip |
Merge branch 'master' into ipxeipxe
Diffstat (limited to 'modules-available/statistics/inc/filter.inc.php')
-rw-r--r-- | modules-available/statistics/inc/filter.inc.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php index 3ccea2c3..46de467b 100644 --- a/modules-available/statistics/inc/filter.inc.php +++ b/modules-available/statistics/inc/filter.inc.php @@ -14,6 +14,13 @@ class Filter public $operator; public $argument; + private static $keyCounter = 0; + + public static function getNewKey($colname) + { + return $colname . '_' . (self::$keyCounter++); + } + public function __construct($column, $operator, $argument = null) { $this->column = trim($column); @@ -24,8 +31,7 @@ class Filter /* returns a where clause and adds needed operators to the passed array */ public function whereClause(&$args, &$joins) { - global $unique_key; - $key = $this->column . '_arg' . ($unique_key++); + $key = Filter::getNewKey($this->column); $addendum = ''; /* check if we have to do some parsing*/ @@ -226,8 +232,7 @@ class StateFilter extends Filter $map = [ 'on' => ['IDLE', 'OCCUPIED'], 'off' => ['OFFLINE'], 'idle' => ['IDLE'], 'occupied' => ['OCCUPIED'], 'standby' => ['STANDBY'] ]; $neg = $this->operator == '!=' ? 'NOT ' : ''; if (array_key_exists($this->argument, $map)) { - global $unique_key; - $key = $this->column . '_arg' . ($unique_key++); + $key = Filter::getNewKey($this->column); $args[$key] = $map[$this->argument]; return " machine.state $neg IN ( :$key ) "; } else { @@ -259,8 +264,7 @@ class LocationFilter extends Filter if ($this->argument === 0) { return "machine.locationid IS $neg NULL"; } else { - global $unique_key; - $key = $this->column . '_arg' . ($unique_key++); + $key = Filter::getNewKey($this->column); if ($recursive) { $args[$key] = array_keys(Location::getRecursiveFlat($this->argument)); } else { |