Add show management and going-live controls to admin
- admin/shows.php: list shows - admin/show_edit.php: add, edit and delete shows, with validated background image uploads saved under generated names - admin/index.php: queue the next show, switch the live show, or clear the queue - includes/broadcasts.php: setBroadcastShow() and clearQueuedShow(), shared by the dashboard and cli/set_show.php - includes/admin_layout.php: flash messages and Shows nav link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
babb71660c
commit
6e61fc6bda
7 files changed
+297
-12
No files matched your search
@@ -10,6 +10,12 @@ function e(string $s): string {
|
||||
return htmlspecialchars($s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
|
||||
// One-time status message shown at the top of the next admin page (for post-redirect-get)
|
||||
function flash(string $message, string $type = 'success'): void {
|
||||
startAdminSession();
|
||||
$_SESSION['flash'] = ['message' => $message, 'type' => $type];
|
||||
}
|
||||
|
||||
function adminHeader(string $title, ?array $admin = null): void {
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
@@ -56,6 +62,7 @@ function adminHeader(string $title, ?array $admin = null): void {
|
||||
<?php if ($admin): ?>
|
||||
<ul class="admin-nav">
|
||||
<li><a href="index.php">Dashboard</a></li>
|
||||
<li><a href="shows.php">Shows</a></li>
|
||||
<li><a href="../live.php">View live page</a></li>
|
||||
</ul>
|
||||
<form method="post" action="logout.php">
|
||||
@@ -72,6 +79,10 @@ function adminHeader(string $title, ?array $admin = null): void {
|
||||
<h2><?= e($title) ?></h2>
|
||||
</header>
|
||||
<?php
|
||||
if (!empty($_SESSION['flash'])) {
|
||||
echo '<p class="admin-message ' . e($_SESSION['flash']['type']) . '">' . e($_SESSION['flash']['message']) . "</p>\n";
|
||||
unset($_SESSION['flash']);
|
||||
}
|
||||
}
|
||||
|
||||
function adminFooter(): void {
|
||||
|
||||
@@ -43,6 +43,23 @@ function currentShow(PDO $db): ?array {
|
||||
return $row ?: null;
|
||||
}
|
||||
|
||||
// Assigns a show to the live broadcast, or queues it for the next one if nothing is live.
|
||||
// Returns 'live' or 'queued'.
|
||||
function setBroadcastShow(PDO $db, int $showId): string {
|
||||
$live = liveBroadcast($db);
|
||||
if ($live !== null) {
|
||||
$db->prepare('UPDATE broadcasts SET show_id = ? WHERE id = ?')->execute([$showId, $live['id']]);
|
||||
return 'live';
|
||||
}
|
||||
clearQueuedShow($db);
|
||||
$db->prepare('INSERT INTO broadcasts (show_id) VALUES (?)')->execute([$showId]);
|
||||
return 'queued';
|
||||
}
|
||||
|
||||
function clearQueuedShow(PDO $db): void {
|
||||
$db->exec('DELETE FROM broadcasts WHERE started_at IS NULL');
|
||||
}
|
||||
|
||||
// Tracks from the most recent broadcast that has started, newest first
|
||||
function recentTracks(PDO $db, int $limit = 100): array {
|
||||
$stmt = $db->prepare(
|
||||
|
||||
Reference in new issue
Block a user