query("UPDATE survey_reviews SET is_approved = 1, approved_at = NOW(), approved_by = {$_SESSION['admin_id']} WHERE id = $rid"); $success = 'Review approved and now visible to the public.'; } // Reject / delete if (isset($_GET['reject'])) { $rid = (int)$_GET['reject']; $conn->query("DELETE FROM survey_reviews WHERE id = $rid"); $success = 'Review rejected and deleted.'; } // Bulk actions if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['bulk_ids'])) { $ids = array_map('intval', (array)$_POST['bulk_ids']); $id_str = implode(',', $ids); if ($_POST['bulk_action'] === 'approve') { $conn->query("UPDATE survey_reviews SET is_approved = 1, approved_at = NOW(), approved_by = {$_SESSION['admin_id']} WHERE id IN ($id_str)"); $success = count($ids) . ' review(s) approved.'; } elseif ($_POST['bulk_action'] === 'reject') { $conn->query("DELETE FROM survey_reviews WHERE id IN ($id_str)"); $success = count($ids) . ' review(s) deleted.'; } } // ── FILTERS ────────────────────────────────────────────────── $status_filter = $_GET['status'] ?? 'pending'; $survey_filter = isset($_GET['survey']) ? (int)$_GET['survey'] : 0; $rating_filter = isset($_GET['rating']) ? (int)$_GET['rating'] : 0; $where = ['1=1']; if ($status_filter === 'pending') $where[] = 'r.is_approved = 0'; if ($status_filter === 'approved') $where[] = 'r.is_approved = 1'; if ($survey_filter > 0) $where[] = "r.survey_id = $survey_filter"; if ($rating_filter > 0) $where[] = "r.rating = $rating_filter"; $where_sql = implode(' AND ', $where); $reviews_sql = "SELECT r.*, s.title as survey_title FROM survey_reviews r JOIN survey_sites s ON r.survey_id = s.id WHERE $where_sql ORDER BY r.created_at DESC"; $reviews = $conn->query($reviews_sql); // Stats $pending_count = $conn->query("SELECT COUNT(*) as c FROM survey_reviews WHERE is_approved = 0")->fetch_assoc()['c']; $approved_count = $conn->query("SELECT COUNT(*) as c FROM survey_reviews WHERE is_approved = 1")->fetch_assoc()['c']; $total_count = $pending_count + $approved_count; // All survey sites for filter dropdown $sites_result = $conn->query("SELECT id, title FROM survey_sites ORDER BY title ASC"); $page_title = 'Manage Reviews'; include 'includes/header.php'; ?>

Manage Reviews

Approve, reject, and manage member reviews for all survey sites.

← Dashboard
Pending
Approved
Total
⏳ Pending () ✓ Approved () All
num_rows > 0): ?>
| num_rows; ?> review(s) shown
fetch_assoc()): ?>
Survey Site Reviewer Rating Review Date Status Actions
📍
IP:
/5

chars

✓ Approved ⏳ Pending ✓ Approve ✗ Delete ↗ View
📭

No reviews found

No reviews match your filters.