<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/include_all.inc.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $groupId = $_POST['groupId'];
    $newStatus = $_POST['newStatus'];
    
    $query = "UPDATE wp_groups SET group_status = ? WHERE id = ?";
    $stmt = $pdo->prepare($query);
    $result = $stmt->execute([$newStatus, $groupId]);
    
    if ($result) {
        echo json_encode(['success' => true]);
    } else {
        echo json_encode(['success' => false, 'error' => 'Database update failed']);
    }
} else {
    echo json_encode(['success' => false, 'error' => 'Invalid request method (group status)']);
}