From d9bcf68e395d6156645a7974b1a992aa6e6c00aa Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Mon, 14 Oct 2013 08:57:25 -0400
Subject: [PATCH] Added missing empty directories from svn import

---
 interface/web/mail/user_quota_stats.php |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/interface/web/mail/user_quota_stats.php b/interface/web/mail/user_quota_stats.php
index df036ea..dfc1d8a 100644
--- a/interface/web/mail/user_quota_stats.php
+++ b/interface/web/mail/user_quota_stats.php
@@ -19,7 +19,7 @@
 
 // $tmp_rec = $app->db->queryOneRecord("SELECT data from monitor_data WHERE type = 'harddisk_quota' ORDER BY created DESC");
 // $monitor_data = unserialize($app->db->unquote($tmp_rec['data']));
-$tmp_rec =  $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'email_quota' ORDER BY created DESC LIMIT 0,1");
+$tmp_rec =  $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'email_quota' ORDER BY created DESC");
 $monitor_data = array();
 if(is_array($tmp_rec)) {
 	foreach ($tmp_rec as $tmp_mon) {
@@ -27,7 +27,7 @@
 		$tmp_array = unserialize($app->db->unquote($tmp_mon['data']));
 		if(is_array($tmp_array)) {
 			foreach($tmp_array as $username => $data) {
-				$monitor_data[$username]['used'] += $data['used'];
+				if(!$monitor_data[$username]['used']) $monitor_data[$username]['used'] = $data['used'];
 			}
 		}
 	}
@@ -50,16 +50,24 @@
 		$rec['used'] = isset($monitor_data[$email]['used']) ? $monitor_data[$email]['used'] : array(1 => 0);
 		
 		if (!is_numeric($rec['used'])) $rec['used']=$rec['used'][1];
-
-        $rec['quota'] = round($rec['quota'] / 1048576,2).' MB';
-		if($rec['quota'] == "0 MB") $rec['quota'] = $app->lng('unlimited');
+		
+		if($rec['quota'] == 0){
+			$rec['quota'] = $app->lng('unlimited');
+            $rec['percentage'] = '';
+            $rec['percentage_sort'] = 0;
+		} else {
+            $rec['percentage'] = round(100 * $rec['used'] / $rec['quota']) . '%';
+			$rec['percentage_sort'] = round(100 * $rec['used'] / $rec['quota']);
+			$rec['quota'] = round($rec['quota'] / 1048576,4).' MB';
+		}
 
 
+        $rec['used_sort'] = $rec['used'];
         if($rec['used'] < 1544000) {
-            $rec['used'] = round($rec['used'] / 1024,2).' KB';
+            $rec['used'] = round($rec['used'] / 1024,4).' KB';
         } else {
-            $rec['used'] = round($rec['used'] / 1048576,2).' MB';
-        }   
+            $rec['used'] = round($rec['used'] / 1048576,4).' MB';
+        }
 
 		//* The variable "id" contains always the index variable
 		$rec['id'] = $rec[$this->idx_key];

--
Gitblit v1.9.1