Skip to content

Commit 99d4a96

Browse files
author
Till Brehm
committed
Merge branch 'task/sortSpaceNumbers' into 'stable-3.1'
Sort list quota correct See merge request ispconfig/ispconfig3!949
2 parents 7a179af + a64c9c8 commit 99d4a96

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

interface/lib/classes/listform_actions.inc.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class listform_actions {
3939
private $sortKeys;
4040

4141
private function _sort($aOne, $aTwo) {
42+
$suffixes=array('k' => 1, 'M' => 1024, 'G' => 1048576, 'T' => 1099511627776);
4243
if(!is_array($aOne) || !is_array($aTwo)) return 0;
4344

4445
if(!is_array($this->sortKeys)) $this->sortKeys = array($this->sortKeys);
@@ -49,6 +50,15 @@ private function _sort($aOne, $aTwo) {
4950
}
5051
$a = $aOne[$sKey];
5152
$b = $aTwo[$sKey];
53+
54+
if(preg_match('/(\d+\.?\d*) ([kMGT])B/', $a, $match)) {
55+
$a = $match[1] * $suffixes[$match[2]];
56+
}
57+
58+
if(preg_match('/(\d+\.?\d*) ([kMGT])B/', $b, $match)) {
59+
$b = $match[1] * $suffixes[$match[2]];
60+
}
61+
5262
if(is_string($a)) $a = strtolower($a);
5363
if(is_string($b)) $b = strtolower($b);
5464
if($a < $b) return $sDir == 'DESC' ? 1 : -1;
@@ -129,7 +139,7 @@ public function onLoad()
129139

130140
// Getting Datasets from DB
131141
$records = $app->db->queryAllRecords($this->getQueryString($php_sort));
132-
142+
133143
$csrf_token = $app->auth->csrf_token_get($app->listform->listDef['name']);
134144
$_csrf_id = $csrf_token['csrf_id'];
135145
$_csrf_key = $csrf_token['csrf_key'];

0 commit comments

Comments
 (0)