functions.inc.php: fix check_quota() to handle unlimited maxquota

- explicitely check for unlimited maxquota when checking if 
  $quota > $limit[maxquota]. Without this, $quota was always
  considered as being too big (not surprising, everything is >0 ;-)
  This fixes https://sourceforge.net/tracker/?func=detail&aid=3306926&group_id=191583&atid=937964
  (caused by domain quota patch, therefore not affecting 2.3.x)
- replaced setting $rval with return in some cases if the decision is
  final without needing to check domain quota
- added lots of comments to make understanding the function easier



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1065 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 13 years ago
parent bd41cf1693
commit 62261f54ae

@ -682,31 +682,35 @@ function check_quota ($quota, $domain, $username="") {
global $CONF;
$rval = false;
$limit = get_domain_properties ($domain);
if ($limit['maxquota'] == 0)
{
$rval = true;
$rval = true; # maxquota unlimited -> OK, but domain level quota could still be hit
}
if (($limit['maxquota'] < 0) and ($quota < 0))
{
$rval = true;
return true; # maxquota and $quota are both disabled -> OK, no need for more checks
}
if (($limit['maxquota'] > 0) and ($quota == 0))
{
$rval = false;
return false; # mailbox with unlimited quota on a domain with maxquota restriction -> not allowed, no more checks needed
}
if ($quota > $limit['maxquota'])
if ($limit['maxquota'] != 0 && $quota > $limit['maxquota'])
{
$rval = false;
return false; # mailbox bigger than maxquota restriction (and maxquota != unlimited) -> not allowed, no more checks needed
}
else
{
$rval = true;
$rval = true; # mailbox size looks OK, but domain level quota could still be hit
}
# TODO: detailed error message ("domain quota exceeded", "mailbox quota too big" etc.) via flash_error? Or "available quota: xxx MB"?
if (!$rval || $CONF['domain_quota'] != 'YES') {
return $rval;
} elseif ($limit['quota'] <= 0) {
} elseif ($limit['quota'] <= 0) { # TODO: CHECK - 0 (unlimited) is fine, not sure about <= -1 (disabled)...
$rval = true;
} else {
$table_mailbox = table_by_key('mailbox');

Loading…
Cancel
Save