From: poltawski Date: Mon, 16 Apr 2007 15:56:38 +0000 (+0000) Subject: MDL-9318 Improving the maxbytes setting. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=59465949fad495fea4c9a46800e70cf0adf95fb5;p=moodle.git MDL-9318 Improving the maxbytes setting. Maxbytes admin is now a dropdown box, and has the option to set as 'server limit'. get_max_uploaded_sizes will now add maxbytes to its list of settings, if its available for selection. --- diff --git a/admin/settings/security.php b/admin/settings/security.php index 6664e2f090..e6c9e76271 100644 --- a/admin/settings/security.php +++ b/admin/settings/security.php @@ -8,7 +8,12 @@ $temp->add(new admin_setting_configcheckbox('protectusernames', get_string('prot $temp->add(new admin_setting_configcheckbox('forcelogin', get_string('forcelogin', 'admin'), get_string('configforcelogin', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('forceloginforprofiles', get_string('forceloginforprofiles', 'admin'), get_string('configforceloginforprofiles', 'admin'), 1)); $temp->add(new admin_setting_configcheckbox('opentogoogle', get_string('opentogoogle', 'admin'), get_string('configopentogoogle', 'admin'), 0)); -$temp->add(new admin_setting_configtext('maxbytes', get_string('maxbytes', 'admin'), get_string('configmaxbytes', 'admin'), 0, PARAM_INT)); + +$max_upload_choices = get_max_upload_sizes(); +// maxbytes set to 0 will allow the maxium server lmit for uploads +$max_upload_choices[0] = get_string('serverlimit', 'admin'); +$temp->add(new admin_setting_configselect('maxbytes', get_string('maxbytes', 'admin'), get_string('configmaxbytes', 'admin'), 0, $max_upload_choices)); + $temp->add(new admin_setting_configcheckbox('messaging', get_string('messaging', 'admin'), get_string('configmessaging','admin'), 1)); $temp->add(new admin_setting_configcheckbox('allowobjectembed', get_string('allowobjectembed', 'admin'), get_string('configallowobjectembed', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('enabletrusttext', get_string('enabletrusttext', 'admin'), get_string('configenabletrusttext', 'admin'), 0)); diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 7749a79823..9a7d78b595 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -127,7 +127,7 @@ $string['configloginhttps'] = 'Turning this on will make Moodle use a secure htt $string['configloglifetime'] = 'This specifies the length of time you want to keep logs about user activity. Logs that are older than this age are automatically deleted. It is best to keep logs as long as possible, in case you need them, but if you have a very busy server and are experiencing performance problems, then you may want to lower the log lifetime.'; $string['configlongtimenosee'] = 'If students haven\'t logged in for a very long time, then they are automatically unsubscribed from courses. This parameter specifies that time limit.'; $string['configlookahead'] = 'Days to Lookahead'; -$string['configmaxbytes'] = 'This specifies a maximum size that uploaded files can be throughout the whole site. This setting is limited by the PHP settings post_max_size and upload_max_filesize, as well as the Apache setting LimitRequestBody. In turn, maxbytes limits the range of sizes that can be chosen at course level or module level.'; +$string['configmaxbytes'] = 'This specifies a maximum size that uploaded files can be throughout the whole site. This setting is limited by the PHP settings post_max_size and upload_max_filesize, as well as the Apache setting LimitRequestBody. In turn, maxbytes limits the range of sizes that can be chosen at course level or module level. If \'Server Limit\' is chosen, the server maxiumum allowed by the server will be used.'; $string['configmaxeditingtime'] = 'This specifies the amount of time people have to re-edit forum postings, glossary comments etc. Usually 30 minutes is a good value.'; $string['configmaxevents'] = 'Events to Lookahead'; $string['configmemcachedhosts'] = 'For memcached. Comma-separated list of hosts that are running the memcached daemon. Use IP addresses to avoid DNS latency. memcached does not behave well if you add/remove hosts on a running setup.'; @@ -493,6 +493,7 @@ $string['searchinsettings'] = 'Search in settings'; $string['secureforms'] = 'Use additional form security'; $string['security'] = 'Security'; $string['server'] = 'Server'; +$string['serverlimit'] = 'Server Limit'; $string['sessioncookie'] = 'Cookie prefix'; $string['sessioncookiepath'] = 'Cookie path'; $string['sessionhandling'] = 'Session Handling'; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 1c9696e1d4..d5bc8dc537 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3838,6 +3838,7 @@ function get_max_upload_file_size($sitebytes=0, $coursebytes=0, $modulebytes=0) * @todo Finish documenting this function */ function get_max_upload_sizes($sitebytes=0, $coursebytes=0, $modulebytes=0) { + global $CFG; if (!$maxsize = get_max_upload_file_size($sitebytes, $coursebytes, $modulebytes)) { return array(); @@ -3848,6 +3849,11 @@ function get_max_upload_sizes($sitebytes=0, $coursebytes=0, $modulebytes=0) { $sizelist = array(10240, 51200, 102400, 512000, 1048576, 2097152, 5242880, 10485760, 20971520, 52428800, 104857600); + // Allow maxbytes to be selected if it falls outside the above boundaries + if( isset($CFG->maxbytes) && !in_array($CFG->maxbytes, $sizelist) ){ + $sizelist[] = $CFG->maxbytes; + } + foreach ($sizelist as $sizebytes) { if ($sizebytes < $maxsize) { $filesize[$sizebytes] = display_size($sizebytes);