From 870121e7cde35c32943ec436a75b08b27bd4f5ed Mon Sep 17 00:00:00 2001 From: Tomasz Wolniewicz <twoln@umk.pl> Date: Mon, 22 Jan 2024 11:32:19 +0100 Subject: [PATCH] adding the possibility to filter out federations which have some problems but are not under the close expiry threat --- lib/API.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/API.php b/lib/API.php index 3220e21..3966dfc 100644 --- a/lib/API.php +++ b/lib/API.php @@ -297,7 +297,7 @@ class API { } break; case 'only_errors': - if ($optValue != 1) { + if ($optValue != 1 && $optValue != 2) { $optValue = 0; } case 'details': @@ -577,8 +577,8 @@ class API { 'arg' => 'only_errors', 'required' => FALSE, 'default' => '0', - 'values' => '0, 1', - 'description' => '0 - show all; 1 - only federations with feed problems including close to expiry'], + 'values' => '0, 1, 2', + 'description' => '0 - show all; 1 - only federations with feed problems including close to expiry; 2 - show only federations with expiry time below the set valid_sec value'], [ 'arg' => 'valid_sec', 'required' => FALSE, @@ -611,7 +611,7 @@ class API { Utils::debug(5, $this->opts, "OPTS: ", "\n"); $edugain = new eduGAIN(5, $this->fed_id, true); $edugain->load_federations_state(); - if ($this->opts['only_errors'] == 1) { + if ($this->opts['only_errors'] > 0) { $out = []; if ($this->opts['valid_sec'] > 0) { $sec = $this->opts['valid_sec']; @@ -619,8 +619,15 @@ class API { $sec = VALIDITY_WARNING_THRESHOLD; } foreach ($edugain->FEDS as $fed) { - if ($fed['feed_problem'] > 0 || $fed['valid_sec'] < $sec) { - $out[$fed['code']] = $fed; + if ($this->opts['only_errors'] == 2) { + if ($fed['valid_sec'] < $sec) { + $out[$fed['code']] = $fed; + } + } + if ($this->opts['only_errors'] == 1) { + if ($fed['valid_sec'] < $sec || $fed['feed_problem'] > 0 ) { + $out[$fed['code']] = $fed; + } } } -- GitLab