Proyectos de Subversion Moodle

Rev

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