diff --git a/lib/API.php b/lib/API.php index 8e94e8b991233c0510975aedac97d8d07954b993..502c62428399f49769ac38a609a1f42f2b97a3f1 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'],