Permalink
Browse files

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

…dle into MOODLE_22_STABLE
  • Loading branch information...
2 parents 0686d3d + 79d375e commit b7367b9638154dcc3c38c4657a266473fc0532e2 Sam Hemelryk committed Sep 12, 2012
Showing with 15 additions and 4 deletions.
  1. +3 −2 admin/settings/courses.php
  2. +1 −1 course/edit_form.php
  3. +11 −1 lib/moodlelib.php
@@ -35,10 +35,11 @@
$temp->add(new admin_setting_configselect('moodlecourse/showgrades', get_string('showgrades'), get_string('coursehelpshowgrades'), 1,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('moodlecourse/showreports', get_string('showreports'), '', 0,array(0 => get_string('no'), 1 => get_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', get_string('maximumupload'), get_string('coursehelpmaximumupload'), key($choices), $choices));
View
@@ -150,7 +150,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
@@ -5813,9 +5813,11 @@ function get_max_upload_file_size($sitebytes=0, $coursebytes=0, $modulebytes=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)) {
@@ -5827,6 +5829,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

0 comments on commit b7367b9

Please sign in to comment.