diff --git a/admin/tool/messageinbound/classes/manager.php b/admin/tool/messageinbound/classes/manager.php index 81e8c1b69e9..0e25a023202 100644 --- a/admin/tool/messageinbound/classes/manager.php +++ b/admin/tool/messageinbound/classes/manager.php @@ -672,7 +672,7 @@ class manager { $attachment->charset = $partdata->getCharset(); $attachment->description = $partdata->getDescription(); $attachment->contentid = $partdata->getContentId(); - $attachment->filesize = $messagedata->getBodyPartSize($part); + $attachment->filesize = $partdata->getBytes(); if (!empty($CFG->antiviruses)) { mtrace("--> Attempting virus scan of '{$attachment->filename}'"); diff --git a/lib/classes/message/inbound/private_files_handler.php b/lib/classes/message/inbound/private_files_handler.php index a0eba4071a6..64d9d2541b5 100644 --- a/lib/classes/message/inbound/private_files_handler.php +++ b/lib/classes/message/inbound/private_files_handler.php @@ -26,6 +26,8 @@ namespace core\message\inbound; defined('MOODLE_INTERNAL') || die(); +require_once($CFG->libdir . '/filelib.php'); + /** * A Handler to store attachments sent in e-mails as private files. * @@ -98,15 +100,17 @@ class private_files_handler extends handler { $uploadedfiles = array(); $failedfiles = array(); + $usedspace = file_get_user_used_space(); $fs = get_file_storage(); foreach ($data->attachments as $attachmenttype => $attachments) { foreach ($attachments as $attachment) { mtrace("--- Processing attachment '{$attachment->filename}'"); - if (file_is_draft_area_limit_reached($itemid, $maxbytes, $attachment->filesize)) { + if ($maxbytes != USER_CAN_IGNORE_FILE_SIZE_LIMITS && + ($attachment->filesize + $usedspace) > $maxbytes) { // The user quota will be exceeded if this file is included. $skippedfiles[] = $attachment; - mtrace("---- Skipping attacment. User will be over quota."); + mtrace("---- Skipping attachment. User will be over quota."); continue; } @@ -132,8 +136,9 @@ class private_files_handler extends handler { // File created successfully. mtrace("---- File uploaded successfully as {$record->filename}."); $uploadedfiles[] = $attachment; + $usedspace += $attachment->filesize; } else { - mtrace("---- Skipping attacment. Unknown failure during creation."); + mtrace("---- Skipping attachment. Unknown failure during creation."); $failedfiles[] = $attachment; } }