mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'wip-mdl-30667' of git://github.com/rajeshtaneja/moodle
This commit is contained in:
commit
fd9a54c2e3
@ -35,10 +35,11 @@ if ($hassiteconfig
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'), new lang_string('coursehelpshowgrades'), 1,array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
|
||||
$currentmaxbytes = get_config('moodlecourse', 'maxbytes');
|
||||
if (isset($CFG->maxbytes)) {
|
||||
$choices = get_max_upload_sizes($CFG->maxbytes);
|
||||
$choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $currentmaxbytes);
|
||||
} else {
|
||||
$choices = get_max_upload_sizes();
|
||||
$choices = get_max_upload_sizes(0, 0, 0, $currentmaxbytes);
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'), new lang_string('coursehelpmaximumupload'), key($choices), $choices));
|
||||
|
||||
|
@ -156,7 +156,7 @@ class course_edit_form extends moodleform {
|
||||
$mform->addHelpButton('showreports', 'showreports');
|
||||
$mform->setDefault('showreports', $courseconfig->showreports);
|
||||
|
||||
$choices = get_max_upload_sizes($CFG->maxbytes);
|
||||
$choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $course->maxbytes);
|
||||
$mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices);
|
||||
$mform->addHelpButton('maxbytes', 'maximumupload');
|
||||
$mform->setDefault('maxbytes', $courseconfig->maxbytes);
|
||||
|
@ -5969,9 +5969,11 @@ function get_user_max_upload_file_size($context, $sitebytes=0, $coursebytes=0, $
|
||||
* @param int $sizebytes Set maximum size
|
||||
* @param int $coursebytes Current course $course->maxbytes (in bytes)
|
||||
* @param int $modulebytes Current module ->maxbytes (in bytes)
|
||||
* @param int|array $custombytes custom upload size/s which will be added to list,
|
||||
* Only value/s smaller then maxsize will be added to list.
|
||||
* @return array
|
||||
*/
|
||||
function get_max_upload_sizes($sitebytes=0, $coursebytes=0, $modulebytes=0) {
|
||||
function get_max_upload_sizes($sitebytes = 0, $coursebytes = 0, $modulebytes = 0, $custombytes = null) {
|
||||
global $CFG;
|
||||
|
||||
if (!$maxsize = get_max_upload_file_size($sitebytes, $coursebytes, $modulebytes)) {
|
||||
@ -5983,6 +5985,14 @@ function get_max_upload_sizes($sitebytes=0, $coursebytes=0, $modulebytes=0) {
|
||||
$sizelist = array(10240, 51200, 102400, 512000, 1048576, 2097152,
|
||||
5242880, 10485760, 20971520, 52428800, 104857600);
|
||||
|
||||
// If custombytes is given then add it to the list.
|
||||
if (!is_null($custombytes)) {
|
||||
if (is_number($custombytes)) {
|
||||
$custombytes = array((int)$custombytes);
|
||||
}
|
||||
$sizelist = array_unique(array_merge($sizelist, $custombytes));
|
||||
}
|
||||
|
||||
// Allow maxbytes to be selected if it falls outside the above boundaries
|
||||
if (isset($CFG->maxbytes) && !in_array(get_real_size($CFG->maxbytes), $sizelist)) {
|
||||
// note: get_real_size() is used in order to prevent problems with invalid values
|
||||
|
Loading…
x
Reference in New Issue
Block a user