From e8b3291ecd0c5278b9ddc274769a3809e92f5c16 Mon Sep 17 00:00:00 2001
From: Dominik Mueller <info@profi-webdesign.net>
Date: Wed, 26 Feb 2014 18:05:31 -0500
Subject: [PATCH] Quota-Lib für remote-quota-angaben Erweiterungen für remote-Quota

---
 interface/web/dashboard/dashlets/mailquota.php |   61 ++----------------------------
 1 files changed, 4 insertions(+), 57 deletions(-)

diff --git a/interface/web/dashboard/dashlets/mailquota.php b/interface/web/dashboard/dashlets/mailquota.php
index 68105a5..923784f 100644
--- a/interface/web/dashboard/dashlets/mailquota.php
+++ b/interface/web/dashboard/dashlets/mailquota.php
@@ -16,70 +16,17 @@
 		if(is_file($lng_file)) include $lng_file;
 		$tpl->setVar($wb);
 
-		$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) {
-				//$monitor_data = array_merge_recursive($monitor_data,unserialize($app->db->unquote($tmp_mon['data'])));
-				$tmp_array = unserialize($app->db->unquote($tmp_mon['data']));
-				if(is_array($tmp_array)) {
-					foreach($tmp_array as $username => $data) {
-						if(!$monitor_data[$username]['used']) $monitor_data[$username]['used'] = $data['used'];
-					}
-				}
-			}
-		}
-		//print_r($monitor_data);
-		if($_SESSION["s"]["user"]["typ"] != 'admin'){
-			$sql_where = " AND sys_groupid = ".intval($_SESSION['s']['user']['default_group']);
-		}
+		$emails = $app->quota_lib->get_mailquota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['default_group'] : null);
+		//print_r($emails);
 
 		$has_mailquota = false;
-		// select email accounts belonging to client
-		$emails = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE 1".$sql_where);
-		//print_r($emails);
 		if(is_array($emails) && !empty($emails)){
-			for($i=0;$i<sizeof($emails);$i++){
-				$email = $emails[$i]['email'];
-
-				$emails[$i]['used'] = isset($monitor_data[$email]['used']) ? $monitor_data[$email]['used'] : array(1 => 0);
-
-				if (!is_numeric($emails[$i]['used'])) $emails[$i]['used']=$emails[$i]['used'][1];
-
-				// colours
-				$emails[$i]['display_colour'] = '#000000';
-				if($emails[$i]['quota'] > 0){
-					$used_ratio = $emails[$i]['used']/$emails[$i]['quota'];
-				} else {
-					$used_ratio = 0;
-				}
-				if($used_ratio >= 0.8) $emails[$i]['display_colour'] = '#fd934f';
-				if($used_ratio >= 1) $emails[$i]['display_colour'] = '#cc0000';
-
-				if($emails[$i]['quota'] == 0){
-					$emails[$i]['quota'] = $app->lng('unlimited');
-				} else {
-					$emails[$i]['quota'] = round($emails[$i]['quota'] / 1048576, 4).' MB';
-				}
-
-
-				if($emails[$i]['used'] < 1544000) {
-					$emails[$i]['used'] = round($emails[$i]['used'] / 1024, 4).' KB';
-				} else {
-					$emails[$i]['used'] = round($emails[$i]['used'] / 1048576, 4).' MB';
-				}
-
-			}
-			$has_mailquota = true;
 			$tpl->setloop('mailquota', $emails);
+			$has_mailquota = isset($emails[0]['used']);
 		}
-		//print_r($sites);
-
 		$tpl->setVar('has_mailquota', $has_mailquota);
-
+		
 		return $tpl->grab();
-
-
 	}
 
 }

--
Gitblit v1.9.1