This commit is contained in:
Huong Nguyen
2026-03-06 09:11:14 +07:00
5 changed files with 158 additions and 68 deletions
+155
View File
@@ -0,0 +1,155 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Login administration settings.
*
* @package core_admin
* @copyright 2026 Muhammad Arnaldo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($hassiteconfig) {
$temp = new admin_settingpage('loginsettings', new lang_string('loginsettings', 'admin'));
// Force to show the login page for fresh installs.
$temp->add(new admin_setting_configcheckbox(
'forcelogin',
new lang_string('forcelogin', 'admin'),
new lang_string('configforcelogin', 'admin'),
1
));
// Self registration.
$temp->add(new admin_setting_special_registerauth());
// Allow log in via email.
$temp->add(new admin_setting_configcheckbox(
'authloginviaemail',
new lang_string('authloginviaemail', 'core_auth'),
new lang_string('authloginviaemail_desc', 'core_auth'),
1,
));
// Autofocus login page form.
$temp->add(new admin_setting_configcheckbox(
'loginpageautofocus',
new lang_string('loginpageautofocus', 'admin'),
new lang_string('loginpageautofocus_help', 'admin'),
0
));
// Guest login button.
$temp->add(new admin_setting_configselect(
'guestloginbutton',
new lang_string('guestloginbutton', 'auth'),
new lang_string('showguestlogin', 'auth'),
'0',
[0 => new lang_string('hide'), 1 => new lang_string('show')],
));
// Alternate login URL.
$temp->add(new admin_setting_configtext(
'alternateloginurl',
new lang_string('alternateloginurl', 'auth'),
new lang_string('alternatelogin', 'auth', htmlspecialchars(get_login_url(), ENT_COMPAT)),
''
));
// Display manual login form.
$temp->add(new admin_setting_configcheckbox(
'showloginform',
new lang_string('showloginform', 'core_auth'),
new lang_string('showloginform_desc', 'core_auth'),
1
));
// Forgotten password URL.
$temp->add(new admin_setting_configtext(
'forgottenpasswordurl',
new lang_string('forgottenpasswordurl', 'auth'),
new lang_string('forgottenpassword', 'auth'),
'',
PARAM_URL
));
// Instructions shown on the login page.
$temp->add(new admin_setting_confightmleditor(
'auth_instructions',
new lang_string('instructions', 'auth'),
new lang_string('authinstructions', 'auth'),
''
));
// Enable reCAPTCHA for login.
$temp->add(new admin_setting_configselect(
'enableloginrecaptcha',
new lang_string('auth_loginrecaptcha', 'auth'),
new lang_string('auth_loginrecaptcha_desc', 'auth'),
0,
[
new lang_string('no'),
new lang_string('yes'),
],
));
// Enable reCAPTCHA for forgot password.
$temp->add(new admin_setting_configcheckbox(
'enableforgotpasswordrecaptcha',
new lang_string('auth_forgotpasswordrecaptcha', 'auth'),
new lang_string('auth_forgotpasswordrecaptcha_desc', 'auth'),
0,
));
// ReCAPTCHA site key.
$setting = new admin_setting_configtext(
'recaptchapublickey',
new lang_string('recaptchapublickey', 'admin'),
new lang_string('configrecaptchapublickey', 'admin'),
'',
PARAM_NOTAGS
);
$setting->set_force_ltr(true);
$temp->add($setting);
// ReCAPTCHA secret key.
$setting = new admin_setting_configtext(
'recaptchaprivatekey',
new lang_string('recaptchaprivatekey', 'admin'),
new lang_string('configrecaptchaprivatekey', 'admin'),
'',
PARAM_NOTAGS
);
$setting->set_force_ltr(true);
$temp->add($setting);
// Password visibility toggle.
$temp->add(new admin_setting_configselect(
'loginpasswordtoggle',
new lang_string('auth_loginpasswordtoggle', 'auth'),
new lang_string('auth_loginpasswordtoggle_desc', 'auth'),
TOGGLE_SENSITIVE_ENABLED,
[
TOGGLE_SENSITIVE_DISABLED => get_string('disabled', 'admin'),
TOGGLE_SENSITIVE_ENABLED => get_string('enabled', 'admin'),
TOGGLE_SENSITIVE_SMALL_SCREENS_ONLY => get_string('smallscreensonly', 'admin'),
],
));
$ADMIN->add('login', $temp);
}
-61
View File
@@ -115,37 +115,14 @@ if ($hassiteconfig) {
$temp = new admin_settingpage('manageauths', new lang_string('authsettings', 'admin'));
$temp->add(new admin_setting_manageauths());
$temp->add(new admin_setting_heading('manageauthscommonheading', new lang_string('commonsettings', 'admin'), ''));
$temp->add(new admin_setting_special_registerauth());
$temp->add(new admin_setting_configcheckbox(
'authloginviaemail',
new lang_string('authloginviaemail', 'core_auth'),
new lang_string('authloginviaemail_desc', 'core_auth'),
1,
));
$temp->add(new admin_setting_configcheckbox('allowaccountssameemail',
new lang_string('allowaccountssameemail', 'core_auth'),
new lang_string('allowaccountssameemail_desc', 'core_auth'), 0));
$temp->add(new admin_setting_configcheckbox('authpreventaccountcreation', new lang_string('authpreventaccountcreation', 'admin'), new lang_string('authpreventaccountcreation_help', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('loginpageautofocus', new lang_string('loginpageautofocus', 'admin'), new lang_string('loginpageautofocus_help', 'admin'), 0));
$temp->add(new admin_setting_configselect(
'guestloginbutton',
new lang_string('guestloginbutton', 'auth'),
new lang_string('showguestlogin', 'auth'),
'0',
[ 0 => new lang_string('hide'), 1 => new lang_string('show')],
));
$options = array(0 => get_string('no'), 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 10 => 10, 20 => 20, 50 => 50);
$temp->add(new admin_setting_configselect('limitconcurrentlogins',
new lang_string('limitconcurrentlogins', 'core_auth'),
new lang_string('limitconcurrentlogins_desc', 'core_auth'), 0, $options));
$temp->add(new admin_setting_configtext('alternateloginurl', new lang_string('alternateloginurl', 'auth'),
new lang_string('alternatelogin', 'auth', htmlspecialchars(get_login_url(), ENT_COMPAT)), ''));
$temp->add(new admin_setting_configcheckbox('showloginform', new lang_string('showloginform', 'core_auth'),
new lang_string('showloginform_desc', 'core_auth'), 1));
$temp->add(new admin_setting_configtext('forgottenpasswordurl', new lang_string('forgottenpasswordurl', 'auth'),
new lang_string('forgottenpassword', 'auth'), '', PARAM_URL));
$temp->add(new admin_setting_confightmleditor('auth_instructions', new lang_string('instructions', 'auth'),
new lang_string('authinstructions', 'auth'), ''));
$setting = new admin_setting_configtext('allowemailaddresses', new lang_string('allowemailaddresses', 'admin'),
new lang_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS);
$setting->set_force_ltr(true);
@@ -156,46 +133,8 @@ if ($hassiteconfig) {
$temp->add($setting);
$temp->add(new admin_setting_configcheckbox('verifychangedemail', new lang_string('verifychangedemail', 'admin'), new lang_string('configverifychangedemail', 'admin'), 1));
// ReCaptcha.
$temp->add(new admin_setting_configselect('enableloginrecaptcha',
new lang_string('auth_loginrecaptcha', 'auth'),
new lang_string('auth_loginrecaptcha_desc', 'auth'),
0,
[
new lang_string('no'),
new lang_string('yes'),
],
));
// Forgot password ReCaptcha.
$temp->add(new admin_setting_configcheckbox(
'enableforgotpasswordrecaptcha',
new lang_string('auth_forgotpasswordrecaptcha', 'auth'),
new lang_string('auth_forgotpasswordrecaptcha_desc', 'auth'),
0,
));
$setting = new admin_setting_configtext('recaptchapublickey', new lang_string('recaptchapublickey', 'admin'), new lang_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS);
$setting->set_force_ltr(true);
$temp->add($setting);
$setting = new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS);
$setting->set_force_ltr(true);
$temp->add($setting);
$ADMIN->add('authsettings', $temp);
// Toggle password visiblity icon.
$temp->add(new admin_setting_configselect('loginpasswordtoggle',
new lang_string('auth_loginpasswordtoggle', 'auth'),
new lang_string('auth_loginpasswordtoggle_desc', 'auth'),
TOGGLE_SENSITIVE_ENABLED,
[
TOGGLE_SENSITIVE_DISABLED => get_string('disabled', 'admin'),
TOGGLE_SENSITIVE_ENABLED => get_string('enabled', 'admin'),
TOGGLE_SENSITIVE_SMALL_SCREENS_ONLY => get_string('smallscreensonly', 'admin'),
],
));
$temp = new admin_externalpage('authtestsettings', get_string('testsettings', 'core_auth'), new moodle_url("/auth/test_settings.php"), 'moodle/site:config', true);
$ADMIN->add('authsettings', $temp);
-7
View File
@@ -39,13 +39,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
// "sitepolicies" settingpage
$temp = new admin_settingpage('sitepolicies', new lang_string('sitepolicies', 'admin'));
$temp->add(new admin_setting_configcheckbox('protectusernames', new lang_string('protectusernames', 'admin'), new lang_string('configprotectusernames', 'admin'), 1));
// Force to show the login page for fresh installs.
$temp->add(new admin_setting_configcheckbox(
'forcelogin',
new lang_string('forcelogin', 'admin'),
new lang_string('configforcelogin', 'admin'),
1
));
$temp->add(new admin_setting_configcheckbox('forceloginforprofiles', new lang_string('forceloginforprofiles', 'admin'), new lang_string('configforceloginforprofiles', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('forceloginforprofileimage', new lang_string('forceloginforprofileimage', 'admin'), new lang_string('forceloginforprofileimage_help', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('opentowebcrawlers', new lang_string('opentowebcrawlers', 'admin'), new lang_string('configopentowebcrawlers', 'admin'), 0));
+1
View File
@@ -32,6 +32,7 @@ $ADMIN->add('root', new admin_category('badges', new lang_string('badges'), empt
$ADMIN->add('root', new admin_category('h5p', new lang_string('h5p', 'core_h5p')));
$ADMIN->add('root', new admin_category('license', new lang_string('license')));
$ADMIN->add('root', new admin_category('location', new lang_string('location','admin')));
$ADMIN->add('root', new admin_category('login', new lang_string('login', 'admin')));
$ADMIN->add('root', new admin_category('language', new lang_string('language')));
$ADMIN->add('root', new admin_category('messaging', new lang_string('messagingcategory', 'admin')));
$ADMIN->add('root', new admin_category('payment', new lang_string('payments', 'payment')));
+2
View File
@@ -854,10 +854,12 @@ $string['lockrequestcategory'] = 'Prevent category selection';
$string['log'] = 'Logs';
$string['logguests'] = 'Log guest access';
$string['logguests_help'] = 'This setting enables logging of actions by guest account and not logged in users. High profile sites may want to disable this logging for performance reasons. It is recommended to keep this setting enabled on production sites.';
$string['login'] = 'Login';
$string['logininfoinsecurelayout'] = 'Display logged-in user in secure layout';
$string['logininfoinsecurelayout_desc'] = 'If enabled, the logged-in user\'s full name will be displayed in the navigation bar when attempting a quiz or other activity using secure layout.';
$string['loginpageautofocus'] = 'Autofocus login page form';
$string['loginpageautofocus_help'] = 'Enabling this option improves usability of the login page, but automatically focusing fields may be considered an accessibility issue.';
$string['loginsettings'] = 'Login settings';
$string['loglifetime'] = 'Keep logs for';
$string['logo'] = 'Logo';
$string['logo_desc'] = 'A full logo to be used as decoration by some themes (such as core themes). This image can be quite high resolution because it will be scaled down for use (and cached for performance). Logos that are wider than they are high usually give better results.';