MDL-27156 repositories: altered filepicker.php so that users with the ability to...
authorAndrew Davis <andrew@moodle.com>
Mon, 18 Jun 2012 04:33:28 +0000 (11:33 +0700)
committerAndrew Davis <andrew@moodle.com>
Wed, 20 Jun 2012 04:27:31 +0000 (11:27 +0700)
lib/form/filepicker.php
lib/moodlelib.php

index bcee75d..a27f015 100644 (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();
                 }
index 6978a42..a2f6309 100644 (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);
 }