MDL-35517 course: Handle non-existing $course->maxbytes on course creation.
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 19 Sep 2012 15:24:38 +0000 (17:24 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 20 Sep 2012 08:20:21 +0000 (10:20 +0200)
course/edit_form.php

index 319bdac..20a010e 100644 (file)
@@ -156,7 +156,11 @@ class course_edit_form extends moodleform {
         $mform->addHelpButton('showreports', 'showreports');
         $mform->setDefault('showreports', $courseconfig->showreports);
 
-        $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $course->maxbytes);
+        // Handle non-existing $course->maxbytes on course creation.
+        $coursemaxbytes = !isset($course->maxbytes) ? null : $course->maxbytes;
+
+        // Let's prepare the maxbytes popup.
+        $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $coursemaxbytes);
         $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices);
         $mform->addHelpButton('maxbytes', 'maximumupload');
         $mform->setDefault('maxbytes', $courseconfig->maxbytes);