From c6548654765fd78f4f3b32be4241a2818c0df36a Mon Sep 17 00:00:00 2001 From: Tomasz Wolniewicz <twoln@umk.pl> Date: Tue, 27 Jun 2023 15:16:30 +0200 Subject: [PATCH] an innitial implementation of the CSV dump of federations - to be polished --- lib/API.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/API.php b/lib/API.php index 8e94e8b..502c624 100644 --- a/lib/API.php +++ b/lib/API.php @@ -454,7 +454,7 @@ class API { private function action_list_feds() { $this->description([ 'header' => "List federation details (code, name, contact email, registration authority string, status).", - 'supportedFormats' => ['json', 'print_r'], + 'supportedFormats' => ['json', 'csv', 'print_r'], 'arguments' => [ [ 'arg' => 'opt', @@ -487,6 +487,17 @@ class API { $edugain = new eduGAIN($this->opts['opt']); $F = $edugain->FEDS; ksort($F, SORT_STRING | SORT_FLAG_CASE); + + + if ($this->format == 'csv') { + $out = ''; + foreach ($F as $fed => $A) { + $ln = $fed . "\t" . implode("\t", $A) . "\n"; + $out .= $ln; + } + return($out); + } + foreach ($F as $fed => $A) { $out[$fed] = ['name' => $A['name'], 'email' => $A['contact_email'], -- GitLab