From 8a76cd224893080d5cae4524f49f8caf9ba55e53 Mon Sep 17 00:00:00 2001 From: Matthew Hilton Date: Mon, 14 Sep 2026 16:10:05 +1000 Subject: [PATCH] T20: Move settings to autoloaded classes --- classes/plugininfo/factor.php | 9 ++++++--- factor/sms/classes/local/smsgateway/aws_sns.php | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/classes/plugininfo/factor.php b/classes/plugininfo/factor.php index 29291f11..e6ad308a 100644 --- a/classes/plugininfo/factor.php +++ b/classes/plugininfo/factor.php @@ -16,6 +16,9 @@ namespace tool_mfa\plugininfo; +use core\setting\part\page; +use core\setting\part\part_of_admin_tree; + /** * Subplugin info class. * @@ -242,11 +245,11 @@ public function get_settings_section_name() { * This function usually includes settings.php file in plugins folder. * Alternatively it can create a link to some settings page (instance of admin_externalpage) * - * @param \part_of_admin_tree $adminroot + * @param part_of_admin_tree $adminroot * @param string $parentnodename * @param bool $hassiteconfig whether the current user has moodle/site:config capability */ - public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) { + public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) { if (!$this->is_installed_and_upgraded()) { return; @@ -258,7 +261,7 @@ public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $ $section = $this->get_settings_section_name(); - $settings = new \admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false); + $settings = new page($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false); if ($adminroot->fulltree) { include($this->full_path('settings.php')); diff --git a/factor/sms/classes/local/smsgateway/aws_sns.php b/factor/sms/classes/local/smsgateway/aws_sns.php index af3d7ca1..b83502ee 100644 --- a/factor/sms/classes/local/smsgateway/aws_sns.php +++ b/factor/sms/classes/local/smsgateway/aws_sns.php @@ -16,6 +16,10 @@ namespace factor_sms\local\smsgateway; +use core\setting\heading; +use core\setting\type\checkbox; +use core\setting\type\password_unmask; +use core\setting\type\text; use factor_sms\event\sms_sent; /** @@ -124,18 +128,18 @@ public static function add_settings($settings) { if (!$reqs) { $warning = $OUTPUT->notification(get_string('awssdkrequired', 'factor_sms'), 'notifyerror'); - $settings->add(new \admin_setting_heading('factor_sms/awssdkwarning', '', $warning)); + $settings->add(new heading('factor_sms/awssdkwarning', '', $warning)); } else { - $settings->add(new \admin_setting_configcheckbox('factor_sms/usecredchain', + $settings->add(new checkbox('factor_sms/usecredchain', get_string('settings:aws:usecredchain', 'factor_sms'), '', 0)); if (!get_config('factor_sms', 'usecredchain')) { // AWS Settings. - $settings->add(new \admin_setting_configtext('factor_sms/api_key', + $settings->add(new text('factor_sms/api_key', get_string('settings:aws:key', 'factor_sms'), get_string('settings:aws:key_help', 'factor_sms'), '')); - $settings->add(new \admin_setting_configpasswordunmask('factor_sms/api_secret', + $settings->add(new password_unmask('factor_sms/api_secret', get_string('settings:aws:secret', 'factor_sms'), get_string('settings:aws:secret_help', 'factor_sms'), '')); }