From 4a8c177fcb2239bef78db6502f3d02e95db9fb1e Mon Sep 17 00:00:00 2001 From: domi <> Date: Fri, 24 Aug 2012 17:16:29 +0000 Subject: [PATCH] Refactoring quotas 'oneuser' display with get_size_xx function --- bureau/admin/quotas_oneuser.php | 45 +++++++++++++++++++++++---------- bureau/class/m_quota.php | 40 ++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 15 deletions(-) diff --git a/bureau/admin/quotas_oneuser.php b/bureau/admin/quotas_oneuser.php index af7039bf..1e6a60bb 100644 --- a/bureau/admin/quotas_oneuser.php +++ b/bureau/admin/quotas_oneuser.php @@ -8,10 +8,10 @@ if (!defined("QUOTASONE")) return;
"._("Web Space:")." "; - echo sprintf("%.1f", $totalweb / 1024)." "._("MB"); + echo "
"._("Web Space:")." "; + echo sprintf("%.1f", $totalweb / 1024)." "._("MB"); echo "
"; ?> @@ -31,14 +31,18 @@ if (!defined("QUOTASONE")) return; $s=mysql_query("SELECT * FROM domaines WHERE compte='".$c["uid"]."';"); $totalmail=0; while ($d=mysql_fetch_array($s)) { - list($mstmp)=@mysql_fetch_array(mysql_query("SELECT SUM(size) FROM size_mail WHERE alias LIKE '%\_".$d["domaine"]."';")); + $mstmp = $quota->get_size_mail_sum_domain($d["domaine"]); $totalmail+=$mstmp; } + echo ""._("Mail boxes:")." "; + echo sprintf("%.1f", $totalmail / 1024)." "._("MB"); + echo "
"; + $s=mysql_query("SELECT * FROM domaines WHERE compte='".$c["uid"]."';"); while ($d=mysql_fetch_array($s)) { - $t=mysql_query("SELECT alias,size FROM size_mail WHERE alias LIKE '%\_".$d["domaine"]."' ORDER BY alias;"); - while ($e=mysql_fetch_array($t)) { + $alias_sizes = $quota->get_size_mail_details_domain($d["domaine"]); + foreach ($alias_sizes as $e) { echo "+get_size_db_sum_user($c["login"]); + + echo "
"._("Databases:")." "; + echo sprintf("%.1f", $totaldb/(1024*1024))." "._("MB"); + echo "
"; +?> +".$d["db"]." | "; @@ -100,10 +111,16 @@ if (!defined("QUOTASONE")) return; |
+ +"._("Mailman lists:")." "; + echo sprintf("%.1f", $totallist/1024)." "._("MB"); + echo ""; +?>
".$d["list"]." | "; diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php index 30f054e0..76018384 100644 --- a/bureau/class/m_quota.php +++ b/bureau/class/m_quota.php @@ -387,6 +387,20 @@ class m_quota { } } + function _get_size_and_record_sql($sql) { + global $db,$err,$cuid; + $db->query($sql); + if ($db->num_rows() == 0) { + return array(); + } else { + $ret = array(); + while ($db->next_record()) { + $ret[] = $db->Record; + } + return $ret; + } + } + /* sum of websites sizes from all users */ function get_size_web_sum_all() { return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web;"); @@ -397,6 +411,7 @@ class m_quota { return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web WHERE uid='$u';"); } + /* sum of mailbox sizes from all domains */ function get_size_mail_sum_all() { return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mail;"); @@ -417,6 +432,12 @@ class m_quota { return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mail FROM size_mail WHERE alias LIKE '%\_{$dom}'"); } + /* get list of mailbox alias and size for one domain */ + function get_size_mail_details_domain($dom) { + return $this->_get_size_and_record_sql("SELECT alias,size FROM size_mail WHERE alias LIKE '%\_{$dom}' ORDER BY alias;"); + } + + /* sum of mailman lists sizes from all domains */ function get_size_mailman_sum_all() { return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman;"); @@ -427,6 +448,11 @@ class m_quota { return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE list LIKE '%@{$dom}'"); } + /* sum of mailman lists for one user */ + function get_size_mailman_sum_user($u) { + return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE uid = '{$u}'"); + } + /* count of mailman lists sizes from all domains */ function get_size_mailman_count_all() { return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman;"); @@ -437,6 +463,12 @@ class m_quota { return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman WHERE uid = '{$u}'"); } + /* get list of mailman list and size for one user */ + function get_size_mailman_details_user($u) { + return $this->_get_size_and_record_sql("SELECT list,size FROM size_mailman WHERE uid='{$u}' ORDER BY list ASC"); + } + + /* sum of databases sizes from all users */ function get_size_db_sum_all() { return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db;"); @@ -452,11 +484,17 @@ class m_quota { return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db;"); } - /* count of mailman lists for one user */ + /* count of databases for one user */ function get_size_db_count_user($u) { return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'"); } + /* get list of databases name and size for one user */ + function get_size_db_details_user($u) { + return $this->_get_size_and_record_sql("SELECT db,size FROM size_db WHERE db='{$u}' OR db LIKE '{$u}\_%';"); + } + + #list($dc)=@mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM domaines;")); |