]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9318 Improving the maxbytes setting.
authorpoltawski <poltawski>
Mon, 16 Apr 2007 15:56:38 +0000 (15:56 +0000)
committerpoltawski <poltawski>
Mon, 16 Apr 2007 15:56:38 +0000 (15:56 +0000)
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.

admin/settings/security.php
lang/en_utf8/admin.php
lib/moodlelib.php

index 6664e2f0909a2bc080ebe07bc0783414dc4e6569..e6c9e76271b6886baa2188e13d7e242a78b2a4a0 100644 (file)
@@ -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));
index 7749a798238e94b5e0a016313188842c507eb8dd..9a7d78b5958127aa4d2006e175c2ac2f95078cc0 100644 (file)
@@ -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';
index 1c9696e1d4878fba943a33351a468c96d4d7ae9e..d5bc8dc5374cbd367f2b3ffe53de4c71cab58e01 100644 (file)
@@ -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);