028804bf846a580c9e371fe5fc8d270753fd3414
[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', get_string('systempaths','admin'));
10 $temp->add(new admin_setting_configselect('gdversion', get_string('gdversion','admin'), get_string('configgdversion', 'admin'), check_gd_version(), array('0' => get_string('gdnot'),
11                                                                                                                                                           '1' => get_string('gd1'),
12                                                                                                                                                           '2' => get_string('gd2'))));
13 $temp->add(new admin_setting_configexecutable('pathtodu', get_string('pathtodu', 'admin'), get_string('configpathtodu', 'admin'), ''));
14 $temp->add(new admin_setting_configexecutable('aspellpath', get_string('aspellpath', 'admin'), get_string('edhelpaspellpath'), ''));
15 $ADMIN->add('server', $temp);
19 // "email" settingpage
20 $temp = new admin_settingpage('mail', get_string('mail','admin'));
21 $temp->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'admin'), get_string('configsmtphosts', 'admin'), '', PARAM_RAW));
22 $temp->add(new admin_setting_configtext('smtpuser', get_string('smtpuser', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
23 $temp->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'admin'), get_string('configsmtpuser', 'admin'), ''));
24 $temp->add(new admin_setting_configtext('smtpmaxbulk', get_string('smtpmaxbulk', 'admin'), get_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT));
25 $temp->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'admin'), get_string('confignoreplyaddress', 'admin'), 'noreply@' . get_host_from_url($CFG->wwwroot), PARAM_NOTAGS));
26 $temp->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'admin'), get_string('configdigestmailtime', 'admin'), 17, array('00' => '00',
27                                                                                                                                                           '01' => '01',
28                                                                                                                                                           '02' => '02',
29                                                                                                                                                           '03' => '03',
30                                                                                                                                                           '04' => '04',
31                                                                                                                                                           '05' => '05',
32                                                                                                                                                           '06' => '06',
33                                                                                                                                                           '07' => '07',
34                                                                                                                                                           '08' => '08',
35                                                                                                                                                           '09' => '09',
36                                                                                                                                                           '10' => '10',
37                                                                                                                                                           '11' => '11',
38                                                                                                                                                           '12' => '12',
39                                                                                                                                                           '13' => '13',
40                                                                                                                                                           '14' => '14',
41                                                                                                                                                           '15' => '15',
42                                                                                                                                                           '16' => '16',
43                                                                                                                                                           '17' => '17',
44                                                                                                                                                           '18' => '18',
45                                                                                                                                                           '19' => '19',
46                                                                                                                                                           '20' => '20',
47                                                                                                                                                           '21' => '21',
48                                                                                                                                                           '22' => '22',
49                                                                                                                                                           '23' => '23')));
50 $charsets = get_list_of_charsets();
51 unset($charsets['UTF-8']); // not needed here
52 $options = array();
53 $options['0'] = 'UTF-8';
54 $options = array_merge($options, $charsets);
55 $temp->add(new admin_setting_configselect('sitemailcharset', get_string('sitemailcharset', 'admin'), get_string('configsitemailcharset','admin'), '0', $options));
56 $temp->add(new admin_setting_configcheckbox('allowusermailcharset', get_string('allowusermailcharset', 'admin'), get_string('configallowusermailcharset', 'admin'), 0));
57 $options = array('LF'=>'LF', 'CRLF'=>'CRLF');
58 $temp->add(new admin_setting_configselect('mailnewline', get_string('mailnewline', 'admin'), get_string('configmailnewline','admin'), 'LF', $options));
59 if (isloggedin()) {
60     global $USER;
61     $primaryadminemail = $USER->email;
62     $primaryadminname  = fullname($USER, true);
64 } else {
65     // no defaults during installation - admin user must be created first
66     $primaryadminemail = NULL;
67     $primaryadminname  = NULL;
68 }
69 $temp->add(new admin_setting_configtext('supportname', get_string('supportname', 'admin'), get_string('configsupportname', 'admin'), $primaryadminname, PARAM_NOTAGS));
70 $temp->add(new admin_setting_configtext('supportemail', get_string('supportemail', 'admin'), get_string('configsupportemail', 'admin'), $primaryadminemail, PARAM_NOTAGS));
71 $temp->add(new admin_setting_configtext('supportpage', get_string('supportpage', 'admin'), get_string('configsupportpage', 'admin'), '', PARAM_URL));
72 $ADMIN->add('server', $temp);
76 // "sessionhandling" settingpage
77 $temp = new admin_settingpage('sessionhandling', get_string('sessionhandling', 'admin'));
78 $temp->add(new admin_setting_configcheckbox('dbsessions', get_string('dbsessions', 'admin'), get_string('configdbsessions', 'admin'), 1));
79 $temp->add(new admin_setting_configselect('sessiontimeout', get_string('sessiontimeout', 'admin'), get_string('configsessiontimeout', 'admin'), 7200, array(14400 => get_string('numhours', '', 4),
80                                                                                                                                                       10800 => get_string('numhours', '', 3),
81                                                                                                                                                       7200 => get_string('numhours', '', 2),
82                                                                                                                                                       5400 => get_string('numhours', '', '1.5'),
83                                                                                                                                                       3600 => get_string('numminutes', '', 60),
84                                                                                                                                                       2700 => get_string('numminutes', '', 45),
85                                                                                                                                                       1800 => get_string('numminutes', '', 30),
86                                                                                                                                                       900 => get_string('numminutes', '', 15),
87                                                                                                                                                       300 => get_string('numminutes', '', 5))));
88 $temp->add(new admin_setting_configtext('sessioncookie', get_string('sessioncookie', 'admin'), get_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
89 $temp->add(new admin_setting_configtext('sessioncookiepath', get_string('sessioncookiepath', 'admin'), get_string('configsessioncookiepath', 'admin'), '/', PARAM_LOCALURL));
90 $temp->add(new admin_setting_configtext('sessioncookiedomain', get_string('sessioncookiedomain', 'admin'), get_string('configsessioncookiedomain', 'admin'), '', PARAM_TEXT, 50));
91 $ADMIN->add('server', $temp);
94 // "stats" settingpage
95 $temp = new admin_settingpage('stats', get_string('stats'), 'moodle/site:config', empty($CFG->enablestats));
96 $temp->add(new admin_setting_configselect('statsfirstrun', get_string('statsfirstrun', 'admin'), get_string('configstatsfirstrun', 'admin'), 'none', array('none' => get_string('none'),
97                                                                                                                                                            60*60*24*7 => get_string('numweeks','moodle',1),
98                                                                                                                                                            60*60*24*14 => get_string('numweeks','moodle',2),
99                                                                                                                                                            60*60*24*21 => get_string('numweeks','moodle',3),
100                                                                                                                                                            60*60*24*28 => get_string('nummonths','moodle',1),
101                                                                                                                                                            60*60*24*56 => get_string('nummonths','moodle',2),
102                                                                                                                                                            60*60*24*84 => get_string('nummonths','moodle',3),
103                                                                                                                                                            60*60*24*112 => get_string('nummonths','moodle',4),
104                                                                                                                                                            60*60*24*140 => get_string('nummonths','moodle',5),
105                                                                                                                                                            60*60*24*168 => get_string('nummonths','moodle',6),
106                                                                                                                                                            'all' => get_string('all') )));
107 $temp->add(new admin_setting_configselect('statsmaxruntime', get_string('statsmaxruntime', 'admin'), get_string('configstatsmaxruntime3', 'admin'), 0, array(0 => get_string('untilcomplete'),
108                                                                                                                                                             60*30 => '10 '.get_string('minutes'),
109                                                                                                                                                             60*30 => '30 '.get_string('minutes'),
110                                                                                                                                                             60*60 => '1 '.get_string('hour'),
111                                                                                                                                                             60*60*2 => '2 '.get_string('hours'),
112                                                                                                                                                             60*60*3 => '3 '.get_string('hours'),
113                                                                                                                                                             60*60*4 => '4 '.get_string('hours'),
114                                                                                                                                                             60*60*5 => '5 '.get_string('hours'),
115                                                                                                                                                             60*60*6 => '6 '.get_string('hours'),
116                                                                                                                                                             60*60*7 => '7 '.get_string('hours'),
117                                                                                                                                                             60*60*8 => '8 '.get_string('hours') )));
118 $temp->add(new admin_setting_configtext('statsruntimedays', get_string('statsruntimedays', 'admin'), get_string('configstatsruntimedays', 'admin'), 31, PARAM_INT));
119 $temp->add(new admin_setting_configtime('statsruntimestarthour', 'statsruntimestartminute', get_string('statsruntimestart', 'admin'), get_string('configstatsruntimestart', 'admin'), array('h' => 0, 'm' => 0)));
120 $temp->add(new admin_setting_configtext('statsuserthreshold', get_string('statsuserthreshold', 'admin'), get_string('configstatsuserthreshold', 'admin'), 0, PARAM_INT));
122 $options = array(0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6);
123 $temp->add(new admin_setting_configselect('statscatdepth', get_string('statscatdepth', 'admin'), get_string('configstatscatdepth', 'admin'), 1, $options));
124 $ADMIN->add('server', $temp);
127 // "http" settingpage
128 $temp = new admin_settingpage('http', get_string('http', 'admin'));
129 $temp->add(new admin_setting_configtext('framename', get_string('framename', 'admin'), get_string('configframename', 'admin'), '_top', PARAM_ALPHAEXT));
130 $temp->add(new admin_setting_configcheckbox('slasharguments', get_string('slasharguments', 'admin'), get_string('configslasharguments', 'admin'), 1));
131 $temp->add(new admin_setting_heading('reverseproxy', get_string('reverseproxy', 'admin'), '', ''));
132 $options = array(
133     0 => 'HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
134     GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
135     GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
136     GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR|GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR');
137 $temp->add(new admin_setting_configselect('getremoteaddrconf', get_string('getremoteaddrconf', 'admin'), get_string('configgetremoteaddrconf', 'admin'), 0, $options));
138 $temp->add(new admin_setting_heading('webproxy', get_string('webproxy', 'admin'), get_string('webproxyinfo', 'admin')));
139 $temp->add(new admin_setting_configtext('proxyhost', get_string('proxyhost', 'admin'), get_string('configproxyhost', 'admin'), '', PARAM_HOST));
140 $temp->add(new admin_setting_configtext('proxyport', get_string('proxyport', 'admin'), get_string('configproxyport', 'admin'), 0, PARAM_INT));
141 $options = array('HTTP'=>'HTTP');
142 if (defined('CURLPROXY_SOCKS5')) {
143     $options['SOCKS5'] = 'SOCKS5';
145 $temp->add(new admin_setting_configselect('proxytype', get_string('proxytype', 'admin'), get_string('configproxytype','admin'), 'HTTP', $options));
146 $temp->add(new admin_setting_configtext('proxyuser', get_string('proxyuser', 'admin'), get_string('configproxyuser', 'admin'), ''));
147 $temp->add(new admin_setting_configpasswordunmask('proxypassword', get_string('proxypassword', 'admin'), get_string('configproxypassword', 'admin'), ''));
148 $temp->add(new admin_setting_configtext('proxybypass', get_string('proxybypass', 'admin'), get_string('configproxybypass', 'admin'), 'localhost, 127.0.0.1'));
149 $ADMIN->add('server', $temp);
151 $temp = new admin_settingpage('maintenancemode', get_string('sitemaintenancemode', 'admin'));
152 $options = array(0=>get_string('disable'), 1=>get_string('enable'));
153 $temp->add(new admin_setting_configselect('maintenance_enabled', get_string('sitemaintenancemode', 'admin'),
154                                           get_string('helpsitemaintenance', 'admin'), 0, $options));
155 $temp->add(new admin_setting_confightmleditor('maintenance_message', get_string('optionalmaintenancemessage', 'admin'),
156                                               '', ''));
157 $ADMIN->add('server', $temp);
159 $temp = new admin_settingpage('cleanup', get_string('cleanup', 'admin'));
160 $temp->add(new admin_setting_configselect('longtimenosee', get_string('longtimenosee', 'admin'), get_string('configlongtimenosee', 'admin'), 120, array(0 => get_string('never'),
161                                                                                                                                                         1000 => get_string('numdays', '', 1000),
162                                                                                                                                                         365 => get_string('numdays', '', 365),
163                                                                                                                                                         180 => get_string('numdays', '', 180),
164                                                                                                                                                         150 => get_string('numdays', '', 150),
165                                                                                                                                                         120 => get_string('numdays', '', 120),
166                                                                                                                                                         90 => get_string('numdays', '', 90),
167                                                                                                                                                         60 => get_string('numdays', '', 60),
168                                                                                                                                                         30 => get_string('numdays', '', 30),
169                                                                                                                                                         21 => get_string('numdays', '', 21),
170                                                                                                                                                         14 => get_string('numdays', '', 14),
171                                                                                                                                                         7 => get_string('numdays', '', 7) )));
172 $temp->add(new admin_setting_configselect('deleteunconfirmed', get_string('deleteunconfirmed', 'admin'), get_string('configdeleteunconfirmed', 'admin'), 168, array(0 => get_string('never'),
173                                                                                                                                                                     168 => get_string('numdays', '', 7),
174                                                                                                                                                                     144 => get_string('numdays', '', 6),
175                                                                                                                                                                     120 => get_string('numdays', '', 5),
176                                                                                                                                                                     96 => get_string('numdays', '', 4),
177                                                                                                                                                                     72 => get_string('numdays', '', 3),
178                                                                                                                                                                     48 => get_string('numdays', '', 2),
179                                                                                                                                                                     24 => get_string('numdays', '', 1),
180                                                                                                                                                                     12 => get_string('numhours', '', 12),
181                                                                                                                                                                     6 => get_string('numhours', '', 6),
182                                                                                                                                                                     1 => get_string('numhours', '', 1))));
184 $temp->add(new admin_setting_configselect('deleteincompleteusers', get_string('deleteincompleteusers', 'admin'), get_string('configdeleteincompleteusers', 'admin'), 0, array(0 => get_string('never'),
185                                                                                                                                                                     168 => get_string('numdays', '', 7),
186                                                                                                                                                                     144 => get_string('numdays', '', 6),
187                                                                                                                                                                     120 => get_string('numdays', '', 5),
188                                                                                                                                                                     96 => get_string('numdays', '', 4),
189                                                                                                                                                                     72 => get_string('numdays', '', 3),
190                                                                                                                                                                     48 => get_string('numdays', '', 2),
191                                                                                                                                                                     24 => get_string('numdays', '', 1))));
193 $temp->add(new admin_setting_configselect('loglifetime', get_string('loglifetime', 'admin'), get_string('configloglifetime', 'admin'), 0, array(0 => get_string('neverdeletelogs'),
194                                                                                                                                                 1000 => get_string('numdays', '', 1000),
195                                                                                                                                                 365 => get_string('numdays', '', 365),
196                                                                                                                                                 180 => get_string('numdays', '', 180),
197                                                                                                                                                 150 => get_string('numdays', '', 150),
198                                                                                                                                                 120 => get_string('numdays', '', 120),
199                                                                                                                                                 90 => get_string('numdays', '', 90),
200                                                                                                                                                 60 => get_string('numdays', '', 60),
201                                                                                                                                                 35 => get_string('numdays', '', 35),
202                                                                                                                                                 10 => get_string('numdays', '', 10),
203                                                                                                                                                 5 => get_string('numdays', '', 5),
204                                                                                                                                                 2 => get_string('numdays', '', 2))));
207 $temp->add(new admin_setting_configcheckbox('disablegradehistory', get_string('disablegradehistory', 'grades'),
208                                             get_string('disablegradehistory_help', 'grades'), 0, PARAM_INT));
210 $temp->add(new admin_setting_configselect('gradehistorylifetime', get_string('gradehistorylifetime', 'grades'),
211                                           get_string('gradehistorylifetime_help', 'grades'), 0, array(0 => get_string('neverdeletehistory', 'grades'),
212                                                                                                    1000 => get_string('numdays', '', 1000),
213                                                                                                     365 => get_string('numdays', '', 365),
214                                                                                                     180 => get_string('numdays', '', 180),
215                                                                                                     150 => get_string('numdays', '', 150),
216                                                                                                     120 => get_string('numdays', '', 120),
217                                                                                                      90 => get_string('numdays', '', 90),
218                                                                                                      60 => get_string('numdays', '', 60),
219                                                                                                      30 => get_string('numdays', '', 30))));
221 $ADMIN->add('server', $temp);
225 $ADMIN->add('server', new admin_externalpage('environment', get_string('environment','admin'), "$CFG->wwwroot/$CFG->admin/environment.php"));
226 $ADMIN->add('server', new admin_externalpage('phpinfo', get_string('phpinfo'), "$CFG->wwwroot/$CFG->admin/phpinfo.php"));
229 // "performance" settingpage
230 $temp = new admin_settingpage('performance', get_string('performance', 'admin'));
232 $temp->add(new admin_setting_configselect('extramemorylimit', get_string('extramemorylimit', 'admin'),
233                                           get_string('configextramemorylimit', 'admin'), '128M',
234                                           // if this option is set to 0, default 128M will be used
235                                           array( '64M' => '64M',
236                                                  '128M' => '128M',
237                                                  '256M' => '256M',
238                                                  '512M' => '512M',
239                                                  '1024M' => '1024M'
240                                              )));
241 $temp->add(new admin_setting_special_selectsetup('cachetype', get_string('cachetype', 'admin'),
242                                           get_string('configcachetype', 'admin'), '',
243                                           array( '' => get_string('none'),
244                                                  'internal' => 'internal',
245                                                  'memcached' => 'memcached',
246                                                  'eaccelerator' => 'eaccelerator')));
247 // NOTE: $CFG->rcache is forced to bool in lib/setup.php
248 $temp->add(new admin_setting_special_selectsetup('rcache', get_string('rcache', 'admin'),
249                                           get_string('configrcache', 'admin'), 0,
250                                           array( '0' => get_string('no'),
251                                                  '1' => get_string('yes'))));
252 $temp->add(new admin_setting_configtext('rcachettl', get_string('rcachettl', 'admin'),
253                                         get_string('configrcachettl', 'admin'), 10));
254 $temp->add(new admin_setting_configtext('intcachemax', get_string('intcachemax', 'admin'),
255                                         get_string('configintcachemax', 'admin'), 10));
256 $temp->add(new admin_setting_configtext('curlcache', get_string('curlcache', 'admin'),
257                                         get_string('configcurlcache', 'admin'), 120, PARAM_INT));
258 $temp->add(new admin_setting_configtext('memcachedhosts', get_string('memcachedhosts', 'admin'),
259                                         get_string('configmemcachedhosts', 'admin'), ''));
260 $temp->add(new admin_setting_configselect('memcachedpconn', get_string('memcachedpconn', 'admin'),
261                                           get_string('configmemcachedpconn', 'admin'), 0,
262                                           array( '0' => get_string('no'),
263                                                  '1' => get_string('yes'))));
264 $ADMIN->add('server', new admin_externalpage('adminregistration', get_string('registration','admin'), "$CFG->wwwroot/$CFG->admin/registration/index.php"));
266 $ADMIN->add('server', $temp);
268 $dbfamily = $DB->get_dbfamily();
270 if ($dbfamily === 'mysql') {
271     if (file_exists("$CFG->dirroot/$CFG->admin/mysql/frame.php")) {
272         $ADMIN->add('server', new admin_externalpage('database', get_string('managedatabase'), "$CFG->wwwroot/$CFG->admin/mysql/frame.php"));
273     }
274 } else if ($dbfamily === 'postgres') {
275     if (file_exists("$CFG->dirroot/$CFG->admin/pgsql/frame.php")) {
276         $ADMIN->add('server', new admin_externalpage('database', get_string('managedatabase'), "$CFG->wwwroot/$CFG->admin/pgsql/frame.php"));
277     }
280 } // end of speedup