From 792e19b85baea21c80dd752e74e2b02e57ef5e14 Mon Sep 17 00:00:00 2001 From: Katelyn Gigante Date: Sun, 5 Nov 2023 14:41:56 +1100 Subject: [PATCH] Upcoming Events API --- gatherling/api.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gatherling/api.php b/gatherling/api.php index 2aca53026..938cabede 100644 --- a/gatherling/api.php +++ b/gatherling/api.php @@ -104,6 +104,22 @@ } break; + case 'upcoming_events': + $events = []; + $db = Database::getConnection(); + $query = $db->query('SELECT e.name as name FROM events e + WHERE e.start > NOW() + ORDER BY e.start ASC'); + while ($row = $query->fetch_assoc()) { + $events[] = $row['name']; + } + $query->close(); + foreach ($events as $eventname) { + $event = new Event($eventname); + $result[$event->name] = repr_json_event($event); + } + break; + case 'create_series': $series = $_REQUEST['series']; $active = true;