Du cache pour les quota de mails par domain
(on économise autant de requete que de domaine sur le compte)
This commit is contained in:
parent
4dd3a2c915
commit
13bbebaca1
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue