diff options
| author | Simon Rettberg | 2026-01-20 15:52:04 +0100 |
|---|---|---|
| committer | Simon Rettberg | 2026-01-20 15:52:04 +0100 |
| commit | 24f5c388cd1246074bf5d39c5a0c484d0d625d80 (patch) | |
| tree | a961f7bbc10d62b30e43ecbf898818cc21660287 /modules-available/locationinfo/api.inc.php | |
| parent | IntelliJ: Mark Testdir (diff) | |
| download | slx-admin-24f5c388cd1246074bf5d39c5a0c484d0d625d80.tar.gz slx-admin-24f5c388cd1246074bf5d39c5a0c484d0d625d80.tar.xz slx-admin-24f5c388cd1246074bf5d39c5a0c484d0d625d80.zip | |
[locationinfo] Add panel query API, add option to mark panels as public
This adds the option to query a JSON of all available info panels.
In addition, info panels can be marked as public/private, and only
public panels will be returned in the JSON.
Diffstat (limited to 'modules-available/locationinfo/api.inc.php')
| -rw-r--r-- | modules-available/locationinfo/api.inc.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index 1a3bd76e..cd2ffd5a 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -42,6 +42,8 @@ function HandleParameters() $output = LocationInfo::getCalendar($locationIds, time() + 3); } elseif ($get === "manifest") { $output = generateManifest($uuid); + } elseif ($get === 'list') { + $output = generatePublicPanelList(); } if ($output !== null) { Header('Content-Type: application/json; charset=utf-8'); @@ -170,4 +172,26 @@ function generateManifest(string $uuid): array ]; } return $data; +} + +function generatePublicPanelList(): array +{ + $base = Util::shouldRedirectDomain(); + if ($base !== null) { + $base = 'https://' . $base; + } else { + $base = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST']; + } + $result = [ + 'server_name' => 'To be filled by O.E.M.', + 'panels' => [], + ]; + $res = Database::simpleQuery("SELECT paneluuid, panelname FROM locationinfo_panel WHERE ispublic = 1"); + foreach ($res as $row) { + $result['panels'][] = [ + 'title' => $row['panelname'], + 'url' => $base . '/panel/' . $row['paneluuid'], + ]; + } + return $result; }
\ No newline at end of file |
