From 05c095bae2d119da260262c76ce15d6ad100efbc Mon Sep 17 00:00:00 2001 From: Benjamin Walker Date: Wed, 5 Aug 2026 11:45:44 +1000 Subject: [PATCH] Use check API for proxy range request test #618 --- lang/en/tool_objectfs.php | 2 +- settings.php | 38 ++++---------------------------------- version.php | 4 ++-- 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/lang/en/tool_objectfs.php b/lang/en/tool_objectfs.php index b1884d74..5c037a77 100644 --- a/lang/en/tool_objectfs.php +++ b/lang/en/tool_objectfs.php @@ -29,7 +29,7 @@ $string['check:connection:error'] = 'Could not establish connection to the object store: {$a}'; $string['check:connection:na'] = 'No object store client is configured'; $string['check:connection:ok'] = 'Connection to the object store is working'; -$string['check:proxyrangerequestsdisabled'] = 'The proxy range request setting is disabled.'; +$string['check:proxyrangerequestsdisabled'] = 'Proxy range requests can\'t be tested with the current configuration.'; $string['check:tagging:error'] = 'Error trying to tag object'; $string['check:tagging:migrationerror'] = 'Object tagging migration task(s) have faildelay > 0'; $string['check:tagging:migrationok'] = 'Object tagging migration tasks OK'; diff --git a/settings.php b/settings.php index aef439fd..5cc71940 100644 --- a/settings.php +++ b/settings.php @@ -24,6 +24,7 @@ */ use tool_objectfs\check\connection; +use tool_objectfs\check\proxy_range_request; use tool_objectfs\check\token_expiry; use tool_objectfs\check\tagging_migration_status; use tool_objectfs\check\tagging_sync_status; @@ -34,8 +35,6 @@ require_once(__DIR__ . '/classes/local/manager.php'); require_once(__DIR__ . '/lib.php'); -global $PAGE, $CFG; - if (!$hassiteconfig) { return; } @@ -70,20 +69,6 @@ )); if ($ADMIN->fulltree) { - // Check if we are actually on the Objectfs settings page, or in correct category. - $caturl = new moodle_url('/admin/category.php'); - $pageurl = new moodle_url('/admin/settings.php'); - $objectfspage = false; - if ($PAGE->has_set_url()) { - $thisurl = $PAGE->url; - if ( - ($caturl->compare($thisurl, URL_MATCH_BASE) && $thisurl->get_param('category') == 'tool_objectfs') || - ($pageurl->compare($thisurl, URL_MATCH_BASE) && $thisurl->get_param('section') == 'tool_objectfs_settings') - ) { - $objectfspage = true; - } - } - $warntext = ''; if (method_exists('file_storage', 'get_file_system')) { if (!\tool_objectfs\local\manager::check_file_storage_filesystem()) { @@ -249,29 +234,12 @@ )); if ($classexists) { - $connstatus = false; - if ($objectfspage) { - $testconn = $client->test_connection(); - $connstatus = $testconn->success; - } - $warningtext = ''; $methodexists = method_exists('file_system', 'xsendfile_file'); if (!$methodexists) { $warningtext .= $OUTPUT->notification(get_string('settings:presignedurl:xsendfilefile', 'tool_objectfs')); - } else if ($connstatus) { - // Range request tests can only work if there is a valid connection. - $range = $client->test_range_request(new $config->filesystem()); - if ($range->result) { - $warningtext .= $OUTPUT->notification( - get_string('settings:presignedurl:testrangeok', 'tool_objectfs'), - 'notifysuccess' - ); - } else { - $warningtext .= $OUTPUT->notification(get_string('settings:presignedurl:testrangeerror', 'tool_objectfs')); - $warningtext .= $OUTPUT->notification($range->error); - } } + $settings->add(new admin_setting_configcheckbox( 'tool_objectfs/proxyrangerequests', new lang_string('settings:presignedurl:proxyrangerequests', 'tool_objectfs'), @@ -279,6 +247,8 @@ '1' )); + $settings->add(new admin_setting_check('tool_objectfs/proxyrangerequestscheck', new proxy_range_request())); + $settings->add(new admin_setting_configcheckbox( 'tool_objectfs/enablepresignedurls', new lang_string('settings:presignedurl:enablepresignedurls', 'tool_objectfs'), diff --git a/version.php b/version.php index d1656ed8..598d3758 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2026041008; // The current plugin version (Date: YYYYMMDDXX). -$plugin->release = 2026041008; // Same as version. +$plugin->version = 2026041009; // The current plugin version (Date: YYYYMMDDXX). +$plugin->release = 2026041009; // Same as version. $plugin->requires = 2024042200; // Requires 4.4. $plugin->component = "tool_objectfs"; $plugin->maturity = MATURITY_STABLE;