Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]
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 0 => new lang_string('untilcomplete'), 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 0 => 'HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR', 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 0 => new lang_string('never'), 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 0 => new lang_string('never'), 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 0 => new lang_string('neverdeletehistory', 'grades'), 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 $ADMIN->add('taskconfig', $temp); 394 395 // Task log configuration. 396 $temp = new admin_settingpage('tasklogging', new lang_string('tasklogging', 'admin')); 397 $temp->add( 398 new admin_setting_configselect( 399 'task_logmode', 400 new lang_string('task_logmode', 'admin'), 401 new lang_string('task_logmode_desc', 'admin'), 402 \core\task\logmanager::MODE_ALL, 403 [ 404 \core\task\logmanager::MODE_ALL => new lang_string('task_logmode_all', 'admin'), 405 \core\task\logmanager::MODE_FAILONLY => new lang_string('task_logmode_failonly', 'admin'), 406 \core\task\logmanager::MODE_NONE => new lang_string('task_logmode_none', 'admin'), 407 ] 408 ) 409 ); 410 $temp->add( 411 new admin_setting_configcheckbox( 412 'task_logtostdout', 413 new lang_string('task_logtostdout', 'admin'), 414 new lang_string('task_logtostdout_desc', 'admin'), 415 1 416 ) 417 ); 418 419 if (\core\task\logmanager::uses_standard_settings()) { 420 $temp->add( 421 new admin_setting_configduration( 422 'task_logretention', 423 new \lang_string('task_logretention', 'admin'), 424 new \lang_string('task_logretention_desc', 'admin'), 425 28 * DAYSECS 426 ) 427 ); 428 429 $temp->add( 430 new admin_setting_configtext( 431 'task_logretainruns', 432 new \lang_string('task_logretainruns', 'admin'), 433 new \lang_string('task_logretainruns_desc', 'admin'), 434 20, 435 PARAM_INT 436 ) 437 ); 438 } 439 $ADMIN->add('taskconfig', $temp); 440 441 // Task logs. 442 if (\core\task\logmanager::uses_standard_settings()) { 443 $ADMIN->add('taskconfig', new admin_externalpage( 444 'tasklogs', 445 new lang_string('tasklogs', 'admin'), 446 "{$CFG->wwwroot}/{$CFG->admin}/tasklogs.php" 447 )); 448 } 449 450 // Email. 451 $ADMIN->add('server', new admin_category('email', new lang_string('categoryemail', 'admin'))); 452 453 // Outgoing mail configuration. 454 $temp = new admin_settingpage('outgoingmailconfig', new lang_string('outgoingmailconfig', 'admin')); 455 456 if (!empty($CFG->noemailever)) { 457 $noemaileverwarning = new \core\output\notification(get_string('noemaileverwarning', 'admin'), 458 \core\output\notification::NOTIFY_ERROR); 459 $temp->add(new admin_setting_heading('outgoingmaildisabled', '', $OUTPUT->render($noemaileverwarning))); 460 } 461 462 $temp->add(new admin_setting_heading('smtpheading', new lang_string('smtp', 'admin'), 463 new lang_string('smtpdetail', 'admin'))); 464 465 $temp->add(new admin_setting_configtext('smtphosts', new lang_string('smtphosts', 'admin'), 466 new lang_string('configsmtphosts', 'admin'), '', PARAM_RAW)); 467 468 $options = [ 469 '' => new lang_string('none', 'admin'), 470 'ssl' => 'SSL', 471 'tls' => 'TLS', 472 ]; 473 474 $temp->add(new admin_setting_configselect('smtpsecure', new lang_string('smtpsecure', 'admin'), 475 new lang_string('configsmtpsecure', 'admin'), '', $options)); 476 477 $authtypeoptions = [ 478 'LOGIN' => 'LOGIN', 479 'PLAIN' => 'PLAIN', 480 'NTLM' => 'NTLM', 481 'CRAM-MD5' => 'CRAM-MD5', 482 ]; 483 484 // Get all the issuers. 485 $issuers = \core\oauth2\api::get_all_issuers(); 486 $enabledissuers = []; 487 foreach ($issuers as $issuer) { 488 // Get the enabled issuer only. 489 if ($issuer->get('enabled')) { 490 $enabledissuers[] = $issuer; 491 } 492 } 493 494 if (count($enabledissuers) > 0) { 495 $authtypeoptions['XOAUTH2'] = 'XOAUTH2'; 496 } 497 498 $temp->add(new admin_setting_configselect('smtpauthtype', new lang_string('smtpauthtype', 'admin'), 499 new lang_string('configsmtpauthtype', 'admin'), 'LOGIN', $authtypeoptions)); 500 501 if (count($enabledissuers) > 0) { 502 $oauth2services = [ 503 '' => new lang_string('none', 'admin'), 504 ]; 505 foreach ($enabledissuers as $issuer) { 506 $oauth2services[$issuer->get('id')] = s($issuer->get('name')); 507 } 508 509 $temp->add(new admin_setting_configselect('smtpoauthservice', new lang_string('issuer', 'auth_oauth2'), 510 new lang_string('configsmtpoauthservice', 'admin'), '', $oauth2services)); 511 } 512 513 $temp->add(new admin_setting_configtext('smtpuser', new lang_string('smtpuser', 'admin'), 514 new lang_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS)); 515 516 $temp->add(new admin_setting_configpasswordunmask('smtppass', new lang_string('smtppass', 'admin'), 517 new lang_string('configsmtpuser', 'admin'), '')); 518 519 $temp->add(new admin_setting_configtext('smtpmaxbulk', new lang_string('smtpmaxbulk', 'admin'), 520 new lang_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT)); 521 522 $temp->add(new admin_setting_heading('noreplydomainheading', new lang_string('noreplydomain', 'admin'), 523 new lang_string('noreplydomaindetail', 'admin'))); 524 525 $default = clean_param('noreply@' . get_host_from_url($CFG->wwwroot), PARAM_EMAIL); 526 if (!$default) { 527 $default = null; 528 } 529 $temp->add(new admin_setting_configtext('noreplyaddress', new lang_string('noreplyaddress', 'admin'), 530 new lang_string('confignoreplyaddress', 'admin'), $default, PARAM_EMAIL)); 531 532 $temp->add(new admin_setting_configtextarea('allowedemaildomains', 533 new lang_string('allowedemaildomains', 'admin'), 534 new lang_string('configallowedemaildomains', 'admin'), 535 '')); 536 537 $temp->add(new admin_setting_heading('divertallemailsheading', new lang_string('divertallemails', 'admin'), 538 new lang_string('divertallemailsdetail', 'admin'))); 539 $temp->add(new admin_setting_configtext('divertallemailsto', 540 new lang_string('divertallemailsto', 'admin'), 541 new lang_string('divertallemailsto_desc', 'admin'), 542 '')); 543 $temp->add(new admin_setting_configtextarea('divertallemailsexcept', 544 new lang_string('divertallemailsexcept', 'admin'), 545 new lang_string('divertallemailsexcept_desc', 'admin'), 546 '', PARAM_RAW, '50', '4')); 547 548 $noreplyaddress = isset($CFG->noreplyaddress) ? $CFG->noreplyaddress : 'noreply@example.com'; 549 $dkimdomain = substr(strrchr($noreplyaddress, "@"), 1); 550 $dkimselector = empty($CFG->emaildkimselector) ? '[selector]' : $CFG->emaildkimselector; 551 $pempath = "\$CFG->dataroot/dkim/{$dkimdomain}/{$dkimselector}.private"; 552 $temp->add(new admin_setting_heading('emaildkim', new lang_string('emaildkim', 'admin'), 553 new lang_string('emaildkiminfo', 'admin', ['path' => $pempath, 'docs' => \get_docs_url('Mail_configuration#DKIM')]))); 554 $temp->add(new admin_setting_configtext('emaildkimselector', new lang_string('emaildkimselector', 'admin'), 555 new lang_string('configemaildkimselector', 'admin'), '', PARAM_FILE)); 556 557 $url = new moodle_url('/admin/testoutgoingmailconf.php'); 558 $link = html_writer::link($url, get_string('testoutgoingmailconf', 'admin')); 559 $temp->add(new admin_setting_heading('testoutgoinmailc', new lang_string('testoutgoingmailconf', 'admin'), 560 new lang_string('testoutgoingmaildetail', 'admin', $link))); 561 562 $temp->add(new admin_setting_heading('emaildoesnotfit', new lang_string('doesnotfit', 'admin'), 563 new lang_string('doesnotfitdetail', 'admin'))); 564 565 $charsets = get_list_of_charsets(); 566 unset($charsets['UTF-8']); 567 $options = [ 568 '0' => 'UTF-8', 569 ]; 570 $options = array_merge($options, $charsets); 571 $temp->add(new admin_setting_configselect('sitemailcharset', new lang_string('sitemailcharset', 'admin'), 572 new lang_string('configsitemailcharset', 'admin'), '0', $options)); 573 574 $temp->add(new admin_setting_configcheckbox('allowusermailcharset', new lang_string('allowusermailcharset', 'admin'), 575 new lang_string('configallowusermailcharset', 'admin'), 0)); 576 577 $temp->add(new admin_setting_configcheckbox('allowattachments', new lang_string('allowattachments', 'admin'), 578 new lang_string('configallowattachments', 'admin'), 1)); 579 580 $options = [ 581 'LF' => 'LF', 582 'CRLF' => 'CRLF', 583 ]; 584 $temp->add(new admin_setting_configselect('mailnewline', new lang_string('mailnewline', 'admin'), 585 new lang_string('configmailnewline', 'admin'), 'LF', $options)); 586 587 $choices = [ 588 new lang_string('never', 'admin'), 589 new lang_string('always', 'admin'), 590 new lang_string('onlynoreply', 'admin'), 591 ]; 592 $temp->add(new admin_setting_configselect('emailfromvia', new lang_string('emailfromvia', 'admin'), 593 new lang_string('configemailfromvia', 'admin'), 1, $choices)); 594 595 $temp->add(new admin_setting_configtext('emailsubjectprefix', new lang_string('emailsubjectprefix', 'admin'), 596 new lang_string('configemailsubjectprefix', 'admin'), '', PARAM_RAW)); 597 598 $temp->add(new admin_setting_configtextarea('emailheaders', new lang_string('emailheaders', 'admin'), 599 new lang_string('configemailheaders', 'admin'), '', PARAM_RAW, '50', '3')); 600 601 $ADMIN->add('email', $temp); 602 603 // Update notifications. 604 if (empty($CFG->disableupdatenotifications)) { 605 $temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin')); 606 $temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'), 607 new lang_string('updateautocheck_desc', 'core_admin'), 1)); 608 $temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'), 609 new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE, 610 [ 611 MATURITY_ALPHA => new lang_string('maturity'.MATURITY_ALPHA, 'core_admin'), 612 MATURITY_BETA => new lang_string('maturity'.MATURITY_BETA, 'core_admin'), 613 MATURITY_RC => new lang_string('maturity'.MATURITY_RC, 'core_admin'), 614 MATURITY_STABLE => new lang_string('maturity'.MATURITY_STABLE, 'core_admin'), 615 ] 616 )); 617 $temp->add(new admin_setting_configcheckbox('updatenotifybuilds', new lang_string('updatenotifybuilds', 'core_admin'), 618 new lang_string('updatenotifybuilds_desc', 'core_admin'), 0)); 619 $ADMIN->add('server', $temp); 620 } 621 622 // Web services. 623 $ADMIN->add('server', new admin_category('webservicesettings', new lang_string('webservices', 'webservice'))); 624 625 // Web services > Overview. 626 $temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice')); 627 $temp->add(new admin_setting_webservicesoverview()); 628 $ADMIN->add('webservicesettings', $temp); 629 630 // Web services > API documentation. 631 $ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'), 632 "{$CFG->wwwroot}/{$CFG->admin}/webservice/documentation.php", 'moodle/site:config', false)); 633 634 // Web services > External services. 635 $temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice')); 636 637 $temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'), 638 new lang_string('servicehelpexplanation', 'webservice'))); 639 640 $temp->add(new admin_setting_manageexternalservices()); 641 642 $ADMIN->add('webservicesettings', $temp); 643 644 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', new lang_string('editaservice', 'webservice'), 645 "{$CFG->wwwroot}/{$CFG->admin}/webservice/service.php", 'moodle/site:config', true)); 646 647 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions', 648 new lang_string('externalservicefunctions', 'webservice'), "{$CFG->wwwroot}/{$CFG->admin}/webservice/service_functions.php", 649 'moodle/site:config', true)); 650 651 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers', 652 new lang_string('externalserviceusers', 'webservice'), "{$CFG->wwwroot}/{$CFG->admin}/webservice/service_users.php", 653 'moodle/site:config', true)); 654 655 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusersettings', 656 new lang_string('serviceusersettings', 'webservice'), "{$CFG->wwwroot}/{$CFG->admin}/webservice/service_user_settings.php", 657 'moodle/site:config', true)); 658 659 // Web services > Manage protocols. 660 $temp = new admin_settingpage('webserviceprotocols', new lang_string('manageprotocols', 'webservice')); 661 $temp->add(new admin_setting_managewebserviceprotocols()); 662 if (empty($CFG->enablewebservices)) { 663 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice'))); 664 } 665 666 // We cannot use $OUTPUT->doc_link() this early, we would lose the ability to set the page layout on all admin pages. 667 $url = new moodle_url(get_docs_url('How_to_get_a_security_key')); 668 $wsdoclink = html_writer::link($url, new lang_string('supplyinfo', 'webservice'), ['target' => '_blank']); 669 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', new lang_string('enablewsdocumentation', 'admin'), 670 new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false)); 671 672 $ADMIN->add('webservicesettings', $temp); 673 674 $plugins = core_plugin_manager::instance()->get_plugins_of_type('webservice'); 675 core_collator::asort_objects_by_property($plugins, 'displayname'); 676 foreach ($plugins as $plugin) { 677 /** @var \core\plugininfo\webservice $plugin */ 678 $plugin->load_settings($ADMIN, 'webservicesettings', $hassiteconfig); 679 } 680 681 // Web services > Manage tokens. 682 $ADMIN->add('webservicesettings', new admin_externalpage('webservicetokens', new lang_string('managetokens', 'webservice'), 683 new moodle_url('/admin/webservice/tokens.php'))); 684 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body