diff --git a/bureau/class/m_mail.php b/bureau/class/m_mail.php index 70552b57..f4d76d35 100644 --- a/bureau/class/m_mail.php +++ b/bureau/class/m_mail.php @@ -75,6 +75,7 @@ class m_mail { var $srv_pop3; var $srv_pop3s; + var $cache_domain_mail_size = array(); /* ----------------------------------------------------------------- */ /** * Constructeur @@ -110,6 +111,19 @@ class m_mail { return $obj; } + function get_total_size_for_domain($domain) { + global $db; + if (empty($this->cache_domain_mail_size)) { + $db->query("SELECT SUBSTRING_INDEX(user,'@', -1) as domain, SUM(quota_dovecot) AS sum FROM dovecot_view group by domain ;"); + while ($db->next_record() ) { + $dd = $db->f('domain'); + $this->cache_domain_mail_size[ $dd ] = $db->f('sum'); + } + } + if ( isset( $this->cache_domain_mail_size[$domain]) ) return $this->cache_domain_mail_size[$domain]; + return 0; + } + // FIXME documenter function catchall_getinfos($domain_id) { global $dom, $db; diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php index f533503a..857a962d 100644 --- a/bureau/class/m_quota.php +++ b/bureau/class/m_quota.php @@ -459,7 +459,8 @@ class m_quota { /* sum of mailbox sizes for one domain */ function get_size_mail_sum_domain($dom) { - return $this->_get_sum_sql("SELECT SUM(quota_dovecot) AS sum FROM dovecot_view WHERE user LIKE '%@{$dom}';"); + global $mail; + return $mail->get_total_size_for_domain($dom); } /* count of mailbox sizes from all domains */