prepare("SELECT * FROM municipalities WHERE slug = :slug"); $stmt->execute([':slug' => getenv('MUNICIPALITY_SLUG')]); $municipality = $stmt->fetch(); // Loads News for Moderation $stmt = $pdo->prepare(" SELECT news_id, title, content, author_name, published_at, created_at FROM news WHERE municipality_id = :mid ORDER BY published_at DESC "); $stmt->execute([':mid' => $municipality['municipality_id']]); $news_items = $stmt->fetchAll(); // Loads all Comments with Contribution Titles for Moderation $stmt = $pdo->prepare(" SELECT cm.comment_id, cm.contribution_id, cm.author_name, cm.browser_id, cm.content, cm.status, cm.created_at, co.title AS contribution_title, co.category AS contribution_category FROM comments cm JOIN contributions co ON cm.contribution_id = co.contribution_id WHERE co.municipality_id = :mid ORDER BY cm.created_at DESC "); $stmt->execute([':mid' => $municipality['municipality_id']]); $all_comments = $stmt->fetchAll(); // Counts Comments per Status $comment_counts = ['pending' => 0, 'approved' => 0, 'rejected' => 0]; foreach ($all_comments as $c) { if (isset($comment_counts[$c['status']])) { $comment_counts[$c['status']]++; } } $comment_counts['total'] = count($all_comments); // Shows Login Page if not authenticated if ($page === 'login' || !is_admin()) { show_login_page($municipality, $login_error ?? null); exit; } // ----------------------------------------------------------------- // Loads shared Category Definitions // ----------------------------------------------------------------- $categories = get_categories(); // ----------------------------------------------------------------- // Loads Contributions and Statistics // ----------------------------------------------------------------- // Loads all Contributions for Municipality $stmt = $pdo->prepare(" SELECT contribution_id, title, category, description, author_name, photo_path, geom_type, status, likes_count, dislikes_count, comment_count, created_at, updated_at FROM contributions WHERE municipality_id = :mid ORDER BY created_at DESC "); $stmt->execute([':mid' => $municipality['municipality_id']]); $all_contributions = $stmt->fetchAll(); // Counts per Status $counts = ['pending' => 0, 'approved' => 0, 'rejected' => 0]; foreach ($all_contributions as $item) { if (isset($counts[$item['status']])) { $counts[$item['status']]++; } } $counts['total'] = count($all_contributions); // ----------------------------------------------------------------- // Renders Main Page // ----------------------------------------------------------------- ?>
Bitte geben Sie das Moderationspasswort ein.