Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'wip-mdl-30667-m23' of git://github.com/rajeshtaneja/moo…

…dle into MOODLE_23_STABLE
  • Loading branch information...
commit 77ef5e06f9291cc6360223c692102cc60b2a74ec 2 parents cdf30c7 + 2f2242e
@samhemelryk samhemelryk authored
View
5 admin/settings/courses.php
@@ -35,10 +35,11 @@
$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));
View
2  course/edit_form.php
@@ -156,7 +156,7 @@ function definition() {
$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);
View
12 lib/moodlelib.php
@@ -5948,9 +5948,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)) {
@@ -5962,6 +5964,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
Please sign in to comment.
Something went wrong with that request. Please try again.