From bb4e600acd5669f6ac4bfbfafcdea00c0b338c75 Mon Sep 17 00:00:00 2001 From: Matthew Hilton Date: Thu, 24 Oct 2024 10:22:13 +1000 Subject: [PATCH] bugfix: fix token expiry check in admin settings --- classes/check/token_expiry.php | 10 ++++++++++ classes/local/store/azure/client.php | 11 ----------- lang/en/tool_objectfs.php | 2 +- settings.php | 11 +++++++++++ version.php | 4 ++-- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/classes/check/token_expiry.php b/classes/check/token_expiry.php index ad6e8d6d..2eda943c 100644 --- a/classes/check/token_expiry.php +++ b/classes/check/token_expiry.php @@ -28,6 +28,16 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class token_expiry extends check { + /** + * Link to ObjectFS settings page. + * + * @return \action_link|null + */ + public function get_action_link(): ?\action_link { + $url = new \moodle_url('/admin/category.php', ['category' => 'tool_objectfs']); + return new \action_link($url, get_string('pluginname', 'tool_objectfs')); + } + /** * Checks the token expiry time against thresholds * @return result diff --git a/classes/local/store/azure/client.php b/classes/local/store/azure/client.php index ed755e0f..047b07d7 100644 --- a/classes/local/store/azure/client.php +++ b/classes/local/store/azure/client.php @@ -25,10 +25,8 @@ namespace tool_objectfs\local\store\azure; -use admin_setting_description; use SimpleXMLElement; use stdClass; -use tool_objectfs\check\token_expiry; use tool_objectfs\local\store\azure\stream_wrapper; use tool_objectfs\local\store\object_client_base; @@ -362,15 +360,6 @@ public function define_client_section($settings, $config) { new \lang_string('settings:azure:sastoken', 'tool_objectfs'), new \lang_string('settings:azure:sastoken_help', 'tool_objectfs'), '')); - // Admin_setting_check only exists in 4.5+, in lower versions fallback to a basic description. - if (class_exists('admin_setting_check')) { - $settings->add(new admin_setting_check('tool_objectfs/check_tokenexpiry', new token_expiry(), true)); - } else { - $summary = (new token_expiry())->get_result()->get_summary(); - $settings->add(new admin_setting_description('tool_objectfs/tokenexpirycheckresult', - get_string('checktoken_expiry', 'tool_objectfs'), $summary)); - } - return $settings; } diff --git a/lang/en/tool_objectfs.php b/lang/en/tool_objectfs.php index 74b383a5..c6fcfe6c 100644 --- a/lang/en/tool_objectfs.php +++ b/lang/en/tool_objectfs.php @@ -273,5 +273,5 @@ $string['checktoken_expiry'] = 'Token expiry'; $string['check:tokenexpiry:expiresin'] = 'Token expires in {$a->dayssince} days on {$a->time}'; $string['check:tokenexpiry:expired'] = 'Token expired for {$a->dayssince} days. Expired on {$a->time}'; -$string['check:tokenexpiry:na'] = 'Token expired not implemented for filesystem, or no token is set'; +$string['check:tokenexpiry:na'] = 'Token expiry check not implemented for filesystem, or no token is set'; $string['settings:tokenexpirywarnperiod'] = 'Token expiry warn period'; diff --git a/settings.php b/settings.php index aef3c571..18ae8fb6 100644 --- a/settings.php +++ b/settings.php @@ -23,6 +23,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +use tool_objectfs\check\token_expiry; + defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/classes/local/manager.php'); @@ -248,6 +250,15 @@ } } + // Admin_setting_check only exists in 4.5+, in lower versions fallback to a basic description. + if (class_exists('admin_setting_check')) { + $settings->add(new admin_setting_check('tool_objectfs/check_tokenexpiry', new token_expiry(), true)); + } else { + $summary = (new token_expiry())->get_result()->get_summary(); + $settings->add(new admin_setting_description('tool_objectfs/tokenexpirycheckresult', + get_string('checktoken_expiry', 'tool_objectfs'), $summary)); + } + $settings->add(new admin_setting_heading('tool_objectfs/testsettings', new lang_string('settings:testingheader', 'tool_objectfs'), '')); diff --git a/version.php b/version.php index 25c5d28d..09084a53 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024091700; // The current plugin version (Date: YYYYMMDDXX). -$plugin->release = 2024091700; // Same as version. +$plugin->version = 2024102400; // The current plugin version (Date: YYYYMMDDXX). +$plugin->release = 2024102400; // Same as version. $plugin->requires = 2023042400; // Requires 4.2. $plugin->component = "tool_objectfs"; $plugin->maturity = MATURITY_STABLE;