Skip to content

Commit

Permalink
bugfix: fix token expiry admin setting check
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhilton committed Oct 22, 2024
1 parent 6977780 commit b4c35fb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
11 changes: 11 additions & 0 deletions classes/check/token_expiry.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace tool_objectfs\check;

use action_link;
use core\check\check;
use core\check\result;

Expand Down Expand Up @@ -68,4 +69,14 @@ public function get_result(): result {
// Else ok.
return new result(result::OK, get_string('check:tokenexpiry:expiresin', 'tool_objectfs', $strparams));
}

/**
* 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'));
}
}
9 changes: 1 addition & 8 deletions classes/local/store/azure/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

namespace tool_objectfs\local\store\azure;

use admin_setting_check;
use admin_setting_description;
use SimpleXMLElement;
use stdClass;
Expand Down Expand Up @@ -362,14 +363,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;
}
Expand Down
11 changes: 11 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -143,6 +145,15 @@
$settings = $client->define_client_section($settings, $config);
}

// 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));
}

$warningtext = '';
$signingsupport = false;
if (!empty($config->filesystem)) {
Expand Down

0 comments on commit b4c35fb

Please sign in to comment.