<?php
require_once __DIR__ . '/../../app/core/bootstrap.php';
require_once __DIR__ . '/../../app/core/project_permissions.php';
header('Content-Type: application/json');

$uid = gp_current_user_id();
if ($uid <= 0) {
    echo json_encode(['ok' => false]);
    exit;
}

$input = json_decode(file_get_contents('php://input'), true);
if (isset($input['clear_all']) && $input['clear_all'] === true) {
    $stmt = crm_pdo()->prepare("DELETE FROM user_notifications WHERE user_id = ?");
    $stmt->execute([$uid]);
}

echo json_encode(['ok' => true]);
