Permalink
Browse files

MDL-30792 Files API: Cleaner approach to get maxbytes size in filepicker

  • Loading branch information...
1 parent fa7a8a9 commit 64171aac704279f038afa5e04b3558b3a6ec22f3 Rajesh Taneja committed Aug 3, 2012
Showing with 7 additions and 13 deletions.
  1. +3 −3 lib/moodlelib.php
  2. +2 −5 repository/filepicker.php
  3. +2 −5 repository/repository_ajax.php
View
@@ -5739,15 +5739,15 @@ function get_max_upload_file_size($sitebytes=0, $coursebytes=0, $modulebytes=0)
}
}
- if ($sitebytes and $sitebytes < $minimumsize) {
+ if (($sitebytes > 0) and ($sitebytes < $minimumsize)) {
$minimumsize = $sitebytes;
}
- if ($coursebytes and $coursebytes < $minimumsize) {
+ if (($coursebytes > 0) and ($coursebytes < $minimumsize)) {
$minimumsize = $coursebytes;
}
- if ($modulebytes and $modulebytes < $minimumsize) {
+ if (($modulebytes > 0) and ($modulebytes < $minimumsize)) {
$minimumsize = $modulebytes;
}
@@ -93,11 +93,8 @@
}
}
-$moodle_maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes);
-// to prevent maxbytes greater than moodle maxbytes setting
-if (($maxbytes <= 0) || ($maxbytes >= $moodle_maxbytes)) {
- $maxbytes = $moodle_maxbytes;
-}
+// Make sure maxbytes passed is within site filesize limits.
+$maxbytes = get_max_upload_file_size($CFG->maxbytes, $coursemaxbytes, $maxbytes);
$params = array('ctx_id' => $contextid, 'itemid' => $itemid, 'env' => $env, 'course'=>$courseid, 'maxbytes'=>$maxbytes, 'maxfiles'=>$maxfiles, 'subdirs'=>$subdirs, 'sesskey'=>sesskey());
$params['action'] = 'browse';
@@ -87,11 +87,8 @@
if (!empty($course)) {
$coursemaxbytes = $course->maxbytes;
}
-$moodle_maxbytes = get_max_upload_file_size($CFG->maxbytes, $coursemaxbytes);
-// to prevent maxbytes greater than moodle maxbytes setting
-if (($maxbytes <= 0) || ($maxbytes >= $moodle_maxbytes)) {
- $maxbytes = $moodle_maxbytes;
-}
+// Make sure maxbytes passed is within site filesize limits.
+$maxbytes = get_max_upload_file_size($CFG->maxbytes, $coursemaxbytes, $maxbytes);
/// Wait as long as it takes for this script to finish
set_time_limit(0);

0 comments on commit 64171aa

Please sign in to comment.