Merge branch 'MD-31803' of git://github.com/mouneyrac/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'));
10 $temp->add(new admin_setting_configselect('gdversion', new lang_string('gdversion','admin'), new lang_string('configgdversion', 'admin'), check_gd_version(), array('0' => new lang_string('gdnot'),
11                                                                                                                                                           '1' => new lang_string('gd1'),
12                                                                                                                                                           '2' => new lang_string('gd2'))));
13 $temp->add(new admin_setting_configexecutable('pathtodu', new lang_string('pathtodu', 'admin'), new lang_string('configpathtodu', 'admin'), ''));
14 $temp->add(new admin_setting_configexecutable('aspellpath', new lang_string('aspellpath', 'admin'), new lang_string('edhelpaspellpath'), ''));
15 $temp->add(new admin_setting_configexecutable('pathtodot', new lang_string('pathtodot', 'admin'), new lang_string('pathtodot_help', 'admin'), ''));
16 $ADMIN->add('server', $temp);
20 // "supportcontact" settingpage
21 $temp = new admin_settingpage('supportcontact', new lang_string('supportcontact','admin'));
22 if (isloggedin()) {
23     global $USER;
24     $primaryadminemail = $USER->email;
25     $primaryadminname  = fullname($USER, true);
27 } else {
28     // no defaults during installation - admin user must be created first
29     $primaryadminemail = NULL;
30     $primaryadminname  = NULL;
31 }
32 $temp->add(new admin_setting_configtext('supportname', new lang_string('supportname', 'admin'), new lang_string('configsupportname', 'admin'), $primaryadminname, PARAM_NOTAGS));
33 $temp->add(new admin_setting_configtext('supportemail', new lang_string('supportemail', 'admin'), new lang_string('configsupportemail', 'admin'), $primaryadminemail, PARAM_NOTAGS));
34 $temp->add(new admin_setting_configtext('supportpage', new lang_string('supportpage', 'admin'), new lang_string('configsupportpage', 'admin'), '', PARAM_URL));
35 $ADMIN->add('server', $temp);
38 // "sessionhandling" settingpage
39 $temp = new admin_settingpage('sessionhandling', new lang_string('sessionhandling', 'admin'));
40 $temp->add(new admin_setting_configcheckbox('dbsessions', new lang_string('dbsessions', 'admin'), new lang_string('configdbsessions', 'admin'), 1));
41 $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),
42                                                                                                                                                       10800 => new lang_string('numhours', '', 3),
43                                                                                                                                                       7200 => new lang_string('numhours', '', 2),
44                                                                                                                                                       5400 => new lang_string('numhours', '', '1.5'),
45                                                                                                                                                       3600 => new lang_string('numminutes', '', 60),
46                                                                                                                                                       2700 => new lang_string('numminutes', '', 45),
47                                                                                                                                                       1800 => new lang_string('numminutes', '', 30),
48                                                                                                                                                       900 => new lang_string('numminutes', '', 15),
49                                                                                                                                                       300 => new lang_string('numminutes', '', 5))));
50 $temp->add(new admin_setting_configtext('sessioncookie', new lang_string('sessioncookie', 'admin'), new lang_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
51 $temp->add(new admin_setting_configtext('sessioncookiepath', new lang_string('sessioncookiepath', 'admin'), new lang_string('configsessioncookiepath', 'admin'), '', PARAM_RAW));
52 $temp->add(new admin_setting_configtext('sessioncookiedomain', new lang_string('sessioncookiedomain', 'admin'), new lang_string('configsessioncookiedomain', 'admin'), '', PARAM_RAW, 50));
53 $ADMIN->add('server', $temp);
56 // "stats" settingpage
57 $temp = new admin_settingpage('stats', new lang_string('stats'), 'moodle/site:config', empty($CFG->enablestats));
58 $temp->add(new admin_setting_configselect('statsfirstrun', new lang_string('statsfirstrun', 'admin'), new lang_string('configstatsfirstrun', 'admin'), 'none', array('none' => new lang_string('none'),
59                                                                                                                                                            60*60*24*7 => new lang_string('numweeks','moodle',1),
60                                                                                                                                                            60*60*24*14 => new lang_string('numweeks','moodle',2),
61                                                                                                                                                            60*60*24*21 => new lang_string('numweeks','moodle',3),
62                                                                                                                                                            60*60*24*28 => new lang_string('nummonths','moodle',1),
63                                                                                                                                                            60*60*24*56 => new lang_string('nummonths','moodle',2),
64                                                                                                                                                            60*60*24*84 => new lang_string('nummonths','moodle',3),
65                                                                                                                                                            60*60*24*112 => new lang_string('nummonths','moodle',4),
66                                                                                                                                                            60*60*24*140 => new lang_string('nummonths','moodle',5),
67                                                                                                                                                            60*60*24*168 => new lang_string('nummonths','moodle',6),
68                                                                                                                                                            'all' => new lang_string('all') )));
69 $temp->add(new admin_setting_configselect('statsmaxruntime', new lang_string('statsmaxruntime', 'admin'), new lang_string('configstatsmaxruntime3', 'admin'), 0, array(0 => new lang_string('untilcomplete'),
70                                                                                                                                                             60*30 => '10 '.new lang_string('minutes'),
71                                                                                                                                                             60*30 => '30 '.new lang_string('minutes'),
72                                                                                                                                                             60*60 => '1 '.new lang_string('hour'),
73                                                                                                                                                             60*60*2 => '2 '.new lang_string('hours'),
74                                                                                                                                                             60*60*3 => '3 '.new lang_string('hours'),
75                                                                                                                                                             60*60*4 => '4 '.new lang_string('hours'),
76                                                                                                                                                             60*60*5 => '5 '.new lang_string('hours'),
77                                                                                                                                                             60*60*6 => '6 '.new lang_string('hours'),
78                                                                                                                                                             60*60*7 => '7 '.new lang_string('hours'),
79                                                                                                                                                             60*60*8 => '8 '.new lang_string('hours') )));
80 $temp->add(new admin_setting_configtext('statsruntimedays', new lang_string('statsruntimedays', 'admin'), new lang_string('configstatsruntimedays', 'admin'), 31, PARAM_INT));
81 $temp->add(new admin_setting_configtime('statsruntimestarthour', 'statsruntimestartminute', new lang_string('statsruntimestart', 'admin'), new lang_string('configstatsruntimestart', 'admin'), array('h' => 0, 'm' => 0)));
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));
96 $temp->add(new admin_setting_heading('webproxy', new lang_string('webproxy', 'admin'), new lang_string('webproxyinfo', 'admin')));
97 $temp->add(new admin_setting_configtext('proxyhost', new lang_string('proxyhost', 'admin'), new lang_string('configproxyhost', 'admin'), '', PARAM_HOST));
98 $temp->add(new admin_setting_configtext('proxyport', new lang_string('proxyport', 'admin'), new lang_string('configproxyport', 'admin'), 0, PARAM_INT));
99 $options = array('HTTP'=>'HTTP');
100 if (defined('CURLPROXY_SOCKS5')) {
101     $options['SOCKS5'] = 'SOCKS5';
103 $temp->add(new admin_setting_configselect('proxytype', new lang_string('proxytype', 'admin'), new lang_string('configproxytype','admin'), 'HTTP', $options));
104 $temp->add(new admin_setting_configtext('proxyuser', new lang_string('proxyuser', 'admin'), new lang_string('configproxyuser', 'admin'), ''));
105 $temp->add(new admin_setting_configpasswordunmask('proxypassword', new lang_string('proxypassword', 'admin'), new lang_string('configproxypassword', 'admin'), ''));
106 $temp->add(new admin_setting_configtext('proxybypass', new lang_string('proxybypass', 'admin'), new lang_string('configproxybypass', 'admin'), 'localhost, 127.0.0.1'));
107 $ADMIN->add('server', $temp);
109 $temp = new admin_settingpage('maintenancemode', new lang_string('sitemaintenancemode', 'admin'));
110 $options = array(0=>new lang_string('disable'), 1=>new lang_string('enable'));
111 $temp->add(new admin_setting_configselect('maintenance_enabled', new lang_string('sitemaintenancemode', 'admin'),
112                                           new lang_string('helpsitemaintenance', 'admin'), 0, $options));
113 $temp->add(new admin_setting_confightmleditor('maintenance_message', new lang_string('optionalmaintenancemessage', 'admin'),
114                                               '', ''));
115 $ADMIN->add('server', $temp);
117 $temp = new admin_settingpage('cleanup', new lang_string('cleanup', 'admin'));
118 $temp->add(new admin_setting_configselect('deleteunconfirmed', new lang_string('deleteunconfirmed', 'admin'), new lang_string('configdeleteunconfirmed', 'admin'), 168, array(0 => new lang_string('never'),
119                                                                                                                                                                     168 => new lang_string('numdays', '', 7),
120                                                                                                                                                                     144 => new lang_string('numdays', '', 6),
121                                                                                                                                                                     120 => new lang_string('numdays', '', 5),
122                                                                                                                                                                     96 => new lang_string('numdays', '', 4),
123                                                                                                                                                                     72 => new lang_string('numdays', '', 3),
124                                                                                                                                                                     48 => new lang_string('numdays', '', 2),
125                                                                                                                                                                     24 => new lang_string('numdays', '', 1),
126                                                                                                                                                                     12 => new lang_string('numhours', '', 12),
127                                                                                                                                                                     6 => new lang_string('numhours', '', 6),
128                                                                                                                                                                     1 => new lang_string('numhours', '', 1))));
130 $temp->add(new admin_setting_configselect('deleteincompleteusers', new lang_string('deleteincompleteusers', 'admin'), new lang_string('configdeleteincompleteusers', 'admin'), 0, array(0 => new lang_string('never'),
131                                                                                                                                                                     168 => new lang_string('numdays', '', 7),
132                                                                                                                                                                     144 => new lang_string('numdays', '', 6),
133                                                                                                                                                                     120 => new lang_string('numdays', '', 5),
134                                                                                                                                                                     96 => new lang_string('numdays', '', 4),
135                                                                                                                                                                     72 => new lang_string('numdays', '', 3),
136                                                                                                                                                                     48 => new lang_string('numdays', '', 2),
137                                                                                                                                                                     24 => new lang_string('numdays', '', 1))));
139 $temp->add(new admin_setting_configcheckbox('logguests', new lang_string('logguests', 'admin'),
140                                             new lang_string('logguests_help', 'admin'), 1));
141 $temp->add(new admin_setting_configselect('loglifetime', new lang_string('loglifetime', 'admin'), new lang_string('configloglifetime', 'admin'), 0, array(0 => new lang_string('neverdeletelogs'),
142                                                                                                                                                 1000 => new lang_string('numdays', '', 1000),
143                                                                                                                                                 365 => new lang_string('numdays', '', 365),
144                                                                                                                                                 180 => new lang_string('numdays', '', 180),
145                                                                                                                                                 150 => new lang_string('numdays', '', 150),
146                                                                                                                                                 120 => new lang_string('numdays', '', 120),
147                                                                                                                                                 90 => new lang_string('numdays', '', 90),
148                                                                                                                                                 60 => new lang_string('numdays', '', 60),
149                                                                                                                                                 35 => new lang_string('numdays', '', 35),
150                                                                                                                                                 10 => new lang_string('numdays', '', 10),
151                                                                                                                                                 5 => new lang_string('numdays', '', 5),
152                                                                                                                                                 2 => new lang_string('numdays', '', 2))));
155 $temp->add(new admin_setting_configcheckbox('disablegradehistory', new lang_string('disablegradehistory', 'grades'),
156                                             new lang_string('disablegradehistory_help', 'grades'), 0));
158 $temp->add(new admin_setting_configselect('gradehistorylifetime', new lang_string('gradehistorylifetime', 'grades'),
159                                           new lang_string('gradehistorylifetime_help', 'grades'), 0, array(0 => new lang_string('neverdeletehistory', 'grades'),
160                                                                                                    1000 => new lang_string('numdays', '', 1000),
161                                                                                                     365 => new lang_string('numdays', '', 365),
162                                                                                                     180 => new lang_string('numdays', '', 180),
163                                                                                                     150 => new lang_string('numdays', '', 150),
164                                                                                                     120 => new lang_string('numdays', '', 120),
165                                                                                                      90 => new lang_string('numdays', '', 90),
166                                                                                                      60 => new lang_string('numdays', '', 60),
167                                                                                                      30 => new lang_string('numdays', '', 30))));
169 $ADMIN->add('server', $temp);
173 $ADMIN->add('server', new admin_externalpage('environment', new lang_string('environment','admin'), "$CFG->wwwroot/$CFG->admin/environment.php"));
174 $ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo'), "$CFG->wwwroot/$CFG->admin/phpinfo.php"));
177 // "performance" settingpage
178 $temp = new admin_settingpage('performance', new lang_string('performance', 'admin'));
180 $temp->add(new admin_setting_configtext('numcoursesincombo', new lang_string('numcoursesincombo', 'admin'), new lang_string('numcoursesincombo_help', 'admin'), 500));
182 $temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'),
183                                           new lang_string('configextramemorylimit', 'admin'), '512M',
184                                           // if this option is set to 0, default 128M will be used
185                                           array( '64M' => '64M',
186                                                  '128M' => '128M',
187                                                  '256M' => '256M',
188                                                  '512M' => '512M',
189                                                  '1024M' => '1024M'
190                                              )));
191 $temp->add(new admin_setting_configtext('curlcache', new lang_string('curlcache', 'admin'),
192                                         new lang_string('configcurlcache', 'admin'), 120, PARAM_INT));
194 $temp->add(new admin_setting_configtext('curltimeoutkbitrate', new lang_string('curltimeoutkbitrate', 'admin'),
195                                         new lang_string('curltimeoutkbitrate_help', 'admin'), 56, PARAM_INT));
196 /* //TODO: we need to fix code instead of relying on slow rcache, enable this once we have some code that is actually using it
197 $temp->add(new admin_setting_special_selectsetup('cachetype', new lang_string('cachetype', 'admin'),
198                                           new lang_string('configcachetype', 'admin'), '',
199                                           array( '' => new lang_string('none'),
200                                                  'internal' => 'internal',
201                                                  'memcached' => 'memcached',
202                                                  'eaccelerator' => 'eaccelerator')));
203 // NOTE: $CFG->rcache is forced to bool in lib/setup.php
204 $temp->add(new admin_setting_special_selectsetup('rcache', new lang_string('rcache', 'admin'),
205                                           new lang_string('configrcache', 'admin'), 0,
206                                           array( '0' => new lang_string('no'),
207                                                  '1' => new lang_string('yes'))));
208 $temp->add(new admin_setting_configtext('rcachettl', new lang_string('rcachettl', 'admin'),
209                                         new lang_string('configrcachettl', 'admin'), 10));
210 $temp->add(new admin_setting_configtext('intcachemax', new lang_string('intcachemax', 'admin'),
211                                         new lang_string('configintcachemax', 'admin'), 10));
212 $temp->add(new admin_setting_configtext('memcachedhosts', new lang_string('memcachedhosts', 'admin'),
213                                         new lang_string('configmemcachedhosts', 'admin'), ''));
214 $temp->add(new admin_setting_configselect('memcachedpconn', new lang_string('memcachedpconn', 'admin'),
215                                           new lang_string('configmemcachedpconn', 'admin'), 0,
216                                           array( '0' => new lang_string('no'),
217                                                  '1' => new lang_string('yes'))));
218 */
219 $ADMIN->add('server', $temp);
222 $ADMIN->add('server', new admin_externalpage('adminregistration', new lang_string('hubs', 'admin'),
223     "$CFG->wwwroot/$CFG->admin/registration/index.php"));
225 // "update notifications" settingpage
226 if (empty($CFG->disableupdatenotifications)) {
227     $temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin'));
228     $temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'),
229                                                 new lang_string('updateautocheck_desc', 'core_admin'), 1));
230     $temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'),
231                                               new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE,
232                                               array(
233                                                   MATURITY_ALPHA  => new lang_string('maturity'.MATURITY_ALPHA, 'core_admin'),
234                                                   MATURITY_BETA   => new lang_string('maturity'.MATURITY_BETA, 'core_admin'),
235                                                   MATURITY_RC     => new lang_string('maturity'.MATURITY_RC, 'core_admin'),
236                                                   MATURITY_STABLE => new lang_string('maturity'.MATURITY_STABLE, 'core_admin'),
237                                               )));
238     $temp->add(new admin_setting_configcheckbox('updatenotifybuilds', new lang_string('updatenotifybuilds', 'core_admin'),
239                                                 new lang_string('updatenotifybuilds_desc', 'core_admin'), 0));
240     $ADMIN->add('server', $temp);
243 } // end of speedup