$this->definition_after_data();
}
+ /**
+ * Set maximum allowed uploaded file size.
+ * Must be used BEFORE creating of file element!
+ *
+ * @param object $course
+ * @param object $modbytes - max size limit defined in module
+ */
+ function set_max_file_size($course=null, $modbytes=0) {
+ global $CFG, $COURSE;
+
+ if (empty($course->id)) {
+ $course = $COURSE;
+ }
+
+ $maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes, $modbytes);
+ $this->_form->setMaxFileSize($maxbytes);
+ }
+
/**
* Check that form was submitted. Does not check validity of submitted data.
*
// the upload manager is used directly in post precessing, moodleform::save_files() is not used yet
$this->_upload_manager = new upload_manager('attachment', true, false, $course, false, $forum->maxbytes, true, true);
-
- // set file max size to enable proper server side validation
- $maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes, $forum->maxbytes);
- $mform->setMaxFileSize($maxbytes);
+ $this->set_max_file_size($course, $forum->maxbytes);
$mform->addElement('header', 'general', '');//fill in the data depending on page params
//later using set_defaults