Skip to content

Commit

Permalink
fix zero division error when userquota is 0 but prevent setting quota…
Browse files Browse the repository at this point in the history
…=0 anyway
  • Loading branch information
Bernd Wurst committed Sep 29, 2024
1 parent 18ff9a5 commit 4dff892
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/systemuser/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
foreach ($usedquota as $q) {
$mailbar = '';
$mailstring = '';
$mailpercent = round(($q['mailquota'] / $q["systemquota"]) * 100);
$mailpercent = round(($q['mailquota'] / max($q["systemquota"],1)) * 100);
$mailwidth = 2 * min($mailpercent, 100);

if ($q["mailquota"] > 0) {
$mailstring = "<br />(davon {$q["mailquota"]} MB für Postfächer reserviert)";
$mailbar = "<div style=\"font-size: 1px; background-color: blue; height: 10px; width: {$mailwidth}px; margin: 0; padding: 0; float: left;\">&#160;</div>";
}

$percent = round((($q["systemquota_used"] + $q["mailquota"]) / $q["systemquota"]) * 100);
$percent = round((($q["systemquota_used"] + $q["mailquota"]) / max($q["systemquota"],1)) * 100);
$color = ($percent > 99 ? 'red' : ($percent > 80 ? "yellow" : "green"));
$width = 2 * min($percent, 100) - $mailwidth;

Expand Down
4 changes: 2 additions & 2 deletions modules/systemuser/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
foreach ($usedquota as $q) {
$mailbar = '';
$mailstring = '';
$mailpercent = round(($q['mailquota'] / $q["systemquota"]) * 100);
$mailpercent = round(($q['mailquota'] / max($q["systemquota"],1)) * 100);
$mailwidth = 2 * min($mailpercent, 100);

if ($q["mailquota"] > 0) {
$mailstring = "<br />(davon {$q["mailquota"]} MB für Postfächer reserviert)";
$mailbar = "<div style=\"font-size: 1px; background-color: blue; height: 10px; width: {$mailwidth}px; margin: 0; padding: 0; float: left;\">&#160;</div>";
}

$percent = round((($q["systemquota_used"] + $q["mailquota"]) / $q["systemquota"]) * 100);
$percent = round((($q["systemquota_used"] + $q["mailquota"]) / max($q["systemquota"],1)) * 100);
if ($percent > 90) {
$need_more_storage = true;
}
Expand Down
3 changes: 3 additions & 0 deletions modules/systemuser/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
$maxquota = $customerquota['max'] - $customerquota['assigned'] + $account['quota'];

$quota = (int) $_POST['quota'];
if ($quota < 1) {
system_failure("Sie müssen dem Account mindestens 1 MB Speicherplatz zuweisen.");
}
if ($quota > $maxquota) {
system_failure("Sie können diesem Account maximal {$maxquota} MB Speicherplatz zuweisen.");
}
Expand Down

0 comments on commit 4dff892

Please sign in to comment.