Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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.
13
//
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/>.
16
 
17
/**
18
 * Defines settingpages and externalpages under the "server" category.
19
 *
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
24
 */
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
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);
46
 
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;
55
    }
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,
66
        [
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'),
70
        ]
71
    ));
72
    $temp->add(new admin_setting_configtext('servicespage', new lang_string('servicespage', 'admin'),
73
        new lang_string('configservicespage', 'admin'), '', PARAM_URL));
74
 
75
    $ADMIN->add('server', $temp);
76
 
77
    // Session handling.
78
    $temp = new admin_settingpage('sessionhandling', new lang_string('sessionhandling', 'admin'));
79
    if (empty($CFG->session_handler_class) and $DB->session_lock_supported()) {
80
        $temp->add(new admin_setting_configcheckbox('dbsessions', new lang_string('dbsessions', 'admin'),
81
            new lang_string('configdbsessions', 'admin'), 0));
82
    }
83
 
84
    $temp->add(new admin_setting_configduration('sessiontimeout', new lang_string('sessiontimeout', 'admin'),
85
        new lang_string('configsessiontimeout', 'admin'), 8 * 60 * 60));
86
 
87
    $sessiontimeoutwarning = new admin_setting_configduration('sessiontimeoutwarning',
88
        new lang_string('sessiontimeoutwarning', 'admin'),
89
        new lang_string('configsessiontimeoutwarning', 'admin'), 20 * 60);
90
 
91
    $sessiontimeoutwarning->set_validate_function(function(int $value): string {
92
        global $CFG;
93
        // Check sessiontimeoutwarning is less than sessiontimeout.
94
        if ($CFG->sessiontimeout <= $value) {
95
            return get_string('configsessiontimeoutwarningcheck', 'admin');
96
        } else {
97
            return '';
98
        }
99
    });
100
 
101
    $temp->add($sessiontimeoutwarning);
102
 
103
    $temp->add(new admin_setting_configtext('sessioncookie', new lang_string('sessioncookie', 'admin'),
104
        new lang_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
105
    $temp->add(new admin_setting_configtext('sessioncookiepath', new lang_string('sessioncookiepath', 'admin'),
106
        new lang_string('configsessioncookiepath', 'admin'), '', PARAM_RAW));
107
    $temp->add(new admin_setting_configtext('sessioncookiedomain', new lang_string('sessioncookiedomain', 'admin'),
108
        new lang_string('configsessioncookiedomain', 'admin'), '', PARAM_RAW, 50));
109
    $ADMIN->add('server', $temp);
110
 
111
    // Statistics.
112
    $temp = new admin_settingpage('stats', new lang_string('stats'), 'moodle/site:config', empty($CFG->enablestats));
113
    $temp->add(new admin_setting_configselect('statsfirstrun', new lang_string('statsfirstrun', 'admin'),
114
        new lang_string('configstatsfirstrun', 'admin'), 'none',
115
        [
116
            'none' => new lang_string('none'),
117
            60 * 60 * 24 * 7 => new lang_string('numweeks', 'moodle', 1),
118
            60 * 60 * 24 * 14 => new lang_string('numweeks', 'moodle', 2),
119
            60 * 60 * 24 * 21 => new lang_string('numweeks', 'moodle', 3),
120
            60 * 60 * 24 * 28 => new lang_string('nummonths', 'moodle', 1),
121
            60 * 60 * 24 * 56 => new lang_string('nummonths', 'moodle', 2),
122
            60 * 60 * 24 * 84 => new lang_string('nummonths', 'moodle', 3),
123
            60 * 60 * 24 * 112 => new lang_string('nummonths', 'moodle', 4),
124
            60 * 60 * 24 * 140 => new lang_string('nummonths', 'moodle', 5),
125
            60 * 60 * 24 * 168 => new lang_string('nummonths', 'moodle', 6),
126
            'all' => new lang_string('all')
127
        ]
128
    ));
129
    $temp->add(new admin_setting_configselect('statsmaxruntime', new lang_string('statsmaxruntime', 'admin'),
130
        new lang_string('configstatsmaxruntime3', 'admin'), 0,
131
        [
132
 
133
            60 * 30 => '10 ' . new lang_string('minutes'),
134
            60 * 30 => '30 ' . new lang_string('minutes'),
135
            60 * 60 => '1 ' . new lang_string('hour'),
136
            60 * 60 * 2 => '2 ' . new lang_string('hours'),
137
            60 * 60 * 3 => '3 ' . new lang_string('hours'),
138
            60 * 60 * 4 => '4 ' . new lang_string('hours'),
139
            60 * 60 * 5 => '5 ' . new lang_string('hours'),
140
            60 * 60 * 6 => '6 ' . new lang_string('hours'),
141
            60 * 60 * 7 => '7 ' . new lang_string('hours'),
142
            60 * 60 * 8 => '8 ' . new lang_string('hours'),
143
        ]
144
    ));
145
    $temp->add(new admin_setting_configtext('statsruntimedays', new lang_string('statsruntimedays', 'admin'),
146
        new lang_string('configstatsruntimedays', 'admin'), 31, PARAM_INT));
147
    $temp->add(new admin_setting_configtext('statsuserthreshold', new lang_string('statsuserthreshold', 'admin'),
148
        new lang_string('configstatsuserthreshold', 'admin'), 0, PARAM_INT));
149
    $ADMIN->add('server', $temp);
150
 
151
    // HTTP.
152
    $temp = new admin_settingpage('http', new lang_string('http', 'admin'));
153
    $temp->add(new admin_setting_configcheckbox('slasharguments', new lang_string('slasharguments', 'admin'),
154
        new lang_string('configslasharguments', 'admin'), 1));
155
    $temp->add(new admin_setting_heading('reverseproxy', new lang_string('reverseproxy', 'admin'), '', ''));
156
    $options = [
157
 
158
        GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
159
        GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
160
        GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR | GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR'
161
    ];
162
    $temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'),
163
        new lang_string('configgetremoteaddrconf', 'admin'),
164
        GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR | GETREMOTEADDR_SKIP_HTTP_CLIENT_IP, $options));
165
    $temp->add(new admin_setting_configtext('reverseproxyignore', new lang_string('reverseproxyignore', 'admin'),
166
        new lang_string('configreverseproxyignore', 'admin'), ''));
167
 
168
    $temp->add(new admin_setting_heading('webproxy', new lang_string('webproxy', 'admin'),
169
        new lang_string('webproxyinfo', 'admin')));
170
    $temp->add(new admin_setting_configtext('proxyhost', new lang_string('proxyhost', 'admin'),
171
        new lang_string('configproxyhost', 'admin'), '', PARAM_HOST));
172
    $temp->add(new admin_setting_configtext('proxyport', new lang_string('proxyport', 'admin'),
173
        new lang_string('configproxyport', 'admin'), 0, PARAM_INT));
174
    $options = ['HTTP' => 'HTTP'];
175
    if (defined('CURLPROXY_SOCKS5')) {
176
        $options['SOCKS5'] = 'SOCKS5';
177
    }
178
    $temp->add(new admin_setting_configselect('proxytype', new lang_string('proxytype', 'admin'),
179
        new lang_string('configproxytype', 'admin'), 'HTTP', $options));
180
    $temp->add(new admin_setting_configtext('proxyuser', new lang_string('proxyuser', 'admin'),
181
        new lang_string('configproxyuser', 'admin'), ''));
182
    $temp->add(new admin_setting_configpasswordunmask('proxypassword', new lang_string('proxypassword', 'admin'),
183
        new lang_string('configproxypassword', 'admin'), ''));
184
    $temp->add(new admin_setting_configtext('proxybypass', new lang_string('proxybypass', 'admin'),
185
        new lang_string('configproxybypass', 'admin'), 'localhost, 127.0.0.1'));
186
    $temp->add(new admin_setting_configcheckbox('proxylogunsafe', new lang_string('proxylogunsafe', 'admin'),
187
        new lang_string('configproxylogunsafe_help', 'admin'), 0));
188
    $temp->add(new admin_setting_configcheckbox('proxyfixunsafe', new lang_string('proxyfixunsafe', 'admin'),
189
        new lang_string('configproxyfixunsafe_help', 'admin'), 0));
190
 
191
    $ADMIN->add('server', $temp);
192
 
193
    $temp = new admin_settingpage('maintenancemode', new lang_string('sitemaintenancemode', 'admin'));
194
    $options = [0 => new lang_string('disable'), 1 => new lang_string('enable')];
195
    $temp->add(new admin_setting_configselect('maintenance_enabled', new lang_string('sitemaintenancemode', 'admin'),
196
        new lang_string('helpsitemaintenance', 'admin'), 0, $options));
197
    $temp->add(new admin_setting_confightmleditor('maintenance_message', new lang_string('optionalmaintenancemessage', 'admin'),
198
        '', ''));
199
    $ADMIN->add('server', $temp);
200
 
201
    // Cleanup.
202
    $temp = new admin_settingpage('cleanup', new lang_string('cleanup', 'admin'));
203
    $temp->add(new admin_setting_configselect('deleteunconfirmed', new lang_string('deleteunconfirmed', 'admin'),
204
        new lang_string('configdeleteunconfirmed', 'admin'), 168,
205
        [
206
 
207
            168 => new lang_string('numdays', '', 7),
208
            144 => new lang_string('numdays', '', 6),
209
            120 => new lang_string('numdays', '', 5),
210
            96 => new lang_string('numdays', '', 4),
211
            72 => new lang_string('numdays', '', 3),
212
            48 => new lang_string('numdays', '', 2),
213
            24 => new lang_string('numdays', '', 1),
214
            12 => new lang_string('numhours', '', 12),
215
            6 => new lang_string('numhours', '', 6),
216
            1 => new lang_string('numhours', '', 1),
217
        ]
218
    ));
219
 
220
    $temp->add(new admin_setting_configselect('deleteincompleteusers', new lang_string('deleteincompleteusers', 'admin'),
221
        new lang_string('configdeleteincompleteusers', 'admin'), 0,
222
        [
223
 
224
            168 => new lang_string('numdays', '', 7),
225
            144 => new lang_string('numdays', '', 6),
226
            120 => new lang_string('numdays', '', 5),
227
            96 => new lang_string('numdays', '', 4),
228
            72 => new lang_string('numdays', '', 3),
229
            48 => new lang_string('numdays', '', 2),
230
            24 => new lang_string('numdays', '', 1),
231
        ]
232
    ));
233
 
234
    $temp->add(new admin_setting_configcheckbox('disablegradehistory', new lang_string('disablegradehistory', 'grades'),
235
        new lang_string('disablegradehistory_help', 'grades'), 0));
236
 
237
    $temp->add(new admin_setting_configselect('gradehistorylifetime', new lang_string('gradehistorylifetime', 'grades'),
238
        new lang_string('gradehistorylifetime_help', 'grades'), 0,
239
        [
240
 
241
            1000 => new lang_string('numdays', '', 1000),
242
            365 => new lang_string('numdays', '', 365),
243
            180 => new lang_string('numdays', '', 180),
244
            150 => new lang_string('numdays', '', 150),
245
            120 => new lang_string('numdays', '', 120),
246
            90 => new lang_string('numdays', '', 90),
247
            60 => new lang_string('numdays', '', 60),
248
            30 => new lang_string('numdays', '', 30),
249
        ]
250
    ));
251
 
252
    $temp->add(new admin_setting_configselect('tempdatafoldercleanup', new lang_string('tempdatafoldercleanup', 'admin'),
253
        new lang_string('configtempdatafoldercleanup', 'admin'), 168,
254
        [
255
            1 => new lang_string('numhours', '', 1),
256
            3 => new lang_string('numhours', '', 3),
257
            6 => new lang_string('numhours', '', 6),
258
            9 => new lang_string('numhours', '', 9),
259
            12 => new lang_string('numhours', '', 12),
260
            18 => new lang_string('numhours', '', 18),
261
            24 => new lang_string('numhours', '', 24),
262
            48 => new lang_string('numdays', '', 2),
263
            168 => new lang_string('numdays', '', 7),
264
        ]
265
    ));
266
 
267
    $temp->add(new admin_setting_configduration(
268
        'xapicleanupperiod',
269
        new lang_string('xapicleanupperiod', 'xapi'),
270
        new lang_string('xapicleanupperiod_help', 'xapi'),
271
        WEEKSECS * 8,
272
        WEEKSECS
273
    ));
274
 
275
    $ADMIN->add('server', $temp);
276
 
277
    $temp->add(new admin_setting_configduration('filescleanupperiod',
278
        new lang_string('filescleanupperiod', 'admin'),
279
        new lang_string('filescleanupperiod_help', 'admin'),
280
        86400));
281
 
282
    // Environment.
283
    $ADMIN->add('server', new admin_externalpage('environment', new lang_string('environment', 'admin'),
284
        "{$CFG->wwwroot}/{$CFG->admin}/environment.php"));
285
 
286
    // PHP info.
287
    $ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo'),
288
        "{$CFG->wwwroot}/{$CFG->admin}/phpinfo.php"));
289
 
290
    // Test outgoing mail configuration (hidden, accessed via direct link from the settings page).
291
    $ADMIN->add('server', new admin_externalpage('testoutgoingmailconf', new lang_string('testoutgoingmailconf', 'admin'),
292
        new moodle_url('/admin/testoutgoingmailconf.php'), 'moodle/site:config', true));
293
 
294
    // Performance.
295
    $temp = new admin_settingpage('performance', new lang_string('performance', 'admin'));
296
 
297
    // Memory limit options for large administration tasks.
298
    $memoryoptions = [
299
        '64M' => '64M',
300
        '128M' => '128M',
301
        '256M' => '256M',
302
        '512M' => '512M',
303
        '1024M' => '1024M',
304
        '2048M' => '2048M',
305
    ];
306
 
307
    // Allow larger memory usage for 64-bit sites only.
308
    if (PHP_INT_SIZE === 8) {
309
        $memoryoptions['3072M'] = '3072M';
310
        $memoryoptions['4096M'] = '4096M';
311
    }
312
 
313
    $temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'),
314
        new lang_string('configextramemorylimit', 'admin'), '512M', $memoryoptions));
315
 
316
    $temp->add(new admin_setting_configtext('maxtimelimit', new lang_string('maxtimelimit', 'admin'),
317
        new lang_string('maxtimelimit_desc', 'admin'), 0, PARAM_INT));
318
 
319
    $temp->add(new admin_setting_configtext('curlcache', new lang_string('curlcache', 'admin'),
320
        new lang_string('configcurlcache', 'admin'), 120, PARAM_INT));
321
 
322
    $temp->add(new admin_setting_configtext('curltimeoutkbitrate', new lang_string('curltimeoutkbitrate', 'admin'),
323
        new lang_string('curltimeoutkbitrate_help', 'admin'), 56, PARAM_INT));
324
 
325
    $ADMIN->add('server', $temp);
326
 
327
    // Tasks.
328
    $ADMIN->add('server', new admin_category('taskconfig', new lang_string('taskadmintitle', 'admin')));
329
 
330
    // Task processing.
331
    $temp = new admin_settingpage('taskprocessing', new lang_string('taskprocessing', 'admin'));
332
 
333
    $setting = new admin_setting_configcheckbox(
334
        'cron_enabled',
335
        new lang_string('cron_enabled', 'admin'),
336
        new lang_string('cron_enabled_desc', 'admin'),
337
        1
338
    );
339
    $setting->set_updatedcallback('theme_reset_static_caches');
340
    $temp->add($setting);
341
 
342
    $setting = new admin_setting_configduration(
343
        'cron_keepalive',
344
        new lang_string('cron_keepalive', 'admin'),
345
        new lang_string('cron_keepalive_desc', 'admin'),
346
        \core\cron::DEFAULT_MAIN_PROCESS_KEEPALIVE,
347
        // The default unit is minutes.
348
        MINSECS,
349
    );
350
 
351
    // Set an upper limit.
352
    $setting->set_max_duration(\core\cron::MAX_MAIN_PROCESS_KEEPALIVE);
353
 
354
    $temp->add($setting);
355
 
356
    $temp->add(
357
        new admin_setting_configtext(
358
            'task_scheduled_concurrency_limit',
359
            new lang_string('task_scheduled_concurrency_limit', 'admin'),
360
            new lang_string('task_scheduled_concurrency_limit_desc', 'admin'),
361
            3,
362
            PARAM_INT
363
        )
364
    );
365
 
366
    $temp->add(
367
        new admin_setting_configduration(
368
            'task_scheduled_max_runtime',
369
            new lang_string('task_scheduled_max_runtime', 'admin'),
370
            new lang_string('task_scheduled_max_runtime_desc', 'admin'),
371
            30 * MINSECS
372
        )
373
    );
374
 
375
    $temp->add(
376
        new admin_setting_configtext(
377
            'task_adhoc_concurrency_limit',
378
            new lang_string('task_adhoc_concurrency_limit', 'admin'),
379
            new lang_string('task_adhoc_concurrency_limit_desc', 'admin'),
380
            3,
381
            PARAM_INT
382
        )
383
    );
384
 
385
    $temp->add(
386
        new admin_setting_configduration(
387
            'task_adhoc_max_runtime',
388
            new lang_string('task_adhoc_max_runtime', 'admin'),
389
            new lang_string('task_adhoc_max_runtime_desc', 'admin'),
390
            30 * MINSECS
391
        )
392
    );
393
 
394
    $temp->add(
395
        new admin_setting_configduration(
396
            'task_adhoc_failed_retention',
397
            new lang_string('task_adhoc_failed_retention', 'admin'),
398
            new lang_string('task_adhoc_failed_retention_desc', 'admin'),
399
            \core\task\manager::ADHOC_TASK_FAILED_RETENTION,
400
            WEEKSECS
401
        )
402
    );
403
 
404
    $ADMIN->add('taskconfig', $temp);
405
 
406
    // Task log configuration.
407
    $temp = new admin_settingpage('tasklogging', new lang_string('tasklogging', 'admin'));
408
    $temp->add(
409
        new admin_setting_configselect(
410
            'task_logmode',
411
            new lang_string('task_logmode', 'admin'),
412
            new lang_string('task_logmode_desc', 'admin'),
413
            \core\task\logmanager::MODE_ALL,
414
            [
415
                \core\task\logmanager::MODE_ALL => new lang_string('task_logmode_all', 'admin'),
416
                \core\task\logmanager::MODE_FAILONLY => new lang_string('task_logmode_failonly', 'admin'),
417
                \core\task\logmanager::MODE_NONE => new lang_string('task_logmode_none', 'admin'),
418
            ]
419
        )
420
    );
421
    $temp->add(
422
        new admin_setting_configcheckbox(
423
            'task_logtostdout',
424
            new lang_string('task_logtostdout', 'admin'),
425
            new lang_string('task_logtostdout_desc', 'admin'),
426
            1
427
        )
428
    );
429
 
430
    if (\core\task\logmanager::uses_standard_settings()) {
431
        $temp->add(
432
            new admin_setting_configduration(
433
                'task_logretention',
434
                new \lang_string('task_logretention', 'admin'),
435
                new \lang_string('task_logretention_desc', 'admin'),
436
                28 * DAYSECS
437
            )
438
        );
439
 
440
        $temp->add(
441
            new admin_setting_configtext(
442
                'task_logretainruns',
443
                new \lang_string('task_logretainruns', 'admin'),
444
                new \lang_string('task_logretainruns_desc', 'admin'),
445
                20,
446
                PARAM_INT
447
            )
448
        );
449
    }
450
    $ADMIN->add('taskconfig', $temp);
451
 
452
    // Task logs.
453
    if (\core\task\logmanager::uses_standard_settings()) {
454
        $ADMIN->add('taskconfig', new admin_externalpage(
455
            'tasklogs',
456
            new lang_string('tasklogs', 'admin'),
457
            "{$CFG->wwwroot}/{$CFG->admin}/tasklogs.php"
458
        ));
459
    }
460
 
461
    // Email.
462
    $ADMIN->add('server', new admin_category('email', new lang_string('categoryemail', 'admin')));
463
 
464
    // Outgoing mail configuration.
465
    $temp = new admin_settingpage('outgoingmailconfig', new lang_string('outgoingmailconfig', 'admin'));
466
 
467
    if (!empty($CFG->noemailever)) {
468
        $noemaileverwarning = new \core\output\notification(get_string('noemaileverwarning', 'admin'),
469
        \core\output\notification::NOTIFY_ERROR);
470
        $temp->add(new admin_setting_heading('outgoingmaildisabled', '', $OUTPUT->render($noemaileverwarning)));
471
    }
472
 
473
    $temp->add(new admin_setting_heading('smtpheading', new lang_string('smtp', 'admin'),
474
        new lang_string('smtpdetail', 'admin')));
475
 
476
    $temp->add(new admin_setting_configtext('smtphosts', new lang_string('smtphosts', 'admin'),
477
        new lang_string('configsmtphosts', 'admin'), '', PARAM_RAW));
478
 
479
    $options = [
480
        '' => new lang_string('none', 'admin'),
481
        'ssl' => 'SSL',
482
        'tls' => 'TLS',
483
    ];
484
 
485
    $temp->add(new admin_setting_configselect('smtpsecure', new lang_string('smtpsecure', 'admin'),
486
        new lang_string('configsmtpsecure', 'admin'), '', $options));
487
 
488
    $authtypeoptions = [
489
        'LOGIN' => 'LOGIN',
490
        'PLAIN' => 'PLAIN',
491
        'NTLM' => 'NTLM',
492
        'CRAM-MD5' => 'CRAM-MD5',
493
    ];
494
 
495
    // Get all the issuers.
496
    $issuers = \core\oauth2\api::get_all_issuers();
497
    $enabledissuers = [];
498
    foreach ($issuers as $issuer) {
499
        // Get the enabled issuer only.
500
        if ($issuer->get('enabled')) {
501
            $enabledissuers[] = $issuer;
502
        }
503
    }
504
 
505
    if (count($enabledissuers) > 0) {
506
        $authtypeoptions['XOAUTH2'] = 'XOAUTH2';
507
    }
508
 
509
    $temp->add(new admin_setting_configselect('smtpauthtype', new lang_string('smtpauthtype', 'admin'),
510
        new lang_string('configsmtpauthtype', 'admin'), 'LOGIN', $authtypeoptions));
511
 
512
    if (count($enabledissuers) > 0) {
513
        $oauth2services = [
514
            '' => new lang_string('none', 'admin'),
515
        ];
516
        foreach ($enabledissuers as $issuer) {
517
            $oauth2services[$issuer->get('id')] = s($issuer->get('name'));
518
        }
519
 
520
        $temp->add(new admin_setting_configselect('smtpoauthservice', new lang_string('issuer', 'auth_oauth2'),
521
            new lang_string('configsmtpoauthservice', 'admin'), '', $oauth2services));
522
    }
523
 
524
    $temp->add(new admin_setting_configtext('smtpuser', new lang_string('smtpuser', 'admin'),
525
        new lang_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
526
 
527
    $temp->add(new admin_setting_configpasswordunmask('smtppass', new lang_string('smtppass', 'admin'),
528
        new lang_string('configsmtpuser', 'admin'), ''));
529
 
530
    $temp->add(new admin_setting_configtext('smtpmaxbulk', new lang_string('smtpmaxbulk', 'admin'),
531
        new lang_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT));
532
 
533
    $temp->add(new admin_setting_heading('noreplydomainheading', new lang_string('noreplydomain', 'admin'),
534
        new lang_string('noreplydomaindetail', 'admin')));
535
 
536
    $default = clean_param('noreply@' . get_host_from_url($CFG->wwwroot), PARAM_EMAIL);
537
    if (!$default) {
538
        $default = null;
539
    }
540
    $temp->add(new admin_setting_configtext('noreplyaddress', new lang_string('noreplyaddress', 'admin'),
541
        new lang_string('confignoreplyaddress', 'admin'), $default, PARAM_EMAIL));
542
 
543
    $temp->add(new admin_setting_configtextarea('allowedemaildomains',
544
        new lang_string('allowedemaildomains', 'admin'),
545
        new lang_string('configallowedemaildomains', 'admin'),
546
        ''));
547
 
548
    $temp->add(new admin_setting_heading('divertallemailsheading', new lang_string('divertallemails', 'admin'),
549
        new lang_string('divertallemailsdetail', 'admin')));
550
    $temp->add(new admin_setting_configtext('divertallemailsto',
551
        new lang_string('divertallemailsto', 'admin'),
552
        new lang_string('divertallemailsto_desc', 'admin'),
553
        ''));
554
    $temp->add(new admin_setting_configtextarea('divertallemailsexcept',
555
        new lang_string('divertallemailsexcept', 'admin'),
556
        new lang_string('divertallemailsexcept_desc', 'admin'),
557
        '', PARAM_RAW, '50', '4'));
558
 
559
    $noreplyaddress = isset($CFG->noreplyaddress) ? $CFG->noreplyaddress : 'noreply@example.com';
560
    $dkimdomain = substr(strrchr($noreplyaddress, "@"), 1);
561
    $dkimselector = empty($CFG->emaildkimselector) ? '[selector]' : $CFG->emaildkimselector;
562
    $pempath = "\$CFG->dataroot/dkim/{$dkimdomain}/{$dkimselector}.private";
563
    $temp->add(new admin_setting_heading('emaildkim', new lang_string('emaildkim', 'admin'),
564
        new lang_string('emaildkiminfo', 'admin', ['path' => $pempath, 'docs' => \get_docs_url('Mail_configuration#DKIM')])));
565
    $temp->add(new admin_setting_configtext('emaildkimselector', new lang_string('emaildkimselector', 'admin'),
566
        new lang_string('configemaildkimselector', 'admin'), '', PARAM_FILE));
567
 
568
    $url = new moodle_url('/admin/testoutgoingmailconf.php');
569
    $link = html_writer::link($url, get_string('testoutgoingmailconf', 'admin'));
570
    $temp->add(new admin_setting_heading('testoutgoinmailc', new lang_string('testoutgoingmailconf', 'admin'),
571
        new lang_string('testoutgoingmaildetail', 'admin', $link)));
572
 
573
    $temp->add(new admin_setting_heading('emaildoesnotfit', new lang_string('doesnotfit', 'admin'),
574
        new lang_string('doesnotfitdetail', 'admin')));
575
 
576
    $charsets = get_list_of_charsets();
577
    unset($charsets['UTF-8']);
578
    $options = [
579
        '0' => 'UTF-8',
580
    ];
581
    $options = array_merge($options, $charsets);
582
    $temp->add(new admin_setting_configselect('sitemailcharset', new lang_string('sitemailcharset', 'admin'),
583
        new lang_string('configsitemailcharset', 'admin'), '0', $options));
584
 
585
    $temp->add(new admin_setting_configcheckbox('allowusermailcharset', new lang_string('allowusermailcharset', 'admin'),
586
        new lang_string('configallowusermailcharset', 'admin'), 0));
587
 
588
    $temp->add(new admin_setting_configcheckbox('allowattachments', new lang_string('allowattachments', 'admin'),
589
        new lang_string('configallowattachments', 'admin'), 1));
590
 
591
    $options = [
592
        'LF' => 'LF',
593
        'CRLF' => 'CRLF',
594
    ];
595
    $temp->add(new admin_setting_configselect('mailnewline', new lang_string('mailnewline', 'admin'),
596
        new lang_string('configmailnewline', 'admin'), 'LF', $options));
597
 
598
    $choices = [
599
        new lang_string('never', 'admin'),
600
        new lang_string('always', 'admin'),
601
        new lang_string('onlynoreply', 'admin'),
602
    ];
603
    $temp->add(new admin_setting_configselect('emailfromvia', new lang_string('emailfromvia', 'admin'),
604
        new lang_string('configemailfromvia', 'admin'), 1, $choices));
605
 
606
    $temp->add(new admin_setting_configtext('emailsubjectprefix', new lang_string('emailsubjectprefix', 'admin'),
607
        new lang_string('configemailsubjectprefix', 'admin'), '', PARAM_RAW));
608
 
609
    $temp->add(new admin_setting_configtextarea('emailheaders', new lang_string('emailheaders', 'admin'),
610
        new lang_string('configemailheaders', 'admin'), '', PARAM_RAW, '50', '3'));
611
 
612
    $ADMIN->add('email', $temp);
613
 
614
    // Update notifications.
615
    if (empty($CFG->disableupdatenotifications)) {
616
        $temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin'));
617
        $temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'),
618
            new lang_string('updateautocheck_desc', 'core_admin'), 1));
619
        $temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'),
620
            new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE,
621
            [
622
                MATURITY_ALPHA => new lang_string('maturity'.MATURITY_ALPHA, 'core_admin'),
623
                MATURITY_BETA => new lang_string('maturity'.MATURITY_BETA, 'core_admin'),
624
                MATURITY_RC => new lang_string('maturity'.MATURITY_RC, 'core_admin'),
625
                MATURITY_STABLE => new lang_string('maturity'.MATURITY_STABLE, 'core_admin'),
626
            ]
627
        ));
628
        $temp->add(new admin_setting_configcheckbox('updatenotifybuilds', new lang_string('updatenotifybuilds', 'core_admin'),
629
            new lang_string('updatenotifybuilds_desc', 'core_admin'), 0));
630
        $ADMIN->add('server', $temp);
631
    }
632
 
633
    // Web services.
634
    $ADMIN->add('server', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
635
 
636
    // Web services > Overview.
637
    $temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice'));
638
    $temp->add(new admin_setting_webservicesoverview());
639
    $ADMIN->add('webservicesettings', $temp);
640
 
641
    // Web services > API documentation.
642
    $ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'),
643
        "{$CFG->wwwroot}/{$CFG->admin}/webservice/documentation.php", 'moodle/site:config', false));
644
 
645
    // Web services > External services.
646
    $temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
647
 
648
    $temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'),
649
        new lang_string('servicehelpexplanation', 'webservice')));
650
 
651
    $temp->add(new admin_setting_manageexternalservices());
652
 
653
    $ADMIN->add('webservicesettings', $temp);
654
 
655
    $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', new lang_string('editaservice', 'webservice'),
656
        "{$CFG->wwwroot}/{$CFG->admin}/webservice/service.php", 'moodle/site:config', true));
657
 
658
    $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions',
659
        new lang_string('externalservicefunctions', 'webservice'), "{$CFG->wwwroot}/{$CFG->admin}/webservice/service_functions.php",
660
        'moodle/site:config', true));
661
 
662
    $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers',
663
        new lang_string('externalserviceusers', 'webservice'), "{$CFG->wwwroot}/{$CFG->admin}/webservice/service_users.php",
664
        'moodle/site:config', true));
665
 
666
    $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusersettings',
667
        new lang_string('serviceusersettings', 'webservice'), "{$CFG->wwwroot}/{$CFG->admin}/webservice/service_user_settings.php",
668
        'moodle/site:config', true));
669
 
670
    // Web services > Manage protocols.
671
    $temp = new admin_settingpage('webserviceprotocols', new lang_string('manageprotocols', 'webservice'));
672
    $temp->add(new admin_setting_managewebserviceprotocols());
673
    if (empty($CFG->enablewebservices)) {
674
        $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
675
    }
676
 
677
    // We cannot use $OUTPUT->doc_link() this early, we would lose the ability to set the page layout on all admin pages.
678
    $url = new moodle_url(get_docs_url('How_to_get_a_security_key'));
679
    $wsdoclink = html_writer::link($url, new lang_string('supplyinfo', 'webservice'), ['target' => '_blank']);
680
    $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', new lang_string('enablewsdocumentation', 'admin'),
681
        new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
682
 
683
    $ADMIN->add('webservicesettings', $temp);
684
 
685
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('webservice');
686
    core_collator::asort_objects_by_property($plugins, 'displayname');
687
    foreach ($plugins as $plugin) {
688
        /** @var \core\plugininfo\webservice $plugin */
689
        $plugin->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
690
    }
691
 
692
    // Web services > Manage tokens.
693
    $ADMIN->add('webservicesettings', new admin_externalpage('webservicetokens', new lang_string('managetokens', 'webservice'),
694
        new moodle_url('/admin/webservice/tokens.php')));
695
}