154b98f84b1f3af6ac5eb023d4b8a633403d5047
[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 $ADMIN->add('server', $temp);
18 // "supportcontact" settingpage
19 $temp = new admin_settingpage('supportcontact', new lang_string('supportcontact','admin'));
20 if (isloggedin()) {
21     global $USER;
22     $primaryadminemail = $USER->email;
23     $primaryadminname  = fullname($USER, true);
25 } else {
26     // no defaults during installation - admin user must be created first
27     $primaryadminemail = NULL;
28     $primaryadminname  = NULL;
29 }
30 $temp->add(new admin_setting_configtext('supportname', new lang_string('supportname', 'admin'), new lang_string('configsupportname', 'admin'), $primaryadminname, PARAM_NOTAGS));
31 $temp->add(new admin_setting_configtext('supportemail', new lang_string('supportemail', 'admin'), new lang_string('configsupportemail', 'admin'), $primaryadminemail, PARAM_NOTAGS));
32 $temp->add(new admin_setting_configtext('supportpage', new lang_string('supportpage', 'admin'), new lang_string('configsupportpage', 'admin'), '', PARAM_URL));
33 $ADMIN->add('server', $temp);
36 // "sessionhandling" settingpage
37 $temp = new admin_settingpage('sessionhandling', new lang_string('sessionhandling', 'admin'));
38 $temp->add(new admin_setting_configcheckbox('dbsessions', new lang_string('dbsessions', 'admin'), new lang_string('configdbsessions', 'admin'), 1));
39 $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),
40                                                                                                                                                       10800 => new lang_string('numhours', '', 3),
41                                                                                                                                                       7200 => new lang_string('numhours', '', 2),
42                                                                                                                                                       5400 => new lang_string('numhours', '', '1.5'),
43                                                                                                                                                       3600 => new lang_string('numminutes', '', 60),
44                                                                                                                                                       2700 => new lang_string('numminutes', '', 45),
45                                                                                                                                                       1800 => new lang_string('numminutes', '', 30),
46                                                                                                                                                       900 => new lang_string('numminutes', '', 15),
47                                                                                                                                                       300 => new lang_string('numminutes', '', 5))));
48 $temp->add(new admin_setting_configtext('sessioncookie', new lang_string('sessioncookie', 'admin'), new lang_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
49 $temp->add(new admin_setting_configtext('sessioncookiepath', new lang_string('sessioncookiepath', 'admin'), new lang_string('configsessioncookiepath', 'admin'), '', PARAM_RAW));
50 $temp->add(new admin_setting_configtext('sessioncookiedomain', new lang_string('sessioncookiedomain', 'admin'), new lang_string('configsessioncookiedomain', 'admin'), '', PARAM_RAW, 50));
51 $ADMIN->add('server', $temp);
54 // "stats" settingpage
55 $temp = new admin_settingpage('stats', new lang_string('stats'), 'moodle/site:config', empty($CFG->enablestats));
56 $temp->add(new admin_setting_configselect('statsfirstrun', new lang_string('statsfirstrun', 'admin'), new lang_string('configstatsfirstrun', 'admin'), 'none', array('none' => new lang_string('none'),
57                                                                                                                                                            60*60*24*7 => new lang_string('numweeks','moodle',1),
58                                                                                                                                                            60*60*24*14 => new lang_string('numweeks','moodle',2),
59                                                                                                                                                            60*60*24*21 => new lang_string('numweeks','moodle',3),
60                                                                                                                                                            60*60*24*28 => new lang_string('nummonths','moodle',1),
61                                                                                                                                                            60*60*24*56 => new lang_string('nummonths','moodle',2),
62                                                                                                                                                            60*60*24*84 => new lang_string('nummonths','moodle',3),
63                                                                                                                                                            60*60*24*112 => new lang_string('nummonths','moodle',4),
64                                                                                                                                                            60*60*24*140 => new lang_string('nummonths','moodle',5),
65                                                                                                                                                            60*60*24*168 => new lang_string('nummonths','moodle',6),
66                                                                                                                                                            'all' => new lang_string('all') )));
67 $temp->add(new admin_setting_configselect('statsmaxruntime', new lang_string('statsmaxruntime', 'admin'), new lang_string('configstatsmaxruntime3', 'admin'), 0, array(0 => new lang_string('untilcomplete'),
68                                                                                                                                                             60*30 => '10 '.new lang_string('minutes'),
69                                                                                                                                                             60*30 => '30 '.new lang_string('minutes'),
70                                                                                                                                                             60*60 => '1 '.new lang_string('hour'),
71                                                                                                                                                             60*60*2 => '2 '.new lang_string('hours'),
72                                                                                                                                                             60*60*3 => '3 '.new lang_string('hours'),
73                                                                                                                                                             60*60*4 => '4 '.new lang_string('hours'),
74                                                                                                                                                             60*60*5 => '5 '.new lang_string('hours'),
75                                                                                                                                                             60*60*6 => '6 '.new lang_string('hours'),
76                                                                                                                                                             60*60*7 => '7 '.new lang_string('hours'),
77                                                                                                                                                             60*60*8 => '8 '.new lang_string('hours') )));
78 $temp->add(new admin_setting_configtext('statsruntimedays', new lang_string('statsruntimedays', 'admin'), new lang_string('configstatsruntimedays', 'admin'), 31, PARAM_INT));
79 $temp->add(new admin_setting_configtime('statsruntimestarthour', 'statsruntimestartminute', new lang_string('statsruntimestart', 'admin'), new lang_string('configstatsruntimestart', 'admin'), array('h' => 0, 'm' => 0)));
80 $temp->add(new admin_setting_configtext('statsuserthreshold', new lang_string('statsuserthreshold', 'admin'), new lang_string('configstatsuserthreshold', 'admin'), 0, PARAM_INT));
81 $ADMIN->add('server', $temp);
84 // "http" settingpage
85 $temp = new admin_settingpage('http', new lang_string('http', 'admin'));
86 $temp->add(new admin_setting_configcheckbox('slasharguments', new lang_string('slasharguments', 'admin'), new lang_string('configslasharguments', 'admin'), 1));
87 $temp->add(new admin_setting_heading('reverseproxy', new lang_string('reverseproxy', 'admin'), '', ''));
88 $options = array(
89     0 => 'HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
90     GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
91     GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
92     GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR|GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR');
93 $temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'), new lang_string('configgetremoteaddrconf', 'admin'), 0, $options));
94 $temp->add(new admin_setting_heading('webproxy', new lang_string('webproxy', 'admin'), new lang_string('webproxyinfo', 'admin')));
95 $temp->add(new admin_setting_configtext('proxyhost', new lang_string('proxyhost', 'admin'), new lang_string('configproxyhost', 'admin'), '', PARAM_HOST));
96 $temp->add(new admin_setting_configtext('proxyport', new lang_string('proxyport', 'admin'), new lang_string('configproxyport', 'admin'), 0, PARAM_INT));
97 $options = array('HTTP'=>'HTTP');
98 if (defined('CURLPROXY_SOCKS5')) {
99     $options['SOCKS5'] = 'SOCKS5';
101 $temp->add(new admin_setting_configselect('proxytype', new lang_string('proxytype', 'admin'), new lang_string('configproxytype','admin'), 'HTTP', $options));
102 $temp->add(new admin_setting_configtext('proxyuser', new lang_string('proxyuser', 'admin'), new lang_string('configproxyuser', 'admin'), ''));
103 $temp->add(new admin_setting_configpasswordunmask('proxypassword', new lang_string('proxypassword', 'admin'), new lang_string('configproxypassword', 'admin'), ''));
104 $temp->add(new admin_setting_configtext('proxybypass', new lang_string('proxybypass', 'admin'), new lang_string('configproxybypass', 'admin'), 'localhost, 127.0.0.1'));
105 $ADMIN->add('server', $temp);
107 $temp = new admin_settingpage('maintenancemode', new lang_string('sitemaintenancemode', 'admin'));
108 $options = array(0=>new lang_string('disable'), 1=>new lang_string('enable'));
109 $temp->add(new admin_setting_configselect('maintenance_enabled', new lang_string('sitemaintenancemode', 'admin'),
110                                           new lang_string('helpsitemaintenance', 'admin'), 0, $options));
111 $temp->add(new admin_setting_confightmleditor('maintenance_message', new lang_string('optionalmaintenancemessage', 'admin'),
112                                               '', ''));
113 $ADMIN->add('server', $temp);
115 $temp = new admin_settingpage('cleanup', new lang_string('cleanup', 'admin'));
116 $temp->add(new admin_setting_configselect('deleteunconfirmed', new lang_string('deleteunconfirmed', 'admin'), new lang_string('configdeleteunconfirmed', 'admin'), 168, array(0 => new lang_string('never'),
117                                                                                                                                                                     168 => new lang_string('numdays', '', 7),
118                                                                                                                                                                     144 => new lang_string('numdays', '', 6),
119                                                                                                                                                                     120 => new lang_string('numdays', '', 5),
120                                                                                                                                                                     96 => new lang_string('numdays', '', 4),
121                                                                                                                                                                     72 => new lang_string('numdays', '', 3),
122                                                                                                                                                                     48 => new lang_string('numdays', '', 2),
123                                                                                                                                                                     24 => new lang_string('numdays', '', 1),
124                                                                                                                                                                     12 => new lang_string('numhours', '', 12),
125                                                                                                                                                                     6 => new lang_string('numhours', '', 6),
126                                                                                                                                                                     1 => new lang_string('numhours', '', 1))));
128 $temp->add(new admin_setting_configselect('deleteincompleteusers', new lang_string('deleteincompleteusers', 'admin'), new lang_string('configdeleteincompleteusers', 'admin'), 0, array(0 => new lang_string('never'),
129                                                                                                                                                                     168 => new lang_string('numdays', '', 7),
130                                                                                                                                                                     144 => new lang_string('numdays', '', 6),
131                                                                                                                                                                     120 => new lang_string('numdays', '', 5),
132                                                                                                                                                                     96 => new lang_string('numdays', '', 4),
133                                                                                                                                                                     72 => new lang_string('numdays', '', 3),
134                                                                                                                                                                     48 => new lang_string('numdays', '', 2),
135                                                                                                                                                                     24 => new lang_string('numdays', '', 1))));
137 $temp->add(new admin_setting_configcheckbox('logguests', new lang_string('logguests', 'admin'),
138                                             new lang_string('logguests_help', 'admin'), 1));
139 $temp->add(new admin_setting_configselect('loglifetime', new lang_string('loglifetime', 'admin'), new lang_string('configloglifetime', 'admin'), 0, array(0 => new lang_string('neverdeletelogs'),
140                                                                                                                                                 1000 => new lang_string('numdays', '', 1000),
141                                                                                                                                                 365 => new lang_string('numdays', '', 365),
142                                                                                                                                                 180 => new lang_string('numdays', '', 180),
143                                                                                                                                                 150 => new lang_string('numdays', '', 150),
144                                                                                                                                                 120 => new lang_string('numdays', '', 120),
145                                                                                                                                                 90 => new lang_string('numdays', '', 90),
146                                                                                                                                                 60 => new lang_string('numdays', '', 60),
147                                                                                                                                                 35 => new lang_string('numdays', '', 35),
148                                                                                                                                                 10 => new lang_string('numdays', '', 10),
149                                                                                                                                                 5 => new lang_string('numdays', '', 5),
150                                                                                                                                                 2 => new lang_string('numdays', '', 2))));
153 $temp->add(new admin_setting_configcheckbox('disablegradehistory', new lang_string('disablegradehistory', 'grades'),
154                                             new lang_string('disablegradehistory_help', 'grades'), 0));
156 $temp->add(new admin_setting_configselect('gradehistorylifetime', new lang_string('gradehistorylifetime', 'grades'),
157                                           new lang_string('gradehistorylifetime_help', 'grades'), 0, array(0 => new lang_string('neverdeletehistory', 'grades'),
158                                                                                                    1000 => new lang_string('numdays', '', 1000),
159                                                                                                     365 => new lang_string('numdays', '', 365),
160                                                                                                     180 => new lang_string('numdays', '', 180),
161                                                                                                     150 => new lang_string('numdays', '', 150),
162                                                                                                     120 => new lang_string('numdays', '', 120),
163                                                                                                      90 => new lang_string('numdays', '', 90),
164                                                                                                      60 => new lang_string('numdays', '', 60),
165                                                                                                      30 => new lang_string('numdays', '', 30))));
167 $ADMIN->add('server', $temp);
171 $ADMIN->add('server', new admin_externalpage('environment', new lang_string('environment','admin'), "$CFG->wwwroot/$CFG->admin/environment.php"));
172 $ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo'), "$CFG->wwwroot/$CFG->admin/phpinfo.php"));
175 // "performance" settingpage
176 $temp = new admin_settingpage('performance', new lang_string('performance', 'admin'));
178 $temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'),
179                                           new lang_string('configextramemorylimit', 'admin'), '512M',
180                                           // if this option is set to 0, default 128M will be used
181                                           array( '64M' => '64M',
182                                                  '128M' => '128M',
183                                                  '256M' => '256M',
184                                                  '512M' => '512M',
185                                                  '1024M' => '1024M'
186                                              )));
187 $temp->add(new admin_setting_configtext('curlcache', new lang_string('curlcache', 'admin'),
188                                         new lang_string('configcurlcache', 'admin'), 120, PARAM_INT));
190 $temp->add(new admin_setting_configtext('curltimeoutkbitrate', new lang_string('curltimeoutkbitrate', 'admin'),
191                                         new lang_string('curltimeoutkbitrate_help', 'admin'), 56, PARAM_INT));
193 $ADMIN->add('server', $temp);
196 $ADMIN->add('server', new admin_externalpage('adminregistration', new lang_string('hubs', 'admin'),
197     "$CFG->wwwroot/$CFG->admin/registration/index.php"));
199 // "update notifications" settingpage
200 if (empty($CFG->disableupdatenotifications)) {
201     $temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin'));
202     $temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'),
203                                                 new lang_string('updateautocheck_desc', 'core_admin'), 1));
204     if (empty($CFG->disableupdateautodeploy)) {
205         $temp->add(new admin_setting_configcheckbox('updateautodeploy', new lang_string('updateautodeploy', 'core_admin'),
206                                                     new lang_string('updateautodeploy_desc', 'core_admin'), 0));
207     }
208     $temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'),
209                                               new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE,
210                                               array(
211                                                   MATURITY_ALPHA  => new lang_string('maturity'.MATURITY_ALPHA, 'core_admin'),
212                                                   MATURITY_BETA   => new lang_string('maturity'.MATURITY_BETA, 'core_admin'),
213                                                   MATURITY_RC     => new lang_string('maturity'.MATURITY_RC, 'core_admin'),
214                                                   MATURITY_STABLE => new lang_string('maturity'.MATURITY_STABLE, 'core_admin'),
215                                               )));
216     $temp->add(new admin_setting_configcheckbox('updatenotifybuilds', new lang_string('updatenotifybuilds', 'core_admin'),
217                                                 new lang_string('updatenotifybuilds_desc', 'core_admin'), 0));
218     $ADMIN->add('server', $temp);
221 } // end of speedup