mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-37122 core get_max_upload_sizes: Include "Course/Site/Activity limit (X)" in list of options
This change removes the "0 bytes" option from the get_max_upload_sizes list and replaces it with "Course limit (X)" or "Site limit (X)" (whichever is smaller). This means we can remove all custom handling in the modules that were removing and adding these options. It only affects pages that pass valid options for sitelimit and courselimit - so admin pages will work correctly. It also orders the list so the course/site limit options will be first (as it will be the largest). AMOS START REM [courseuploadlimit, core] has been parameterized to get [uploadlimitwithsize, core] AMOS END
This commit is contained in:
parent
8fd56c1942
commit
6b219310cf
10 changed files with 122 additions and 18 deletions
|
@ -6022,7 +6022,10 @@ function get_user_max_upload_file_size($context, $sitebytes=0, $coursebytes=0, $
|
|||
* array of possible sizes in an array, translated to the
|
||||
* local language.
|
||||
*
|
||||
* @todo Finish documenting this function
|
||||
* The list of options will go up to the minimum of $sitebytes, $coursebytes or $modulebytes.
|
||||
*
|
||||
* If $coursebytes or $sitebytes is not 0, an option will be included for "Course/Site upload limit (X)"
|
||||
* with the value set to 0. This option will be the first in the list.
|
||||
*
|
||||
* @global object
|
||||
* @uses SORT_NUMERIC
|
||||
|
@ -6041,7 +6044,7 @@ function get_max_upload_sizes($sitebytes = 0, $coursebytes = 0, $modulebytes = 0
|
|||
}
|
||||
|
||||
$filesize = array();
|
||||
$filesize[intval($maxsize)] = display_size($maxsize);
|
||||
$filesize[(string)intval($maxsize)] = display_size($maxsize);
|
||||
|
||||
$sizelist = array(10240, 51200, 102400, 512000, 1048576, 2097152,
|
||||
5242880, 10485760, 20971520, 52428800, 104857600);
|
||||
|
@ -6063,12 +6066,31 @@ function get_max_upload_sizes($sitebytes = 0, $coursebytes = 0, $modulebytes = 0
|
|||
}
|
||||
|
||||
foreach ($sizelist as $sizebytes) {
|
||||
if ($sizebytes < $maxsize) {
|
||||
$filesize[intval($sizebytes)] = display_size($sizebytes);
|
||||
if ($sizebytes < $maxsize && $sizebytes > 0) {
|
||||
$filesize[(string)intval($sizebytes)] = display_size($sizebytes);
|
||||
}
|
||||
}
|
||||
|
||||
krsort($filesize, SORT_NUMERIC);
|
||||
$limitlevel = '';
|
||||
$displaysize = '';
|
||||
if ($modulebytes &&
|
||||
(($modulebytes < $coursebytes || $coursebytes == 0) &&
|
||||
($modulebytes < $sitebytes || $sitebytes == 0))) {
|
||||
$limitlevel = get_string('activity', 'core');
|
||||
$displaysize = display_size($modulebytes);
|
||||
} else if ($coursebytes && ($coursebytes < $sitebytes || $sitebytes == 0)) {
|
||||
$limitlevel = get_string('course', 'core');
|
||||
$displaysize = display_size($coursebytes);
|
||||
} else if ($sitebytes) {
|
||||
$limitlevel = get_string('site', 'core');
|
||||
$displaysize = display_size($sitebytes);
|
||||
}
|
||||
|
||||
if ($limitlevel) {
|
||||
$params = (object) array('contextname'=>$limitlevel, 'displaysize'=>$displaysize);
|
||||
$filesize = array('0'=>get_string('uploadlimitwithsize', 'core', $params)) + $filesize;
|
||||
}
|
||||
|
||||
return $filesize;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue