Commit f6ff1d28 authored by Robert Lyon's avatar Robert Lyon

Quota percent 'divide by zero' error (Bug 1393584)

Change-Id: I252c5f763ccc83d846f5dcc7fd086d723b31e2e6
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent c906c1e7
......@@ -108,7 +108,8 @@ if ($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionalo
'type' => 'bytes',
'title' => get_string('filequota1','admin'),
'description' => get_string('filequotadescription','admin') . '<br>' . $quotaused,
'rules' => array('integer' => true),
'rules' => array('integer' => true,
'minvalue' => 1),
'defaultvalue' => $user->quota,
);
}
......@@ -353,7 +354,7 @@ function edituser_site_submit(Pieform $form, $values) {
if ($quotanotifylimit <= 0 || $quotanotifylimit >= 100) {
$quotanotifylimit = 100;
}
$user->quotausedpercent = $user->quotaused / $user->quota * 100;
$user->quotausedpercent = empty($user->quota) ? 0 : ($user->quotaused / $user->quota) * 100;
$overlimit = false;
if ($quotanotifylimit <= $user->quotausedpercent) {
$overlimit = true;
......
......@@ -437,8 +437,7 @@ class PluginArtefactFile extends PluginArtefact {
if ($userid !== null) {
$userdata = get_user($userid);
$userdata->quotausedpercent = ($userdata->quotaused + $filesize ) / $userdata->quota * 100;
$userdata->quotausedpercent = empty($userdata->quota) ? 0 : (($userdata->quotaused + $filesize ) / $userdata->quota) * 100;
$overlimit = false;
if ($quotanotifylimit <= $userdata->quotausedpercent) {
$overlimit = true;
......@@ -457,7 +456,7 @@ class PluginArtefactFile extends PluginArtefact {
else if ($group !== null) {
$groupdata = get_record('group', 'id', $group);
$groupdata->quotausedpercent = ($groupdata->quotaused + $filesize ) / $groupdata->quota * 100;
$groupdata->quotausedpercent = empty($groupdata->quota) ? 0 : (($groupdata->quotaused + $filesize ) / $groupdata->quota) * 100;
$overlimit = false;
if ($quotanotifylimit <= $groupdata->quotausedpercent) {
$overlimit = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment