mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
Merge branch 'w17_MDL-39077_m25_sizes' of git://github.com/skodak/moodle
This commit is contained in:
commit
e0b3f5f235
@ -6194,9 +6194,12 @@ function get_max_upload_sizes($sitebytes = 0, $coursebytes = 0, $modulebytes = 0
|
||||
return array();
|
||||
}
|
||||
|
||||
$filesize = array();
|
||||
$filesize[(string)intval($maxsize)] = display_size($maxsize);
|
||||
if ($sitebytes == 0) {
|
||||
// Will get the minimum of upload_max_filesize or post_max_size.
|
||||
$sitebytes = get_max_upload_file_size();
|
||||
}
|
||||
|
||||
$filesize = array();
|
||||
$sizelist = array(10240, 51200, 102400, 512000, 1048576, 2097152,
|
||||
5242880, 10485760, 20971520, 52428800, 104857600);
|
||||
|
||||
@ -6222,7 +6225,6 @@ function get_max_upload_sizes($sitebytes = 0, $coursebytes = 0, $modulebytes = 0
|
||||
}
|
||||
}
|
||||
|
||||
krsort($filesize, SORT_NUMERIC);
|
||||
$limitlevel = '';
|
||||
$displaysize = '';
|
||||
if ($modulebytes &&
|
||||
@ -6230,14 +6232,20 @@ function get_max_upload_sizes($sitebytes = 0, $coursebytes = 0, $modulebytes = 0
|
||||
($modulebytes < $sitebytes || $sitebytes == 0))) {
|
||||
$limitlevel = get_string('activity', 'core');
|
||||
$displaysize = display_size($modulebytes);
|
||||
$filesize[$modulebytes] = $displaysize; // Make sure the limit is also included in the list.
|
||||
|
||||
} else if ($coursebytes && ($coursebytes < $sitebytes || $sitebytes == 0)) {
|
||||
$limitlevel = get_string('course', 'core');
|
||||
$displaysize = display_size($coursebytes);
|
||||
$filesize[$coursebytes] = $displaysize; // Make sure the limit is also included in the list.
|
||||
|
||||
} else if ($sitebytes) {
|
||||
$limitlevel = get_string('site', 'core');
|
||||
$displaysize = display_size($sitebytes);
|
||||
$filesize[$sitebytes] = $displaysize; // Make sure the limit is also included in the list.
|
||||
}
|
||||
|
||||
krsort($filesize, SORT_NUMERIC);
|
||||
if ($limitlevel) {
|
||||
$params = (object) array('contextname'=>$limitlevel, 'displaysize'=>$displaysize);
|
||||
$filesize = array('0'=>get_string('uploadlimitwithsize', 'core', $params)) + $filesize;
|
||||
|
@ -2427,6 +2427,20 @@ class moodlelib_testcase extends advanced_testcase {
|
||||
$result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes, $custombytes);
|
||||
|
||||
$this->assertEquals(3, count($result));
|
||||
|
||||
// Test site limit only.
|
||||
$sitebytes = 51200;
|
||||
$result = get_max_upload_sizes($sitebytes);
|
||||
|
||||
$this->assertEquals('Site upload limit (50KB)', $result['0']);
|
||||
$this->assertEquals('50KB', $result['51200']);
|
||||
$this->assertEquals('10KB', $result['10240']);
|
||||
$this->assertCount(3, $result);
|
||||
|
||||
// Test no limit.
|
||||
$result = get_max_upload_sizes();
|
||||
$this->assertArrayHasKey('0', $result);
|
||||
$this->assertArrayHasKey(get_max_upload_file_size(), $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user