Merge branch 'master_MDL-44712' of git://github.com/danmarsden/moodle
[moodle.git] / admin / settings / server.php
1 <?php
3 // This file defines settingpages and externalpages under the "server" category
5 if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
8 // "systempaths" settingpage
9 $temp = new admin_settingpage('systempaths', new lang_string('systempaths','admin'));
11 $temp->add(new admin_setting_configexecutable('pathtodu', new lang_string('pathtodu', 'admin'), new lang_string('configpathtodu', 'admin'), ''));
12 $temp->add(new admin_setting_configexecutable('aspellpath', new lang_string('aspellpath', 'admin'), new lang_string('edhelpaspellpath'), ''));
13 $temp->add(new admin_setting_configexecutable('pathtodot', new lang_string('pathtodot', 'admin'), new lang_string('pathtodot_help', 'admin'), ''));
14 $temp->add(new admin_setting_configexecutable('pathtogs', new lang_string('pathtogs', 'admin'), new lang_string('pathtogs_help', 'admin'), '/usr/bin/gs'));
15 $temp->add(new admin_setting_configexecutable('pathtounoconv', new lang_string('pathtounoconv', 'admin'), new lang_string('pathtounoconv_help', 'admin'), '/usr/bin/unoconv'));
16 $ADMIN->add('server', $temp);
20 // "supportcontact" settingpage
21 $temp = new admin_settingpage('supportcontact', new lang_string('supportcontact','admin'));
22 $primaryadmin = get_admin();
23 if ($primaryadmin) {
24     $primaryadminemail = $primaryadmin->email;
25     $primaryadminname  = fullname($primaryadmin, true);
26 } else {
27     // no defaults during installation - admin user must be created first
28     $primaryadminemail = NULL;
29     $primaryadminname  = NULL;
30 }
31 $temp->add(new admin_setting_configtext('supportname', new lang_string('supportname', 'admin'), new lang_string('configsupportname', 'admin'), $primaryadminname, PARAM_NOTAGS));
32 $temp->add(new admin_setting_configtext('supportemail', new lang_string('supportemail', 'admin'), new lang_string('configsupportemail', 'admin'), $primaryadminemail, PARAM_NOTAGS));
33 $temp->add(new admin_setting_configtext('supportpage', new lang_string('supportpage', 'admin'), new lang_string('configsupportpage', 'admin'), '', PARAM_URL));
34 $ADMIN->add('server', $temp);
37 // "sessionhandling" settingpage
38 $temp = new admin_settingpage('sessionhandling', new lang_string('sessionhandling', 'admin'));
39 if (empty($CFG->session_handler_class) and $DB->session_lock_supported()) {
40     $temp->add(new admin_setting_configcheckbox('dbsessions', new lang_string('dbsessions', 'admin'), new lang_string('configdbsessions', 'admin'), 0));
41 }
42 $temp->add(new admin_setting_configselect('sessiontimeout', new lang_string('sessiontimeout', 'admin'), new lang_string('configsessiontimeout', 'admin'), 7200, array(14400 => new lang_string('numhours', '', 4),
43                                                                                                                                                       10800 => new lang_string('numhours', '', 3),
44                                                                                                                                                       7200 => new lang_string('numhours', '', 2),
45                                                                                                                                                       5400 => new lang_string('numhours', '', '1.5'),
46                                                                                                                                                       3600 => new lang_string('numminutes', '', 60),
47                                                                                                                                                       2700 => new lang_string('numminutes', '', 45),
48                                                                                                                                                       1800 => new lang_string('numminutes', '', 30),
49                                                                                                                                                       900 => new lang_string('numminutes', '', 15),
50                                                                                                                                                       300 => new lang_string('numminutes', '', 5))));
51 $temp->add(new admin_setting_configtext('sessioncookie', new lang_string('sessioncookie', 'admin'), new lang_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
52 $temp->add(new admin_setting_configtext('sessioncookiepath', new lang_string('sessioncookiepath', 'admin'), new lang_string('configsessioncookiepath', 'admin'), '', PARAM_RAW));
53 $temp->add(new admin_setting_configtext('sessioncookiedomain', new lang_string('sessioncookiedomain', 'admin'), new lang_string('configsessioncookiedomain', 'admin'), '', PARAM_RAW, 50));
54 $ADMIN->add('server', $temp);
57 // "stats" settingpage
58 $temp = new admin_settingpage('stats', new lang_string('stats'), 'moodle/site:config', empty($CFG->enablestats));
59 $temp->add(new admin_setting_configselect('statsfirstrun', new lang_string('statsfirstrun', 'admin'), new lang_string('configstatsfirstrun', 'admin'), 'none', array('none' => new lang_string('none'),
60                                                                                                                                                            60*60*24*7 => new lang_string('numweeks','moodle',1),
61                                                                                                                                                            60*60*24*14 => new lang_string('numweeks','moodle',2),
62                                                                                                                                                            60*60*24*21 => new lang_string('numweeks','moodle',3),
63                                                                                                                                                            60*60*24*28 => new lang_string('nummonths','moodle',1),
64                                                                                                                                                            60*60*24*56 => new lang_string('nummonths','moodle',2),
65                                                                                                                                                            60*60*24*84 => new lang_string('nummonths','moodle',3),
66                                                                                                                                                            60*60*24*112 => new lang_string('nummonths','moodle',4),
67                                                                                                                                                            60*60*24*140 => new lang_string('nummonths','moodle',5),
68                                                                                                                                                            60*60*24*168 => new lang_string('nummonths','moodle',6),
69                                                                                                                                                            'all' => new lang_string('all') )));
70 $temp->add(new admin_setting_configselect('statsmaxruntime', new lang_string('statsmaxruntime', 'admin'), new lang_string('configstatsmaxruntime3', 'admin'), 0, array(0 => new lang_string('untilcomplete'),
71                                                                                                                                                             60*30 => '10 '.new lang_string('minutes'),
72                                                                                                                                                             60*30 => '30 '.new lang_string('minutes'),
73                                                                                                                                                             60*60 => '1 '.new lang_string('hour'),
74                                                                                                                                                             60*60*2 => '2 '.new lang_string('hours'),
75                                                                                                                                                             60*60*3 => '3 '.new lang_string('hours'),
76                                                                                                                                                             60*60*4 => '4 '.new lang_string('hours'),
77                                                                                                                                                             60*60*5 => '5 '.new lang_string('hours'),
78                                                                                                                                                             60*60*6 => '6 '.new lang_string('hours'),
79                                                                                                                                                             60*60*7 => '7 '.new lang_string('hours'),
80                                                                                                                                                             60*60*8 => '8 '.new lang_string('hours') )));
81 $temp->add(new admin_setting_configtext('statsruntimedays', new lang_string('statsruntimedays', 'admin'), new lang_string('configstatsruntimedays', 'admin'), 31, PARAM_INT));
82 $temp->add(new admin_setting_configtext('statsuserthreshold', new lang_string('statsuserthreshold', 'admin'), new lang_string('configstatsuserthreshold', 'admin'), 0, PARAM_INT));
83 $ADMIN->add('server', $temp);
86 // "http" settingpage
87 $temp = new admin_settingpage('http', new lang_string('http', 'admin'));
88 $temp->add(new admin_setting_configcheckbox('slasharguments', new lang_string('slasharguments', 'admin'), new lang_string('configslasharguments', 'admin'), 1));
89 $temp->add(new admin_setting_heading('reverseproxy', new lang_string('reverseproxy', 'admin'), '', ''));
90 $options = array(
91     0 => 'HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
92     GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
93     GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
94     GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR|GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR');
95 $temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'), new lang_string('configgetremoteaddrconf', 'admin'), 0, $options));
97 $temp->add(new admin_setting_heading('webproxy', new lang_string('webproxy', 'admin'), new lang_string('webproxyinfo', 'admin')));
98 $temp->add(new admin_setting_configtext('proxyhost', new lang_string('proxyhost', 'admin'), new lang_string('configproxyhost', 'admin'), '', PARAM_HOST));
99 $temp->add(new admin_setting_configtext('proxyport', new lang_string('proxyport', 'admin'), new lang_string('configproxyport', 'admin'), 0, PARAM_INT));
100 $options = array('HTTP'=>'HTTP');
101 if (defined('CURLPROXY_SOCKS5')) {
102     $options['SOCKS5'] = 'SOCKS5';
104 $temp->add(new admin_setting_configselect('proxytype', new lang_string('proxytype', 'admin'), new lang_string('configproxytype','admin'), 'HTTP', $options));
105 $temp->add(new admin_setting_configtext('proxyuser', new lang_string('proxyuser', 'admin'), new lang_string('configproxyuser', 'admin'), ''));
106 $temp->add(new admin_setting_configpasswordunmask('proxypassword', new lang_string('proxypassword', 'admin'), new lang_string('configproxypassword', 'admin'), ''));
107 $temp->add(new admin_setting_configtext('proxybypass', new lang_string('proxybypass', 'admin'), new lang_string('configproxybypass', 'admin'), 'localhost, 127.0.0.1'));
108 $ADMIN->add('server', $temp);
110 $temp = new admin_settingpage('maintenancemode', new lang_string('sitemaintenancemode', 'admin'));
111 $options = array(0=>new lang_string('disable'), 1=>new lang_string('enable'));
112 $temp->add(new admin_setting_configselect('maintenance_enabled', new lang_string('sitemaintenancemode', 'admin'),
113                                           new lang_string('helpsitemaintenance', 'admin'), 0, $options));
114 $temp->add(new admin_setting_confightmleditor('maintenance_message', new lang_string('optionalmaintenancemessage', 'admin'),
115                                               '', ''));
116 $ADMIN->add('server', $temp);
118 $temp = new admin_settingpage('cleanup', new lang_string('cleanup', 'admin'));
119 $temp->add(new admin_setting_configselect('deleteunconfirmed', new lang_string('deleteunconfirmed', 'admin'), new lang_string('configdeleteunconfirmed', 'admin'), 168, array(0 => new lang_string('never'),
120                                                                                                                                                                     168 => new lang_string('numdays', '', 7),
121                                                                                                                                                                     144 => new lang_string('numdays', '', 6),
122                                                                                                                                                                     120 => new lang_string('numdays', '', 5),
123                                                                                                                                                                     96 => new lang_string('numdays', '', 4),
124                                                                                                                                                                     72 => new lang_string('numdays', '', 3),
125                                                                                                                                                                     48 => new lang_string('numdays', '', 2),
126                                                                                                                                                                     24 => new lang_string('numdays', '', 1),
127                                                                                                                                                                     12 => new lang_string('numhours', '', 12),
128                                                                                                                                                                     6 => new lang_string('numhours', '', 6),
129                                                                                                                                                                     1 => new lang_string('numhours', '', 1))));
131 $temp->add(new admin_setting_configselect('deleteincompleteusers', new lang_string('deleteincompleteusers', 'admin'), new lang_string('configdeleteincompleteusers', 'admin'), 0, array(0 => new lang_string('never'),
132                                                                                                                                                                     168 => new lang_string('numdays', '', 7),
133                                                                                                                                                                     144 => new lang_string('numdays', '', 6),
134                                                                                                                                                                     120 => new lang_string('numdays', '', 5),
135                                                                                                                                                                     96 => new lang_string('numdays', '', 4),
136                                                                                                                                                                     72 => new lang_string('numdays', '', 3),
137                                                                                                                                                                     48 => new lang_string('numdays', '', 2),
138                                                                                                                                                                     24 => new lang_string('numdays', '', 1))));
141 $temp->add(new admin_setting_configcheckbox('disablegradehistory', new lang_string('disablegradehistory', 'grades'),
142                                             new lang_string('disablegradehistory_help', 'grades'), 0));
144 $temp->add(new admin_setting_configselect('gradehistorylifetime', new lang_string('gradehistorylifetime', 'grades'),
145                                           new lang_string('gradehistorylifetime_help', 'grades'), 0, array(0 => new lang_string('neverdeletehistory', 'grades'),
146                                                                                                    1000 => new lang_string('numdays', '', 1000),
147                                                                                                     365 => new lang_string('numdays', '', 365),
148                                                                                                     180 => new lang_string('numdays', '', 180),
149                                                                                                     150 => new lang_string('numdays', '', 150),
150                                                                                                     120 => new lang_string('numdays', '', 120),
151                                                                                                      90 => new lang_string('numdays', '', 90),
152                                                                                                      60 => new lang_string('numdays', '', 60),
153                                                                                                      30 => new lang_string('numdays', '', 30))));
155 $temp->add(new admin_setting_configselect('tempdatafoldercleanup', new lang_string('tempdatafoldercleanup', 'admin'),
156         new lang_string('configtempdatafoldercleanup', 'admin'), 168, array(
157             1 => new lang_string('numhours', '', 1),
158             3 => new lang_string('numhours', '', 3),
159             6 => new lang_string('numhours', '', 6),
160             9 => new lang_string('numhours', '', 9),
161             12 => new lang_string('numhours', '', 12),
162             18 => new lang_string('numhours', '', 18),
163             24 => new lang_string('numhours', '', 24),
164             48 => new lang_string('numdays', '', 2),
165             168 => new lang_string('numdays', '', 7),
166 )));
168 $ADMIN->add('server', $temp);
172 $ADMIN->add('server', new admin_externalpage('environment', new lang_string('environment','admin'), "$CFG->wwwroot/$CFG->admin/environment.php"));
173 $ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo'), "$CFG->wwwroot/$CFG->admin/phpinfo.php"));
176 // "performance" settingpage
177 $temp = new admin_settingpage('performance', new lang_string('performance', 'admin'));
179 // Memory limit options for large administration tasks.
180 $memoryoptions = array(
181     '64M' => '64M',
182     '128M' => '128M',
183     '256M' => '256M',
184     '512M' => '512M',
185     '1024M' => '1024M',
186     '2048M' => '2048M');
188 // Allow larger memory usage for 64-bit sites only.
189 if (PHP_INT_SIZE === 8) {
190     $memoryoptions['3072M'] = '3072M';
191     $memoryoptions['4096M'] = '4096M';
194 $temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'),
195                                           new lang_string('configextramemorylimit', 'admin'), '512M',
196                                           $memoryoptions));
197 $temp->add(new admin_setting_configtext('maxtimelimit', new lang_string('maxtimelimit', 'admin'),
198         new lang_string('maxtimelimit_desc', 'admin'), 0, PARAM_INT));
200 $temp->add(new admin_setting_configtext('curlcache', new lang_string('curlcache', 'admin'),
201                                         new lang_string('configcurlcache', 'admin'), 120, PARAM_INT));
203 $temp->add(new admin_setting_configtext('curltimeoutkbitrate', new lang_string('curltimeoutkbitrate', 'admin'),
204                                         new lang_string('curltimeoutkbitrate_help', 'admin'), 56, PARAM_INT));
206 $ADMIN->add('server', $temp);
209 $ADMIN->add('server', new admin_externalpage('adminregistration', new lang_string('hubs', 'admin'),
210     "$CFG->wwwroot/$CFG->admin/registration/index.php"));
212 // "update notifications" settingpage
213 if (empty($CFG->disableupdatenotifications)) {
214     $temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin'));
215     $temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'),
216                                                 new lang_string('updateautocheck_desc', 'core_admin'), 1));
217     $temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'),
218                                               new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE,
219                                               array(
220                                                   MATURITY_ALPHA  => new lang_string('maturity'.MATURITY_ALPHA, 'core_admin'),
221                                                   MATURITY_BETA   => new lang_string('maturity'.MATURITY_BETA, 'core_admin'),
222                                                   MATURITY_RC     => new lang_string('maturity'.MATURITY_RC, 'core_admin'),
223                                                   MATURITY_STABLE => new lang_string('maturity'.MATURITY_STABLE, 'core_admin'),
224                                               )));
225     $temp->add(new admin_setting_configcheckbox('updatenotifybuilds', new lang_string('updatenotifybuilds', 'core_admin'),
226                                                 new lang_string('updatenotifybuilds_desc', 'core_admin'), 0));
227     $ADMIN->add('server', $temp);
230 } // end of speedup