Actualiser api/index.php
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
Security Scan (Trivy) / Trivy — Docker image scan (push) Has been cancelled
Security Scan (Trivy) / Trivy — Filesystem scan (push) Has been cancelled

This commit is contained in:
2026-06-17 13:30:48 +00:00
parent e52aa6d699
commit 288e0c05f6
+27
View File
@@ -939,6 +939,9 @@ try {
case 'locations_remove':
locationsRemove($db);
break;
case 'locations_update':
locationsUpdate($db);
break;
case 'recipes_list':
recipesList($db);
break;
@@ -12041,6 +12044,30 @@ function locationsRemove(PDO $db): void {
echo json_encode(['success' => true]);
}
function locationsUpdate(PDO $db): void {
$input = json_decode(file_get_contents('php://input'), true) ?? [];
$key = trim($input['key'] ?? '');
$label = trim($input['label'] ?? '');
$icon = trim($input['icon'] ?? '');
if ($key === '' || $label === '') {
echo json_encode(['success' => false, 'error' => 'key and label required']);
return;
}
$stmt = $db->prepare("SELECT id FROM locations WHERE key = ?");
$stmt->execute([$key]);
if (!$stmt->fetch()) {
echo json_encode(['success' => false, 'error' => 'location not found']);
return;
}
$stmt = $db->prepare("UPDATE locations SET label = ?, icon = ? WHERE key = ?");
$stmt->execute([$label, $icon ?: '📦', $key]);
echo json_encode(['success' => true]);
}
// ===== SHARED APP DATA FUNCTIONS =====
function appSettingsGet(PDO $db): void {