MDL-27156 repositories: altered filepicker.php so that users with the ability to ignore course file size restrictions are not incorrectly restricted

This commit is contained in:
Andrew Davis
2012-06-20 11:27:31 +07:00
parent f4a9bf65da
commit bc8da017b5
2 changed files with 12 additions and 5 deletions
+4 -1
View File
@@ -207,7 +207,10 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id DESC', false)) {
$file = array_shift($files);
if ($this->_options['maxbytes'] and $file->get_filesize() > $this->_options['maxbytes']) {
if ($this->_options['maxbytes']
and $this->_options['maxbytes'] !== USER_CAN_IGNORE_FILE_SIZE_LIMITS
and $file->get_filesize() > $this->_options['maxbytes']) {
// bad luck, somebody tries to sneak in oversized file
$file->delete();
}
+8 -4
View File
@@ -473,6 +473,11 @@ define('HUB_MOODLEORGHUBURL', "http://hub.moodle.org");
*/
define('MOODLE_OFFICIAL_MOBILE_SERVICE', 'moodle_mobile_app');
/**
* Indicates the user has the capabilities required to ignore activity and course file size restrictions
*/
define('USER_CAN_IGNORE_FILE_SIZE_LIMITS', -1);
/// PARAMETER HANDLING ////////////////////////////////////////////////////
/**
@@ -5860,10 +5865,9 @@ function get_user_max_upload_file_size($context, $sitebytes=0, $coursebytes=0, $
$user = $USER;
}
// Temp. commenting this until MDL-27156 fixes it!
// if (has_capability('moodle/course:ignorefilesizelimits', $context, $user)) {
// return -1;
// }
if (has_capability('moodle/course:ignorefilesizelimits', $context, $user)) {
return USER_CAN_IGNORE_FILE_SIZE_LIMITS;
}
return get_max_upload_file_size($sitebytes, $coursebytes, $modulebytes);
}