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

This commit is contained in:
Rajesh Taneja 2012-08-03 11:20:55 +08:00
parent 7030756a98
commit 960f437972
3 changed files with 9 additions and 13 deletions

View file

@ -78,15 +78,13 @@ $repo = repository::get_repository_by_id($repo_id, $contextid, $repooptions);
// Check permissions
$repo->check_capability();
$coursemaxbytes = 0;
if (!empty($course)) {
$coursemaxbytes = $course->maxbytes;
}
$moodle_maxbytes = get_user_max_upload_file_size($context, $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_user_max_upload_file_size($context, $CFG->maxbytes, $coursemaxbytes, $maxbytes);
// Wait as long as it takes for this script to finish
set_time_limit(0);