prepare("SELECT * FROM municipalities WHERE slug = :slug"); $stmt->execute([':slug' => 'lohne']); $municipality = $stmt->fetch(); // Show Login Page if not authenticated if ($page === 'login' || !is_admin()) { show_login_page($municipality, $login_error ?? null); exit; } // ----------------------------------------------------------------- // Handle Moderation Actions (Approve / Reject) // ----------------------------------------------------------------- if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['mod_action'])) { $contribution_id = $_POST['contribution_id'] ?? ''; $mod_action = $_POST['mod_action']; if ($contribution_id && in_array($mod_action, ['approved', 'rejected'])) { $stmt = $pdo->prepare("UPDATE contributions SET status = :status WHERE contribution_id = :id"); $stmt->execute([':status' => $mod_action, ':id' => $contribution_id]); } // Redirects to prevent Form Resubmission on Refresh header('Location: admin.php'); exit; } // ----------------------------------------------------------------- // Load Contributions Data // ----------------------------------------------------------------- // Pending Contributions $stmt = $pdo->prepare(" SELECT contribution_id, title, category, description, author_name, geom_type, status, created_at FROM contributions WHERE municipality_id = :mid AND status = 'pending' ORDER BY created_at DESC "); $stmt->execute([':mid' => $municipality['municipality_id']]); $pending = $stmt->fetchAll(); // Recently moderated Contributions $stmt = $pdo->prepare(" SELECT contribution_id, title, category, description, author_name, geom_type, status, created_at, updated_at FROM contributions WHERE municipality_id = :mid AND status IN ('approved', 'rejected') ORDER BY updated_at DESC LIMIT 20 "); $stmt->execute([':mid' => $municipality['municipality_id']]); $moderated = $stmt->fetchAll(); // Statistics $stmt = $pdo->prepare(" SELECT status, COUNT(*) as count FROM contributions WHERE municipality_id = :mid GROUP BY status "); $stmt->execute([':mid' => $municipality['municipality_id']]); $stats_rows = $stmt->fetchAll(); $stats = []; foreach ($stats_rows as $row) { $stats[$row['status']] = $row['count']; } // Category Labels for German Display $category_labels = [ 'mobility' => '🚲 Mobilität', 'building' => '🏗️ Bauen', 'energy' => '⚡ Energie', 'environment' => '🌳 Umwelt', 'industry' => '🏭 Industrie', 'consumption' => '🛒 Konsum', 'other' => '📌 Sonstiges' ]; // ----------------------------------------------------------------- // Render Main Page // ----------------------------------------------------------------- ?> Moderation — <?= htmlspecialchars($municipality['name']) ?>

Moderation —

Zur Karte Abmelden
Ausstehend
Freigegeben
Abgelehnt
Gesamt

Ausstehende Beiträge ()

Keine ausstehenden Beiträge.
ausstehend ¡ ¡

KĂźrzlich moderiert

Noch keine moderierten Beiträge.
¡ ¡
Moderation — Anmeldung

Moderation

Bitte geben Sie das Moderationspasswort ein.