本文整理汇总了PHP中get_max_upload_file_size函数的典型用法代码示例。如果您正苦于以下问题:PHP get_max_upload_file_size函数的具体用法?PHP get_max_upload_file_size怎么用?PHP get_max_upload_file_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_max_upload_file_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
public function definition()
{
global $CFG, $OUTPUT, $COURSE;
$accepted_types = '.pdf';
if ($CFG->emarking_enabledigitizedzipfile) {
$accepted_types .= ',.zip';
}
// Options for uploading the zip file within the form.
$options = array('subdirs' => 0, 'maxbytes' => get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes, $COURSE->maxbytes), 'maxfiles' => 1, 'accepted_types' => $accepted_types, 'return_types' => FILE_INTERNAL);
$mform = $this->_form;
$instance = $this->_customdata;
// Header.
$mform->addElement('header', 'digitizedfilepdf', get_string('uploadanswers', 'mod_emarking'));
$mform->addHelpButton('digitizedfilepdf', 'digitizedfile', 'mod_emarking');
// The course module id.
$mform->addElement('hidden', 'id', $instance['coursemoduleid']);
$mform->setType('id', PARAM_INT);
// The activity id.
$mform->addElement('hidden', 'emarkingid', $instance['emarkingid']);
$mform->setType('emarkingid', PARAM_INT);
// File picker for the digitized answers.
$mform->addElement('filepicker', 'assignment_file', get_string('uploadexamfile', 'mod_emarking'), null, $options);
$mform->setType('assignment_file', PARAM_FILE);
$mform->addHelpButton('assignment_file', 'filerequiredpdf', 'mod_emarking');
$mform->addRule('assignment_file', get_string('filerequiredpdf', 'mod_emarking'), 'required');
// Header.
$mform->addElement('static', 'qrprocessing_help', '', $OUTPUT->heading(get_string('usedigitizedzipfile', 'mod_emarking'), 4));
$mform->setAdvanced('qrprocessing_help');
// Link to desktop tool.
$desktoplink = html_writer::link(new moodle_url('/mod/emarking/emarkingdesktop.zip'), get_string('qrprocessing', 'mod_emarking'));
$mform->addElement('static', 'qrprocessing', '', $desktoplink);
$mform->setAdvanced('qrprocessing');
// Action buttons.
$this->add_action_buttons(true, get_string('processtitle', 'mod_emarking'));
}
示例2: definition
function definition()
{
global $USER, $CFG, $COURSE;
$mform =& $this->_form;
$mform->addElement('text', 'name', get_string('groupname', 'group'), 'maxlength="254" size="50"');
$mform->addRule('name', get_string('required'), 'required', null, 'client');
$mform->setType('name', PARAM_MULTILANG);
$mform->addElement('htmleditor', 'description', get_string('groupdescription', 'group'), array('rows' => '15', 'course' => $COURSE->id, 'cols' => '45'));
$mform->setType('description', PARAM_RAW);
$mform->addElement('passwordunmask', 'enrolmentkey', get_string('enrolmentkey', 'group'), 'maxlength="254" size="24"', get_string('enrolmentkey'));
$mform->setHelpButton('enrolmentkey', array('groupenrolmentkey', get_string('enrolmentkey', 'group')), true);
$mform->setType('enrolmentkey', PARAM_RAW);
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes);
if (!empty($CFG->gdversion) and $maxbytes) {
$options = array(get_string('no'), get_string('yes'));
$mform->addElement('select', 'hidepicture', get_string('hidepicture'), $options);
$this->set_upload_manager(new upload_manager('imagefile', false, false, null, false, 0, true, true, false));
$mform->addElement('file', 'imagefile', get_string('newpicture', 'group'));
$mform->setHelpButton('imagefile', array('picture', get_string('helppicture')), true);
}
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'courseid');
$mform->setType('courseid', PARAM_INT);
$this->add_action_buttons();
}
示例3: definition
/**
* Form definition
*/
public function definition()
{
$mform = $this->_form;
$data = (object) $this->_customdata;
$mform->addElement('hidden', 'returnurl');
$mform->setType('returnurl', PARAM_URL);
$mform->addElement('header', 'cohortfileuploadform', get_string('uploadafile'));
$filepickeroptions = array();
$filepickeroptions['filetypes'] = '*';
$filepickeroptions['maxbytes'] = get_max_upload_file_size();
$mform->addElement('filepicker', 'cohortfile', get_string('file'), null, $filepickeroptions);
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter', get_string('csvdelimiter', 'tool_uploadcourse'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter', 'cfg');
} else {
if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter', 'semicolon');
} else {
$mform->setDefault('delimiter', 'comma');
}
}
$mform->addHelpButton('delimiter', 'csvdelimiter', 'tool_uploadcourse');
$choices = core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploadcourse'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$mform->addHelpButton('encoding', 'encoding', 'tool_uploadcourse');
$options = $this->get_context_options();
$mform->addElement('select', 'contextid', get_string('defaultcontext', 'cohort'), $options);
$this->add_cohort_upload_buttons(true);
$this->set_data($data);
}
示例4: definition
/**
* Called from Moodle to define this form
*
* @return void
*/
function definition()
{
global $CFG;
$mform =& $this->_form;
/*$stringman = get_string_manager();
$ejsapp_strings = $stringman->load_component_strings('ejsapp', current_language());*/
// Adding atto_ejsapp settings by adding more fieldsets
$mform->addElement('header', 'conf_parameters', get_string('jar_file', 'ejsapp'));
$mform->addElement('hidden', 'class_file', null);
$mform->setType('class_file', PARAM_TEXT);
$mform->setDefault('class_file', 'null');
$mform->addElement('hidden', 'codebase', null);
$mform->setType('codebase', PARAM_TEXT);
$mform->setDefault('codebase', 'null');
$mform->addElement('hidden', 'mainframe', null);
$mform->setType('mainframe', PARAM_TEXT);
$mform->setDefault('mainframe', 'null');
$mform->addElement('hidden', 'is_collaborative', null);
$mform->setType('is_collaborative', PARAM_TEXT);
$mform->setDefault('is_collaborative', 0);
$mform->addElement('hidden', 'manifest', null);
$mform->setType('manifest', PARAM_TEXT);
$mform->setDefault('manifest', '');
$mform->addElement('hidden', 'applet_name', null);
$mform->setType('applet_name', PARAM_TEXT);
$mform->setDefault('applet_name', '');
$maxbytes = get_max_upload_file_size($CFG->maxbytes);
$mform->addElement('filemanager', 'appletfile', get_string('file'), null, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1, 'accepted_types' => array('application/java-archive', 'application/zip')));
$mform->addRule('appletfile', get_string('appletfile_required', 'ejsapp'), 'required');
$mform->addHelpButton('appletfile', 'appletfile', 'ejsapp');
$mform->addElement('header', 'size_header', get_string('size_header', 'atto_ejsapp'));
$mform->setExpanded('size_header', false);
$mform->addElement('select', 'applet_size_conf', get_string('applet_size_conf', 'ejsapp'), array(get_string('preserve_applet_size', 'ejsapp'), get_string('moodle_resize', 'ejsapp'), get_string('user_resize', 'ejsapp')));
$mform->addHelpButton('applet_size_conf', 'applet_size_conf', 'ejsapp');
$mform->addElement('selectyesno', 'preserve_aspect_ratio', get_string('preserve_aspect_ratio', 'ejsapp'));
$mform->addHelpButton('preserve_aspect_ratio', 'preserve_aspect_ratio', 'ejsapp');
$mform->disabledIf('preserve_aspect_ratio', 'applet_size_conf', 'neq', 2);
$mform->addElement('text', 'custom_width', get_string('custom_width', 'ejsapp'), array('size' => '3'));
$mform->setType('custom_width', PARAM_INT);
$mform->disabledIf('custom_width', 'applet_size_conf', 'neq', 2);
$mform->addElement('text', 'custom_height', get_string('custom_height', 'ejsapp'), array('size' => '3'));
$mform->setType('custom_height', PARAM_INT);
$mform->disabledIf('custom_height', 'applet_size_conf', 'neq', 2);
$mform->disabledIf('custom_height', 'preserve_aspect_ratio', 'eq', 1);
$mform->addElement('header', 'state_file', get_string('state_file', 'ejsapp'));
$mform->setExpanded('state_file', false);
$mform->addElement('filemanager', 'statefile', get_string('file'), null, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1, 'accepted_types' => array('application/xml', 'application/json')));
$mform->addHelpButton('statefile', 'statefile', 'ejsapp');
$mform->addElement('header', 'controller_file', get_string('controller_file', 'ejsapp'));
$mform->setExpanded('controller_file', false);
$mform->addElement('filemanager', 'controllerfile', get_string('file'), null, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1, 'accepted_types' => '.cnt'));
$mform->addHelpButton('controllerfile', 'controllerfile', 'ejsapp');
$mform->addElement('header', 'recording_file', get_string('recording_file', 'ejsapp'));
$mform->setExpanded('recording_file', false);
$mform->addElement('filemanager', 'recordingfile', get_string('file'), null, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1, 'accepted_types' => '.rec'));
$mform->addHelpButton('recordingfile', 'recordingfile', 'ejsapp');
$this->add_action_buttons();
}
示例5: MoodleQuickForm_filepicker
function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attributes=null, $options=null) {
global $CFG;
$options = (array)$options;
foreach ($options as $name=>$value) {
if (array_key_exists($name, $this->_options)) {
$this->_options[$name] = $value;
}
}
if (!empty($options['maxbytes'])) {
$this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']);
}
parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
}
示例6: definition
/**
* Form definition
*/
function definition()
{
$mform =& $this->_form;
$data = $this->_customdata;
//fill in the data depending on page params
//later using set_data
$mform->addElement('header', 'general');
$filepickeroptions = array();
$filepickeroptions['filetypes'] = '*';
$filepickeroptions['maxbytes'] = get_max_upload_file_size();
$mform->addElement('filepicker', 'userfile', get_string('import'), null, $filepickeroptions);
$mform->addElement('hidden', 'id');
$this->add_action_buttons(true, get_string('importgroups', 'core_group'));
$this->set_data($data);
}
示例7: saveSimulationFilesToDraft
/**
* Saves the simulation file into the draft area
* @return boolean
*/
public function saveSimulationFilesToDraft($CFG, $context, $draftitemid_applet)
{
$result = false;
$this->maxbytes = get_max_upload_file_size($CFG->maxbytes);
//Obtains the folder number to store the file
while (file_exists($this->folderpath . $this->incremental)) {
$this->incremental++;
}
//Saves the file in draft area
if ($draftitemid_applet) {
file_save_draft_area_files($draftitemid_applet, $context->id, 'atto_ejsapp', 'jarfiles', $this->incremental, array('subdirs' => 0, 'maxbytes' => $this->maxbytes, 'maxfiles' => 1, 'accepted_types' => array('application/java-archive', 'application/zip')));
$result = true;
}
return $result;
}
示例8: upload_manager
/**
* Constructor, sets up configuration stuff so we know how to act.
*
* Note: destination not taken as parameter as some modules want to use the insertid in the path and we need to check the other stuff first.
*
* @uses $CFG
* @param string $inputname If this is given the upload manager will only process the file in $_FILES with this name.
* @param boolean $deleteothers Whether to delete other files in the destination directory (optional, defaults to false)
* @param boolean $handlecollisions Whether to use {@link handle_filename_collision()} or not. (optional, defaults to false)
* @param boolean $recoverifmultiple If we come across a virus, or if a file doesn't validate or whatever, do we continue? optional, defaults to true.
* @param int $maxbytes max bytes for this file {@link get_max_upload_file_size()}.
* @param boolean $silent Whether to notify errors or not.
* @param boolean $allownull Whether we care if there's no file when we've set the input name.
* @param boolean $allownullmultiple Whether we care if there's no files AT ALL when we've got multiples. This won't complain if we have file 1 and file 3 but not file 2, only for NO FILES AT ALL.
*/
function upload_manager($inputname = '', $deleteothers = false, $handlecollisions = false, $recoverifmultiple = false, $maxbytes = 0, $silent = false, $allownull = false, $allownullmultiple = true)
{
global $CFG;
$this->config->deleteothers = $deleteothers;
$this->config->handlecollisions = $handlecollisions;
$this->config->recoverifmultiple = $recoverifmultiple;
$this->config->maxbytes = get_max_upload_file_size($maxbytes);
$this->config->silent = $silent;
$this->config->allownull = $allownull;
$this->files = array();
$this->status = false;
$this->inputname = $inputname;
if (empty($this->inputname)) {
$this->config->allownull = $allownullmultiple;
}
}
示例9: get_content
function get_content()
{
global $PAGE, $CFG, $OUTPUT, $COURSE;
if ($this->content !== NULL) {
return $this->content;
}
if (!$PAGE->user_is_editing()) {
return NULL;
}
$this->content = new stdClass();
$this->content->footer = null;
$this->content->text = '<div id="dndupload-status"><noscript>' . get_string('noscript', 'block_dndupload') . '</noscript></div>';
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
if (!has_capability('moodle/course:managefiles', $context)) {
$this->content->text = '<div id="dndupload-status">' . get_string('nopermission', 'block_dndupload') . '</div>';
return $this->content;
}
$jsmodule = array('name' => 'block_dndupload', 'fullpath' => new moodle_url('/blocks/dndupload/dndupload.js'), 'strings' => array(array('addhere', 'block_dndupload'), array('addlinkhere', 'block_dndupload'), array('addwebpagehere', 'block_dndupload'), array('dndworking', 'block_dndupload'), array('filetoolarge', 'block_dndupload'), array('nameforlink', 'block_dndupload'), array('nameforwebpage', 'block_dndupload'), array('nofilereader', 'block_dndupload'), array('noajax', 'block_dndupload')));
$vars = array(sesskey(), $CFG->wwwroot . '/blocks/dndupload', $COURSE->id, $OUTPUT->pix_url('i/ajaxloader') . '', get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes), $OUTPUT->pix_url('t/addfile') . '');
$PAGE->requires->js_init_call('M.blocks_dndupload.init', $vars, true, $jsmodule);
return $this->content;
}
示例10: upload_manager
/**
* Constructor, sets up configuration stuff so we know how to act.
*
* Note: destination not taken as parameter as some modules want to use the insertid in the path and we need to check the other stuff first.
*
* @uses $CFG
* @param string $inputname If this is given the upload manager will only process the file in $_FILES with this name.
* @param boolean $deleteothers Whether to delete other files in the destination directory (optional, defaults to false)
* @param boolean $handlecollisions Whether to use {@link handle_filename_collision()} or not. (optional, defaults to false)
* @param course $course The course the files are being uploaded for (for logging and virus notifications) {@link $COURSE}
* @param boolean $recoverifmultiple If we come across a virus, or if a file doesn't validate or whatever, do we continue? optional, defaults to true.
* @param int $modbytes Max bytes for this module - this and $course->maxbytes are used to get the maxbytes from {@link get_max_upload_file_size()}.
* @param boolean $silent Whether to notify errors or not.
* @param boolean $allownull Whether we care if there's no file when we've set the input name.
* @param boolean $allownullmultiple Whether we care if there's no files AT ALL when we've got multiples. This won't complain if we have file 1 and file 3 but not file 2, only for NO FILES AT ALL.
*/
function upload_manager($inputname = '', $deleteothers = false, $handlecollisions = false, $course = null, $recoverifmultiple = false, $modbytes = 0, $silent = false, $allownull = false, $allownullmultiple = true)
{
global $CFG, $SITE;
if (empty($course->id)) {
$course = $SITE;
}
$this->config = new stdClass();
// instantiate $this->config explicitely
$this->config->deleteothers = $deleteothers;
$this->config->handlecollisions = $handlecollisions;
$this->config->recoverifmultiple = $recoverifmultiple;
$this->config->maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes, $modbytes);
$this->config->silent = $silent;
$this->config->allownull = $allownull;
$this->files = array();
$this->status = false;
$this->course = $course;
$this->inputname = $inputname;
if (empty($this->inputname)) {
$this->config->allownull = $allownullmultiple;
}
}
示例11: MoodleQuickForm_filepicker
/**
* Constructor
*
* @param string $elementName (optional) name of the filepicker
* @param string $elementLabel (optional) filepicker label
* @param array $attributes (optional) Either a typical HTML attribute string
* or an associative array
* @param array $options set of options to initalize filepicker
*/
function MoodleQuickForm_filepicker($elementName = null, $elementLabel = null, $attributes = null, $options = null)
{
global $CFG, $PAGE;
$options = (array) $options;
foreach ($options as $name => $value) {
if (array_key_exists($name, $this->_options)) {
$this->_options[$name] = $value;
}
}
if (empty($options['return_types'])) {
$this->_options['return_types'] = FILE_INTERNAL;
}
$fpmaxbytes = 0;
if (!empty($options['maxbytes'])) {
$fpmaxbytes = $options['maxbytes'];
}
$coursemaxbytes = 0;
if (!empty($PAGE->course)) {
$coursemaxbytes = $PAGE->course->maxbytes;
}
$this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $coursemaxbytes, $fpmaxbytes);
$this->_type = 'filepicker';
parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
}
示例12: require_once
if ($repository = $DB->get_record_sql($sql, array($repo_id))) {
$type = $repository->type;
if (file_exists($CFG->dirroot.'/repository/'.$type.'/lib.php')) {
require_once($CFG->dirroot.'/repository/'.$type.'/lib.php');
$classname = 'repository_' . $type;
try {
$repo = new $classname($repo_id, $contextid, array('ajax'=>false, 'name'=>$repository->name, 'type'=>$type));
} catch (repository_exception $e){
print_error('pluginerror', 'repository');
}
} else {
print_error('invalidplugin', 'repository');
}
}
$moodle_maxbytes = get_max_upload_file_size();
// to prevent maxbytes greater than moodle maxbytes setting
if ($maxbytes == 0 || $maxbytes>=$moodle_maxbytes) {
$maxbytes = $moodle_maxbytes;
}
$params = array('ctx_id' => $contextid, 'itemid' => $itemid, 'env' => $env, 'course'=>$courseid, 'maxbytes'=>$maxbytes, 'maxfiles'=>$maxfiles, 'subdirs'=>$subdirs, 'sesskey'=>sesskey());
$params['action'] = 'browse';
$params['draftpath'] = $draftpath;
$home_url = new moodle_url('/repository/draftfiles_manager.php', $params);
$params['savepath'] = $savepath;
$params['repo_id'] = $repo_id;
$url = new moodle_url($CFG->httpswwwroot."/repository/filepicker.php", $params);
$PAGE->set_url('/repository/filepicker.php', $params);
示例13: moodle_exception
throw new moodle_exception('upload_error_no_tmp_dir', 'repository_upload');
break;
case UPLOAD_ERR_CANT_WRITE:
throw new moodle_exception('upload_error_cant_write', 'repository_upload');
break;
case UPLOAD_ERR_EXTENSION:
throw new moodle_exception('upload_error_extension', 'repository_upload');
break;
default:
throw new moodle_exception('nofile');
}
}
$file = new stdClass();
$file->filename = clean_param($_FILES[$fieldname]['name'], PARAM_FILE);
// check system maxbytes setting
if (($_FILES[$fieldname]['size'] > get_max_upload_file_size($CFG->maxbytes))) {
// oversize file will be ignored, error added to array to notify
// web service client
$file->errortype = 'fileoversized';
$file->error = get_string('maxbytes', 'error');
} else {
$file->filepath = $_FILES[$fieldname]['tmp_name'];
// calculate total size of upload
$totalsize += $_FILES[$fieldname]['size'];
}
$files[] = $file;
}
$fs = get_file_storage();
$usedspace = 0;
示例14: unset
$return = $SESSION->returnpage;
unset($SESSION->returnpage);
redirect($return);
} else {
redirect(new moodle_url('/mod/referentiel/activite.php', array('id' => $cm->id, 'userid' => $userid, 'activite_id' => $activite_id, 'mailnow' => $mailnow, 'mode' => 'listactivityall', 'filtre_auteur' => $data_filtre->filtre_auteur, 'filtre_validation' => $data_filtre->filtre_validation, 'filtre_referent' => $data_filtre->filtre_referent, 'filtre_date_modif' => $data_filtre->filtre_date_modif, 'filtre_date_modif_student' => $data_filtre->filtre_date_modif_student)));
}
}
$PAGE->set_url($url);
$PAGE->set_context($context);
$title = strip_tags($course->fullname . ': ' . get_string('modulename', 'referentiel') . ': ' . format_string($referentiel->name, true));
$PAGE->set_title($title);
$PAGE->set_heading($title);
// DEBUG
// echo "<br />upload_Mooddle2.php :: 151 :: activite_id:: $activite_id\n";
// exit;
$options = array('subdirs' => 0, 'maxbytes' => get_max_upload_file_size($CFG->maxbytes, $course->maxbytes, $maxbytes), 'maxfiles' => 1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL);
$mform = new mod_referentiel_upload_form(null, array('d' => $referentiel->id, 'contextid' => $context->id, 'userid' => $USER->id, 'activiteid' => $activite_id, 'filearea' => 'document', 'msg' => get_string('document_associe', 'referentiel'), 'mailnow' => $mailnow, 'options' => $options));
if ($mform->is_cancelled()) {
redirect(new moodle_url('/mod/referentiel/activite.php', array('id' => $cm->id, 'userid' => $USER->id, 'activite_id' => $activite_id, 'mailnow' => $mailnow, 'mode' => 'listactivityall', 'filtre_auteur' => $data_filtre->filtre_auteur, 'filtre_validation' => $data_filtre->filtre_validation, 'filtre_referent' => $data_filtre->filtre_referent, 'filtre_date_modif' => $data_filtre->filtre_date_modif, 'filtre_date_modif_student' => $data_filtre->filtre_date_modif_student)));
} else {
if ($mform->get_data()) {
// A TERMINER
referentiel_upload_document($mform, $referentiel->id);
die;
// redirect(new moodle_url('/mod/referentiel/view.php', array('id'=>$cm->id)));
}
}
echo $OUTPUT->header();
echo $OUTPUT->box_start('generalbox');
$mform->display();
echo $OUTPUT->box_end();
示例15: test_get_max_upload_sizes
public function test_get_max_upload_sizes()
{
// Test with very low limits so we are not affected by php upload limits.
// Test activity limit smallest.
$sitebytes = 102400;
$coursebytes = 51200;
$modulebytes = 10240;
$result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes);
$this->assertSame('Activity upload limit (10KB)', $result['0']);
$this->assertCount(2, $result);
// Test course limit smallest.
$sitebytes = 102400;
$coursebytes = 10240;
$modulebytes = 51200;
$result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes);
$this->assertSame('Course upload limit (10KB)', $result['0']);
$this->assertCount(2, $result);
// Test site limit smallest.
$sitebytes = 10240;
$coursebytes = 102400;
$modulebytes = 51200;
$result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes);
$this->assertSame('Site upload limit (10KB)', $result['0']);
$this->assertCount(2, $result);
// Test site limit not set.
$sitebytes = 0;
$coursebytes = 102400;
$modulebytes = 51200;
$result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes);
$this->assertSame('Activity upload limit (50KB)', $result['0']);
$this->assertCount(3, $result);
$sitebytes = 0;
$coursebytes = 51200;
$modulebytes = 102400;
$result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes);
$this->assertSame('Course upload limit (50KB)', $result['0']);
$this->assertCount(3, $result);
// Test custom bytes in range.
$sitebytes = 102400;
$coursebytes = 51200;
$modulebytes = 51200;
$custombytes = 10240;
$result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes, $custombytes);
$this->assertCount(3, $result);
// Test custom bytes in range but non-standard.
$sitebytes = 102400;
$coursebytes = 51200;
$modulebytes = 51200;
$custombytes = 25600;
$result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes, $custombytes);
$this->assertCount(4, $result);
// Test custom bytes out of range.
$sitebytes = 102400;
$coursebytes = 51200;
$modulebytes = 51200;
$custombytes = 102400;
$result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes, $custombytes);
$this->assertCount(3, $result);
// Test custom bytes out of range and non-standard.
$sitebytes = 102400;
$coursebytes = 51200;
$modulebytes = 51200;
$custombytes = 256000;
$result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes, $custombytes);
$this->assertCount(3, $result);
// Test site limit only.
$sitebytes = 51200;
$result = get_max_upload_sizes($sitebytes);
$this->assertSame('Site upload limit (50KB)', $result['0']);
$this->assertSame('50KB', $result['51200']);
$this->assertSame('10KB', $result['10240']);
$this->assertCount(3, $result);
// Test no limit.
$result = get_max_upload_sizes();
$this->assertArrayHasKey('0', $result);
$this->assertArrayHasKey(get_max_upload_file_size(), $result);
}