From 616226be8a99c07386429d48ecf5b31c4907b958 Mon Sep 17 00:00:00 2001 From: andryyy Date: Thu, 8 Apr 2021 11:17:27 +0200 Subject: [PATCH] [Web] Fix quota calculation, fixes #4036 --- data/web/inc/functions.mailbox.inc.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php index ae9aeadf..f11d8440 100644 --- a/data/web/inc/functions.mailbox.inc.php +++ b/data/web/inc/functions.mailbox.inc.php @@ -2388,11 +2388,6 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ); return false; } - $stmt = $pdo->prepare("SELECT `quota`, `maxquota` - FROM `domain` - WHERE `domain` = :domain"); - $stmt->execute(array(':domain' => $domain)); - $DomainData = $stmt->fetch(PDO::FETCH_ASSOC); if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) { $_SESSION['return'][] = array( 'type' => 'danger', @@ -2401,7 +2396,8 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ); continue; } - if ((($is_now['quota_used'] / 1048576) + $quota_m) > $DomainData['quota']) { + $DomainData = mailbox('get', 'domain_details', $domain); + if ($quota_m > ($is_now['max_new_quota'] / 1048576)) { $_SESSION['return'][] = array( 'type' => 'danger', 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr), @@ -2409,11 +2405,11 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ); continue; } - if ($quota_m > $DomainData['maxquota']) { + if ($quota_m > $DomainData['max_quota_for_mbox']) { $_SESSION['return'][] = array( 'type' => 'danger', 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr), - 'msg' => array('mailbox_quota_exceeded', $DomainData['maxquota']) + 'msg' => array('mailbox_quota_exceeded', $DomainData['max_quota_for_mbox']) ); continue; }