Merge branch 'MDL-80468-factorpage-m' of https://github.com/bwalkerl/moodle

This commit is contained in:
Jun Pataleta 2025-01-16 12:25:44 +08:00
commit 4a2e2086a4
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
14 changed files with 376 additions and 343 deletions

View File

@ -280,6 +280,10 @@ class factor extends \core\plugininfo\base {
* @param bool $hassiteconfig whether the current user has moodle/site:config capability
*/
public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig): void {
global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them.
/** @var \admin_root $ADMIN */
$ADMIN = $adminroot; // May be used in settings.php.
$plugininfo = $this; // Also can be used inside settings.php.
if (!$this->is_installed_and_upgraded()) {
return;
@ -293,9 +297,7 @@ class factor extends \core\plugininfo\base {
$settings = new \admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false);
if ($adminroot->fulltree) {
include($this->full_path('settings.php'));
}
$adminroot->add($parentnodename, $settings);
}

View File

@ -25,7 +25,9 @@
defined('MOODLE_INTERNAL') || die();
$settings->add(new admin_setting_heading('factor_admin/description', '', new lang_string('settings:description', 'factor_admin')));
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_admin/description', '',
new lang_string('settings:description', 'factor_admin')));
$settings->add(new admin_setting_heading('factor_admin/settings', new lang_string('settings', 'moodle'), ''));
$enabled = new admin_setting_configcheckbox('factor_admin/enabled',
@ -39,3 +41,4 @@ $settings->add($enabled);
$settings->add(new admin_setting_configtext('factor_admin/weight',
new lang_string('settings:weight', 'tool_mfa'),
new lang_string('settings:weight_help', 'factor_admin'), 100, PARAM_INT));
}

View File

@ -25,7 +25,9 @@
defined('MOODLE_INTERNAL') || die();
$settings->add(new admin_setting_heading('factor_auth/description', '', new lang_string('settings:description', 'factor_auth')));
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_auth/description', '',
new lang_string('settings:description', 'factor_auth')));
$settings->add(new admin_setting_heading('factor_auth/settings', new lang_string('settings', 'moodle'), ''));
$enabled = new admin_setting_configcheckbox('factor_auth/enabled',
@ -50,3 +52,4 @@ foreach ($authtypes as $type) {
$settings->add(new admin_setting_configmulticheckbox('factor_auth/goodauth',
get_string('settings:goodauth', 'factor_auth'),
get_string('settings:goodauth_help', 'factor_auth'), [], $authselect));
}

View File

@ -25,6 +25,7 @@
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_capability/description', '',
new lang_string('settings:description', 'factor_capability')));
$settings->add(new admin_setting_heading('factor_capability/settings', new lang_string('settings', 'moodle'), ''));
@ -45,3 +46,4 @@ $settings->add(new admin_setting_configtext('factor_capability/weight',
$settings->add(new admin_setting_configcheckbox('factor_capability/adminpasses',
new lang_string('settings:adminpasses', 'factor_capability'),
new lang_string('settings:adminpasses_help', 'factor_capability'), 1, 0, 1));
}

View File

@ -26,6 +26,7 @@
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/../../../../../cohort/lib.php');
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_cohort/description', '',
new lang_string('settings:description', 'factor_cohort')));
$settings->add(new admin_setting_heading('factor_cohort/settings', new lang_string('settings', 'moodle'), ''));
@ -54,3 +55,4 @@ if (!empty($choices)) {
new lang_string('settings:cohort', 'factor_cohort'),
new lang_string('settings:cohort_help', 'factor_cohort'), [], $choices));
}
}

View File

@ -25,7 +25,9 @@
defined('MOODLE_INTERNAL') || die();
$settings->add(new admin_setting_heading('factor_email/description', '', new lang_string('settings:description', 'factor_email')));
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_email/description', '',
new lang_string('settings:description', 'factor_email')));
$settings->add(new admin_setting_heading('factor_email/settings', new lang_string('settings', 'moodle'), ''));
$enabled = new admin_setting_configcheckbox('factor_email/enabled',
@ -47,3 +49,4 @@ $settings->add(new admin_setting_configduration('factor_email/duration',
$settings->add(new admin_setting_configcheckbox('factor_email/suspend',
get_string('settings:suspend', 'factor_email'),
get_string('settings:suspend_help', 'factor_email'), 0));
}

View File

@ -25,7 +25,9 @@
defined('MOODLE_INTERNAL') || die();
$settings->add(new admin_setting_heading('factor_grace/description', '', new lang_string('settings:description', 'factor_grace')));
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_grace/description', '',
new lang_string('settings:description', 'factor_grace')));
$settings->add(new admin_setting_heading('factor_grace/settings', new lang_string('settings', 'moodle'), ''));
$enabled = new admin_setting_configcheckbox('factor_grace/enabled',
@ -61,3 +63,4 @@ $settings->add(new admin_setting_configmultiselect('factor_grace/ignorelist',
$settings->add(new admin_setting_confightmleditor('factor_grace/customwarning',
new lang_string('settings:customwarning', 'factor_grace'),
new lang_string('settings:customwarning_help', 'factor_grace'), '', PARAM_RAW));
}

View File

@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die();
global $OUTPUT;
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_iprange/description', '',
new lang_string('settings:description', 'factor_iprange')));
$settings->add(new admin_setting_heading('factor_iprange/settings', new lang_string('settings', 'moodle'), ''));
@ -62,4 +63,4 @@ $settings->add(new admin_setting_configiplist('factor_iprange/safeips',
new lang_string('settings:safeips', 'factor_iprange'),
new lang_string('settings:safeips_help', 'factor_iprange',
['info' => $info, 'syntax' => get_string('ipblockersyntax', 'admin')]), '', PARAM_TEXT));
}

View File

@ -25,6 +25,7 @@
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_nosetup/description', '',
new lang_string('settings:description', 'factor_nosetup')));
$settings->add(new admin_setting_heading('factor_nosetup/settings', new lang_string('settings', 'moodle'), ''));
@ -40,3 +41,4 @@ $settings->add($enabled);
$settings->add(new admin_setting_configtext('factor_nosetup/weight',
new lang_string('settings:weight', 'tool_mfa'),
new lang_string('settings:weight_help', 'tool_mfa'), 100, PARAM_INT));
}

View File

@ -25,7 +25,9 @@
defined('MOODLE_INTERNAL') || die();
$settings->add(new admin_setting_heading('factor_role/description', '', new lang_string('settings:description', 'factor_role')));
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_role/description', '',
new lang_string('settings:description', 'factor_role')));
$settings->add(new admin_setting_heading('factor_role/settings', new lang_string('settings', 'moodle'), ''));
$enabled = new admin_setting_configcheckbox('factor_role/enabled',
@ -49,3 +51,4 @@ foreach ($roles as $role) {
$settings->add(new admin_setting_configmultiselect('factor_role/roles',
new lang_string('settings:roles', 'factor_role'),
new lang_string('settings:roles_help', 'factor_role'), ['admin'], $choices));
}

View File

@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
global $CFG;
if ($ADMIN->fulltree) {
// Get the gateway records.
$manager = \core\di::get(\core_sms\manager::class);
$gatewayrecords = $manager->get_gateway_records(['enabled' => 1]);
@ -118,3 +118,4 @@ if (count($gatewayrecords) > 0) {
),
);
}
}

View File

@ -26,7 +26,9 @@
defined('MOODLE_INTERNAL') || die();
$settings->add(new admin_setting_heading('factor_token/description', '', new lang_string('settings:description', 'factor_token')));
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_token/description', '',
new lang_string('settings:description', 'factor_token')));
$settings->add(new admin_setting_heading('factor_token/settings', new lang_string('settings', 'moodle'), ''));
$enabled = new admin_setting_configcheckbox('factor_token/enabled',
@ -48,3 +50,4 @@ $settings->add(new admin_setting_configduration('factor_token/expiry',
$settings->add(new admin_setting_configcheckbox('factor_token/expireovernight',
new lang_string('settings:expireovernight', 'factor_token'),
new lang_string('settings:expireovernight_help', 'factor_token'), 1));
}

View File

@ -26,7 +26,9 @@
defined('MOODLE_INTERNAL') || die();
$settings->add(new admin_setting_heading('factor_totp/description', '', new lang_string('settings:description', 'factor_totp')));
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_totp/description', '',
new lang_string('settings:description', 'factor_totp')));
$settings->add(new admin_setting_heading('factor_totp/settings', new lang_string('settings', 'moodle'), ''));
$enabled = new admin_setting_configcheckbox('factor_totp/enabled',
@ -50,3 +52,4 @@ $settings->add($window);
$settings->add(new admin_setting_configcheckbox('factor_totp/totplink',
new lang_string('settings:totplink', 'factor_totp'),
new lang_string('settings:totplink_help', 'factor_totp'), 1));
}

View File

@ -25,6 +25,7 @@
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('factor_webauthn/description', '',
new lang_string('settings:description', 'factor_webauthn')));
$settings->add(new admin_setting_heading('factor_webauthn/settings', new lang_string('settings', 'moodle'), ''));
@ -62,3 +63,4 @@ $settings->add(new admin_setting_configselect('factor_webauthn/userverification'
'preferred' => get_string('userverification:preferred', 'factor_webauthn'),
'discouraged' => get_string('userverification:discouraged', 'factor_webauthn'),
]));
}