MDL-77046 availability: validate profile field in condition.
[moodle.git] / admin / settings / server.php
blob481622b15f210db85292bf909fef64ce069f54e1
1 <?php
2 // This file is part of Moodle - https://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Defines settingpages and externalpages under the "server" category.
20 * @package core
21 * @category admin
22 * @copyright 2006 Martin Dougiamas
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') || die();
28 if ($hassiteconfig) {
29 // System paths.
30 $temp = new admin_settingpage('systempaths', new lang_string('systempaths', 'admin'));
31 $temp->add(new admin_setting_configexecutable('pathtophp', new lang_string('pathtophp', 'admin'),
32 new lang_string('configpathtophp', 'admin'), ''));
33 $temp->add(new admin_setting_configexecutable('pathtodu', new lang_string('pathtodu', 'admin'),
34 new lang_string('configpathtodu', 'admin'), ''));
35 $temp->add(new admin_setting_configexecutable('aspellpath', new lang_string('aspellpath', 'admin'),
36 new lang_string('edhelpaspellpath'), ''));
37 $temp->add(new admin_setting_configexecutable('pathtodot', new lang_string('pathtodot', 'admin'),
38 new lang_string('pathtodot_help', 'admin'), ''));
39 $temp->add(new admin_setting_configexecutable('pathtogs', new lang_string('pathtogs', 'admin'),
40 new lang_string('pathtogs_help', 'admin'), '/usr/bin/gs'));
41 $temp->add(new admin_setting_configexecutable('pathtopdftoppm', new lang_string('pathtopdftoppm', 'admin'),
42 new lang_string('pathtopdftoppm_help', 'admin'), ''));
43 $temp->add(new admin_setting_configexecutable('pathtopython', new lang_string('pathtopython', 'admin'),
44 new lang_string('pathtopythondesc', 'admin'), ''));
45 $ADMIN->add('server', $temp);
47 // Support contact.
48 $temp = new admin_settingpage('supportcontact', new lang_string('supportcontact', 'admin'));
49 $primaryadmin = get_admin();
50 if ($primaryadmin) {
51 $primaryadminname = fullname($primaryadmin, true);
52 } else {
53 // No defaults during installation - admin user must be created first.
54 $primaryadminname = null;
56 $temp->add(new admin_setting_configtext('supportname', new lang_string('supportname', 'admin'),
57 new lang_string('configsupportname', 'admin'), $primaryadminname, PARAM_NOTAGS));
58 $setting = new admin_setting_requiredtext('supportemail', new lang_string('supportemail', 'admin'),
59 new lang_string('configsupportemail', 'admin'), null, PARAM_EMAIL);
60 $setting->set_force_ltr(true);
61 $temp->add($setting);
62 $temp->add(new admin_setting_configtext('supportpage', new lang_string('supportpage', 'admin'),
63 new lang_string('configsupportpage', 'admin'), '', PARAM_URL));
64 $temp->add(new admin_setting_configselect('supportavailability', new lang_string('supportavailability', 'admin'),
65 new lang_string('configsupportavailability', 'admin'), CONTACT_SUPPORT_AUTHENTICATED,
67 CONTACT_SUPPORT_ANYONE => new lang_string('availabletoanyone', 'admin'),
68 CONTACT_SUPPORT_AUTHENTICATED => new lang_string('availabletoauthenticated', 'admin'),
69 CONTACT_SUPPORT_DISABLED => new lang_string('disabled', 'admin'),
71 ));
74 $ADMIN->add('server', $temp);
76 // Session handling.
77 $temp = new admin_settingpage('sessionhandling', new lang_string('sessionhandling', 'admin'));
78 if (empty($CFG->session_handler_class) and $DB->session_lock_supported()) {
79 $temp->add(new admin_setting_configcheckbox('dbsessions', new lang_string('dbsessions', 'admin'),
80 new lang_string('configdbsessions', 'admin'), 0));
83 $temp->add(new admin_setting_configduration('sessiontimeout', new lang_string('sessiontimeout', 'admin'),
84 new lang_string('configsessiontimeout', 'admin'), 8 * 60 * 60));
86 $sessiontimeoutwarning = new admin_setting_configduration('sessiontimeoutwarning',
87 new lang_string('sessiontimeoutwarning', 'admin'),
88 new lang_string('configsessiontimeoutwarning', 'admin'), 20 * 60);
90 $sessiontimeoutwarning->set_validate_function(function(int $value): string {
91 global $CFG;
92 // Check sessiontimeoutwarning is less than sessiontimeout.
93 if ($CFG->sessiontimeout <= $value) {
94 return get_string('configsessiontimeoutwarningcheck', 'admin');
95 } else {
96 return '';
98 });
100 $temp->add($sessiontimeoutwarning);
102 $temp->add(new admin_setting_configtext('sessioncookie', new lang_string('sessioncookie', 'admin'),
103 new lang_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
104 $temp->add(new admin_setting_configtext('sessioncookiepath', new lang_string('sessioncookiepath', 'admin'),
105 new lang_string('configsessioncookiepath', 'admin'), '', PARAM_RAW));
106 $temp->add(new admin_setting_configtext('sessioncookiedomain', new lang_string('sessioncookiedomain', 'admin'),
107 new lang_string('configsessioncookiedomain', 'admin'), '', PARAM_RAW, 50));
108 $ADMIN->add('server', $temp);
110 // Statistics.
111 $temp = new admin_settingpage('stats', new lang_string('stats'), 'moodle/site:config', empty($CFG->enablestats));
112 $temp->add(new admin_setting_configselect('statsfirstrun', new lang_string('statsfirstrun', 'admin'),
113 new lang_string('configstatsfirstrun', 'admin'), 'none',
115 'none' => new lang_string('none'),
116 60 * 60 * 24 * 7 => new lang_string('numweeks', 'moodle', 1),
117 60 * 60 * 24 * 14 => new lang_string('numweeks', 'moodle', 2),
118 60 * 60 * 24 * 21 => new lang_string('numweeks', 'moodle', 3),
119 60 * 60 * 24 * 28 => new lang_string('nummonths', 'moodle', 1),
120 60 * 60 * 24 * 56 => new lang_string('nummonths', 'moodle', 2),
121 60 * 60 * 24 * 84 => new lang_string('nummonths', 'moodle', 3),
122 60 * 60 * 24 * 112 => new lang_string('nummonths', 'moodle', 4),
123 60 * 60 * 24 * 140 => new lang_string('nummonths', 'moodle', 5),
124 60 * 60 * 24 * 168 => new lang_string('nummonths', 'moodle', 6),
125 'all' => new lang_string('all')
128 $temp->add(new admin_setting_configselect('statsmaxruntime', new lang_string('statsmaxruntime', 'admin'),
129 new lang_string('configstatsmaxruntime3', 'admin'), 0,
131 0 => new lang_string('untilcomplete'),
132 60 * 30 => '10 ' . new lang_string('minutes'),
133 60 * 30 => '30 ' . new lang_string('minutes'),
134 60 * 60 => '1 ' . new lang_string('hour'),
135 60 * 60 * 2 => '2 ' . new lang_string('hours'),
136 60 * 60 * 3 => '3 ' . new lang_string('hours'),
137 60 * 60 * 4 => '4 ' . new lang_string('hours'),
138 60 * 60 * 5 => '5 ' . new lang_string('hours'),
139 60 * 60 * 6 => '6 ' . new lang_string('hours'),
140 60 * 60 * 7 => '7 ' . new lang_string('hours'),
141 60 * 60 * 8 => '8 ' . new lang_string('hours'),
144 $temp->add(new admin_setting_configtext('statsruntimedays', new lang_string('statsruntimedays', 'admin'),
145 new lang_string('configstatsruntimedays', 'admin'), 31, PARAM_INT));
146 $temp->add(new admin_setting_configtext('statsuserthreshold', new lang_string('statsuserthreshold', 'admin'),
147 new lang_string('configstatsuserthreshold', 'admin'), 0, PARAM_INT));
148 $ADMIN->add('server', $temp);
150 // HTTP.
151 $temp = new admin_settingpage('http', new lang_string('http', 'admin'));
152 $temp->add(new admin_setting_configcheckbox('slasharguments', new lang_string('slasharguments', 'admin'),
153 new lang_string('configslasharguments', 'admin'), 1));
154 $temp->add(new admin_setting_heading('reverseproxy', new lang_string('reverseproxy', 'admin'), '', ''));
155 $options = [
156 0 => 'HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
157 GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
158 GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
159 GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR | GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR'
161 $temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'),
162 new lang_string('configgetremoteaddrconf', 'admin'),
163 GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR | GETREMOTEADDR_SKIP_HTTP_CLIENT_IP, $options));
164 $temp->add(new admin_setting_configtext('reverseproxyignore', new lang_string('reverseproxyignore', 'admin'),
165 new lang_string('configreverseproxyignore', 'admin'), ''));
167 $temp->add(new admin_setting_heading('webproxy', new lang_string('webproxy', 'admin'),
168 new lang_string('webproxyinfo', 'admin')));
169 $temp->add(new admin_setting_configtext('proxyhost', new lang_string('proxyhost', 'admin'),
170 new lang_string('configproxyhost', 'admin'), '', PARAM_HOST));
171 $temp->add(new admin_setting_configtext('proxyport', new lang_string('proxyport', 'admin'),
172 new lang_string('configproxyport', 'admin'), 0, PARAM_INT));
173 $options = ['HTTP' => 'HTTP'];
174 if (defined('CURLPROXY_SOCKS5')) {
175 $options['SOCKS5'] = 'SOCKS5';
177 $temp->add(new admin_setting_configselect('proxytype', new lang_string('proxytype', 'admin'),
178 new lang_string('configproxytype', 'admin'), 'HTTP', $options));
179 $temp->add(new admin_setting_configtext('proxyuser', new lang_string('proxyuser', 'admin'),
180 new lang_string('configproxyuser', 'admin'), ''));
181 $temp->add(new admin_setting_configpasswordunmask('proxypassword', new lang_string('proxypassword', 'admin'),
182 new lang_string('configproxypassword', 'admin'), ''));
183 $temp->add(new admin_setting_configtext('proxybypass', new lang_string('proxybypass', 'admin'),
184 new lang_string('configproxybypass', 'admin'), 'localhost, 127.0.0.1'));
185 $temp->add(new admin_setting_configcheckbox('proxylogunsafe', new lang_string('proxylogunsafe', 'admin'),
186 new lang_string('configproxylogunsafe_help', 'admin'), 0));
187 $temp->add(new admin_setting_configcheckbox('proxyfixunsafe', new lang_string('proxyfixunsafe', 'admin'),
188 new lang_string('configproxyfixunsafe_help', 'admin'), 0));
190 $ADMIN->add('server', $temp);
192 $temp = new admin_settingpage('maintenancemode', new lang_string('sitemaintenancemode', 'admin'));
193 $options = [0 => new lang_string('disable'), 1 => new lang_string('enable')];
194 $temp->add(new admin_setting_configselect('maintenance_enabled', new lang_string('sitemaintenancemode', 'admin'),
195 new lang_string('helpsitemaintenance', 'admin'), 0, $options));
196 $temp->add(new admin_setting_confightmleditor('maintenance_message', new lang_string('optionalmaintenancemessage', 'admin'),
197 '', ''));
198 $ADMIN->add('server', $temp);
200 // Cleanup.
201 $temp = new admin_settingpage('cleanup', new lang_string('cleanup', 'admin'));
202 $temp->add(new admin_setting_configselect('deleteunconfirmed', new lang_string('deleteunconfirmed', 'admin'),
203 new lang_string('configdeleteunconfirmed', 'admin'), 168,
205 0 => new lang_string('never'),
206 168 => new lang_string('numdays', '', 7),
207 144 => new lang_string('numdays', '', 6),
208 120 => new lang_string('numdays', '', 5),
209 96 => new lang_string('numdays', '', 4),
210 72 => new lang_string('numdays', '', 3),
211 48 => new lang_string('numdays', '', 2),
212 24 => new lang_string('numdays', '', 1),
213 12 => new lang_string('numhours', '', 12),
214 6 => new lang_string('numhours', '', 6),
215 1 => new lang_string('numhours', '', 1),
219 $temp->add(new admin_setting_configselect('deleteincompleteusers', new lang_string('deleteincompleteusers', 'admin'),
220 new lang_string('configdeleteincompleteusers', 'admin'), 0,
222 0 => new lang_string('never'),
223 168 => new lang_string('numdays', '', 7),
224 144 => new lang_string('numdays', '', 6),
225 120 => new lang_string('numdays', '', 5),
226 96 => new lang_string('numdays', '', 4),
227 72 => new lang_string('numdays', '', 3),
228 48 => new lang_string('numdays', '', 2),
229 24 => new lang_string('numdays', '', 1),
233 $temp->add(new admin_setting_configcheckbox('disablegradehistory', new lang_string('disablegradehistory', 'grades'),
234 new lang_string('disablegradehistory_help', 'grades'), 0));
236 $temp->add(new admin_setting_configselect('gradehistorylifetime', new lang_string('gradehistorylifetime', 'grades'),
237 new lang_string('gradehistorylifetime_help', 'grades'), 0,
239 0 => new lang_string('neverdeletehistory', 'grades'),
240 1000 => new lang_string('numdays', '', 1000),
241 365 => new lang_string('numdays', '', 365),
242 180 => new lang_string('numdays', '', 180),
243 150 => new lang_string('numdays', '', 150),
244 120 => new lang_string('numdays', '', 120),
245 90 => new lang_string('numdays', '', 90),
246 60 => new lang_string('numdays', '', 60),
247 30 => new lang_string('numdays', '', 30),
251 $temp->add(new admin_setting_configselect('tempdatafoldercleanup', new lang_string('tempdatafoldercleanup', 'admin'),
252 new lang_string('configtempdatafoldercleanup', 'admin'), 168,
254 1 => new lang_string('numhours', '', 1),
255 3 => new lang_string('numhours', '', 3),
256 6 => new lang_string('numhours', '', 6),
257 9 => new lang_string('numhours', '', 9),
258 12 => new lang_string('numhours', '', 12),
259 18 => new lang_string('numhours', '', 18),
260 24 => new lang_string('numhours', '', 24),
261 48 => new lang_string('numdays', '', 2),
262 168 => new lang_string('numdays', '', 7),
266 $ADMIN->add('server', $temp);
268 $temp->add(new admin_setting_configduration('filescleanupperiod',
269 new lang_string('filescleanupperiod', 'admin'),
270 new lang_string('filescleanupperiod_help', 'admin'),
271 86400));
273 // Environment.
274 $ADMIN->add('server', new admin_externalpage('environment', new lang_string('environment', 'admin'),
275 "{$CFG->wwwroot}/{$CFG->admin}/environment.php"));
277 // PHP info.
278 $ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo'),
279 "{$CFG->wwwroot}/{$CFG->admin}/phpinfo.php"));
281 // Test outgoing mail configuration (hidden, accessed via direct link from the settings page).
282 $ADMIN->add('server', new admin_externalpage('testoutgoingmailconf', new lang_string('testoutgoingmailconf', 'admin'),
283 new moodle_url('/admin/testoutgoingmailconf.php'), 'moodle/site:config', true));
285 // Performance.
286 $temp = new admin_settingpage('performance', new lang_string('performance', 'admin'));
288 // Memory limit options for large administration tasks.
289 $memoryoptions = [
290 '64M' => '64M',
291 '128M' => '128M',
292 '256M' => '256M',
293 '512M' => '512M',
294 '1024M' => '1024M',
295 '2048M' => '2048M',
298 // Allow larger memory usage for 64-bit sites only.
299 if (PHP_INT_SIZE === 8) {
300 $memoryoptions['3072M'] = '3072M';
301 $memoryoptions['4096M'] = '4096M';
304 $temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'),
305 new lang_string('configextramemorylimit', 'admin'), '512M', $memoryoptions));
307 $temp->add(new admin_setting_configtext('maxtimelimit', new lang_string('maxtimelimit', 'admin'),
308 new lang_string('maxtimelimit_desc', 'admin'), 0, PARAM_INT));
310 $temp->add(new admin_setting_configtext('curlcache', new lang_string('curlcache', 'admin'),
311 new lang_string('configcurlcache', 'admin'), 120, PARAM_INT));
313 $temp->add(new admin_setting_configtext('curltimeoutkbitrate', new lang_string('curltimeoutkbitrate', 'admin'),
314 new lang_string('curltimeoutkbitrate_help', 'admin'), 56, PARAM_INT));
316 $ADMIN->add('server', $temp);
318 // Tasks.
319 $ADMIN->add('server', new admin_category('taskconfig', new lang_string('taskadmintitle', 'admin')));
321 // Task processing.
322 $temp = new admin_settingpage('taskprocessing', new lang_string('taskprocessing', 'admin'));
324 $setting = new admin_setting_configcheckbox(
325 'cron_enabled',
326 new lang_string('cron_enabled', 'admin'),
327 new lang_string('cron_enabled_desc', 'admin'),
330 $setting->set_updatedcallback('theme_reset_static_caches');
331 $temp->add($setting);
333 $temp->add(
334 new admin_setting_configtext(
335 'task_scheduled_concurrency_limit',
336 new lang_string('task_scheduled_concurrency_limit', 'admin'),
337 new lang_string('task_scheduled_concurrency_limit_desc', 'admin'),
339 PARAM_INT
343 $temp->add(
344 new admin_setting_configduration(
345 'task_scheduled_max_runtime',
346 new lang_string('task_scheduled_max_runtime', 'admin'),
347 new lang_string('task_scheduled_max_runtime_desc', 'admin'),
348 30 * MINSECS
352 $temp->add(
353 new admin_setting_configtext(
354 'task_adhoc_concurrency_limit',
355 new lang_string('task_adhoc_concurrency_limit', 'admin'),
356 new lang_string('task_adhoc_concurrency_limit_desc', 'admin'),
358 PARAM_INT
362 $temp->add(
363 new admin_setting_configduration(
364 'task_adhoc_max_runtime',
365 new lang_string('task_adhoc_max_runtime', 'admin'),
366 new lang_string('task_adhoc_max_runtime_desc', 'admin'),
367 30 * MINSECS
370 $ADMIN->add('taskconfig', $temp);
372 // Task log configuration.
373 $temp = new admin_settingpage('tasklogging', new lang_string('tasklogging', 'admin'));
374 $temp->add(
375 new admin_setting_configselect(
376 'task_logmode',
377 new lang_string('task_logmode', 'admin'),
378 new lang_string('task_logmode_desc', 'admin'),
379 \core\task\logmanager::MODE_ALL,
381 \core\task\logmanager::MODE_ALL => new lang_string('task_logmode_all', 'admin'),
382 \core\task\logmanager::MODE_FAILONLY => new lang_string('task_logmode_failonly', 'admin'),
383 \core\task\logmanager::MODE_NONE => new lang_string('task_logmode_none', 'admin'),
387 $temp->add(
388 new admin_setting_configcheckbox(
389 'task_logtostdout',
390 new lang_string('task_logtostdout', 'admin'),
391 new lang_string('task_logtostdout_desc', 'admin'),
396 if (\core\task\logmanager::uses_standard_settings()) {
397 $temp->add(
398 new admin_setting_configduration(
399 'task_logretention',
400 new \lang_string('task_logretention', 'admin'),
401 new \lang_string('task_logretention_desc', 'admin'),
402 28 * DAYSECS
406 $temp->add(
407 new admin_setting_configtext(
408 'task_logretainruns',
409 new \lang_string('task_logretainruns', 'admin'),
410 new \lang_string('task_logretainruns_desc', 'admin'),
412 PARAM_INT
416 $ADMIN->add('taskconfig', $temp);
418 // Task logs.
419 if (\core\task\logmanager::uses_standard_settings()) {
420 $ADMIN->add('taskconfig', new admin_externalpage(
421 'tasklogs',
422 new lang_string('tasklogs', 'admin'),
423 "{$CFG->wwwroot}/{$CFG->admin}/tasklogs.php"
427 // Email.
428 $ADMIN->add('server', new admin_category('email', new lang_string('categoryemail', 'admin')));
430 // Outgoing mail configuration.
431 $temp = new admin_settingpage('outgoingmailconfig', new lang_string('outgoingmailconfig', 'admin'));
433 $temp->add(new admin_setting_heading('smtpheading', new lang_string('smtp', 'admin'),
434 new lang_string('smtpdetail', 'admin')));
436 $temp->add(new admin_setting_configtext('smtphosts', new lang_string('smtphosts', 'admin'),
437 new lang_string('configsmtphosts', 'admin'), '', PARAM_RAW));
439 $options = [
440 '' => new lang_string('none', 'admin'),
441 'ssl' => 'SSL',
442 'tls' => 'TLS',
445 $temp->add(new admin_setting_configselect('smtpsecure', new lang_string('smtpsecure', 'admin'),
446 new lang_string('configsmtpsecure', 'admin'), '', $options));
448 $authtypeoptions = [
449 'LOGIN' => 'LOGIN',
450 'PLAIN' => 'PLAIN',
451 'NTLM' => 'NTLM',
452 'CRAM-MD5' => 'CRAM-MD5',
455 // Get all the issuers.
456 $issuers = \core\oauth2\api::get_all_issuers();
457 $enabledissuers = [];
458 foreach ($issuers as $issuer) {
459 // Get the enabled issuer only.
460 if ($issuer->get('enabled')) {
461 $enabledissuers[] = $issuer;
465 if (count($enabledissuers) > 0) {
466 $authtypeoptions['XOAUTH2'] = 'XOAUTH2';
469 $temp->add(new admin_setting_configselect('smtpauthtype', new lang_string('smtpauthtype', 'admin'),
470 new lang_string('configsmtpauthtype', 'admin'), 'LOGIN', $authtypeoptions));
472 if (count($enabledissuers) > 0) {
473 $oauth2services = [
474 '' => new lang_string('none', 'admin'),
476 foreach ($enabledissuers as $issuer) {
477 $oauth2services[$issuer->get('id')] = s($issuer->get('name'));
480 $temp->add(new admin_setting_configselect('smtpoauthservice', new lang_string('issuer', 'auth_oauth2'),
481 new lang_string('configsmtpoauthservice', 'admin'), '', $oauth2services));
484 $temp->add(new admin_setting_configtext('smtpuser', new lang_string('smtpuser', 'admin'),
485 new lang_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
487 $temp->add(new admin_setting_configpasswordunmask('smtppass', new lang_string('smtppass', 'admin'),
488 new lang_string('configsmtpuser', 'admin'), ''));
490 $temp->add(new admin_setting_configtext('smtpmaxbulk', new lang_string('smtpmaxbulk', 'admin'),
491 new lang_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT));
493 $temp->add(new admin_setting_heading('noreplydomainheading', new lang_string('noreplydomain', 'admin'),
494 new lang_string('noreplydomaindetail', 'admin')));
496 $temp->add(new admin_setting_configtext('noreplyaddress', new lang_string('noreplyaddress', 'admin'),
497 new lang_string('confignoreplyaddress', 'admin'), 'noreply@' . get_host_from_url($CFG->wwwroot), PARAM_EMAIL));
499 $temp->add(new admin_setting_configtextarea('allowedemaildomains',
500 new lang_string('allowedemaildomains', 'admin'),
501 new lang_string('configallowedemaildomains', 'admin'),
502 ''));
504 $temp->add(new admin_setting_heading('divertallemailsheading', new lang_string('divertallemails', 'admin'),
505 new lang_string('divertallemailsdetail', 'admin')));
506 $temp->add(new admin_setting_configtext('divertallemailsto',
507 new lang_string('divertallemailsto', 'admin'),
508 new lang_string('divertallemailsto_desc', 'admin'),
509 ''));
510 $temp->add(new admin_setting_configtextarea('divertallemailsexcept',
511 new lang_string('divertallemailsexcept', 'admin'),
512 new lang_string('divertallemailsexcept_desc', 'admin'),
513 '', PARAM_RAW, '50', '4'));
515 $noreplyaddress = isset($CFG->noreplyaddress) ? $CFG->noreplyaddress : 'noreply@example.com';
516 $dkimdomain = substr(strrchr($noreplyaddress, "@"), 1);
517 $dkimselector = empty($CFG->emaildkimselector) ? '[selector]' : $CFG->emaildkimselector;
518 $pempath = "\$CFG->dataroot/dkim/{$dkimdomain}/{$dkimselector}.private";
519 $temp->add(new admin_setting_heading('emaildkim', new lang_string('emaildkim', 'admin'),
520 new lang_string('emaildkiminfo', 'admin', ['path' => $pempath, 'docs' => \get_docs_url('Mail_configuration#DKIM')])));
521 $temp->add(new admin_setting_configtext('emaildkimselector', new lang_string('emaildkimselector', 'admin'),
522 new lang_string('configemaildkimselector', 'admin'), '', PARAM_FILE));
524 $url = new moodle_url('/admin/testoutgoingmailconf.php');
525 $link = html_writer::link($url, get_string('testoutgoingmailconf', 'admin'));
526 $temp->add(new admin_setting_heading('testoutgoinmailc', new lang_string('testoutgoingmailconf', 'admin'),
527 new lang_string('testoutgoingmaildetail', 'admin', $link)));
529 $temp->add(new admin_setting_heading('emaildoesnotfit', new lang_string('doesnotfit', 'admin'),
530 new lang_string('doesnotfitdetail', 'admin')));
532 $charsets = get_list_of_charsets();
533 unset($charsets['UTF-8']);
534 $options = [
535 '0' => 'UTF-8',
537 $options = array_merge($options, $charsets);
538 $temp->add(new admin_setting_configselect('sitemailcharset', new lang_string('sitemailcharset', 'admin'),
539 new lang_string('configsitemailcharset', 'admin'), '0', $options));
541 $temp->add(new admin_setting_configcheckbox('allowusermailcharset', new lang_string('allowusermailcharset', 'admin'),
542 new lang_string('configallowusermailcharset', 'admin'), 0));
544 $temp->add(new admin_setting_configcheckbox('allowattachments', new lang_string('allowattachments', 'admin'),
545 new lang_string('configallowattachments', 'admin'), 1));
547 $options = [
548 'LF' => 'LF',
549 'CRLF' => 'CRLF',
551 $temp->add(new admin_setting_configselect('mailnewline', new lang_string('mailnewline', 'admin'),
552 new lang_string('configmailnewline', 'admin'), 'LF', $options));
554 $choices = [
555 new lang_string('never', 'admin'),
556 new lang_string('always', 'admin'),
557 new lang_string('onlynoreply', 'admin'),
559 $temp->add(new admin_setting_configselect('emailfromvia', new lang_string('emailfromvia', 'admin'),
560 new lang_string('configemailfromvia', 'admin'), 1, $choices));
562 $temp->add(new admin_setting_configtext('emailsubjectprefix', new lang_string('emailsubjectprefix', 'admin'),
563 new lang_string('configemailsubjectprefix', 'admin'), '', PARAM_RAW));
565 $temp->add(new admin_setting_configtextarea('emailheaders', new lang_string('emailheaders', 'admin'),
566 new lang_string('configemailheaders', 'admin'), '', PARAM_RAW, '50', '3'));
568 $ADMIN->add('email', $temp);
570 // Update notifications.
571 if (empty($CFG->disableupdatenotifications)) {
572 $temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin'));
573 $temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'),
574 new lang_string('updateautocheck_desc', 'core_admin'), 1));
575 $temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'),
576 new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE,
578 MATURITY_ALPHA => new lang_string('maturity'.MATURITY_ALPHA, 'core_admin'),
579 MATURITY_BETA => new lang_string('maturity'.MATURITY_BETA, 'core_admin'),
580 MATURITY_RC => new lang_string('maturity'.MATURITY_RC, 'core_admin'),
581 MATURITY_STABLE => new lang_string('maturity'.MATURITY_STABLE, 'core_admin'),
584 $temp->add(new admin_setting_configcheckbox('updatenotifybuilds', new lang_string('updatenotifybuilds', 'core_admin'),
585 new lang_string('updatenotifybuilds_desc', 'core_admin'), 0));
586 $ADMIN->add('server', $temp);
589 // Web services.
590 $ADMIN->add('server', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
592 // Web services > Overview.
593 $temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice'));
594 $temp->add(new admin_setting_webservicesoverview());
595 $ADMIN->add('webservicesettings', $temp);
597 // Web services > API documentation.
598 $ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'),
599 "{$CFG->wwwroot}/{$CFG->admin}/webservice/documentation.php", 'moodle/site:config', false));
601 // Web services > External services.
602 $temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
604 $temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'),
605 new lang_string('servicehelpexplanation', 'webservice')));
607 $temp->add(new admin_setting_manageexternalservices());
609 $ADMIN->add('webservicesettings', $temp);
611 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', new lang_string('editaservice', 'webservice'),
612 "{$CFG->wwwroot}/{$CFG->admin}/webservice/service.php", 'moodle/site:config', true));
614 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions',
615 new lang_string('externalservicefunctions', 'webservice'), "{$CFG->wwwroot}/{$CFG->admin}/webservice/service_functions.php",
616 'moodle/site:config', true));
618 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers',
619 new lang_string('externalserviceusers', 'webservice'), "{$CFG->wwwroot}/{$CFG->admin}/webservice/service_users.php",
620 'moodle/site:config', true));
622 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusersettings',
623 new lang_string('serviceusersettings', 'webservice'), "{$CFG->wwwroot}/{$CFG->admin}/webservice/service_user_settings.php",
624 'moodle/site:config', true));
626 // Web services > Manage protocols.
627 $temp = new admin_settingpage('webserviceprotocols', new lang_string('manageprotocols', 'webservice'));
628 $temp->add(new admin_setting_managewebserviceprotocols());
629 if (empty($CFG->enablewebservices)) {
630 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
633 // We cannot use $OUTPUT->doc_link() this early, we would lose the ability to set the page layout on all admin pages.
634 $url = new moodle_url(get_docs_url('How_to_get_a_security_key'));
635 $wsdoclink = html_writer::link($url, new lang_string('supplyinfo', 'webservice'), ['target' => '_blank']);
636 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', new lang_string('enablewsdocumentation', 'admin'),
637 new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
639 $ADMIN->add('webservicesettings', $temp);
641 $plugins = core_plugin_manager::instance()->get_plugins_of_type('webservice');
642 core_collator::asort_objects_by_property($plugins, 'displayname');
643 foreach ($plugins as $plugin) {
644 /** @var \core\plugininfo\webservice $plugin */
645 $plugin->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
648 // Web services > Manage tokens.
649 $ADMIN->add('webservicesettings', new admin_externalpage('webservicetokens', new lang_string('managetokens', 'webservice'),
650 new moodle_url('/admin/webservice/tokens.php')));