22 lines
679 B
PHP
22 lines
679 B
PHP
<?php
|
|
require 'db.php';
|
|
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
|
|
$type = $data['type'];
|
|
$id = intval($data['id']);
|
|
$highlighted = isset($data['highlighted']) && $data['highlighted'] ? 1 : 0;
|
|
|
|
if ($type === 'task') {
|
|
$stmt = $pdo->prepare("UPDATE tasks SET highlighted = ? WHERE id = ?");
|
|
$stmt->execute([$highlighted, $id]);
|
|
echo json_encode(['success' => true]);
|
|
} elseif ($type === 'subtask') {
|
|
$stmt = $pdo->prepare("UPDATE subtasks SET highlighted = ? WHERE id = ?");
|
|
$stmt->execute([$highlighted, $id]);
|
|
echo json_encode(['success' => true]);
|
|
} else {
|
|
echo json_encode(['success' => false, 'error' => 'Invalid type']);
|
|
}
|
|
?>
|