feat(widgets): allow users to customize widget titles from settings gear dropdown

This commit is contained in:
2026-09-11 15:39:36 +02:00
parent 0942a94edd
commit dc740fb94d
2 changed files with 151 additions and 15 deletions
+20 -1
View File
@@ -42,8 +42,27 @@ try {
exit;
}
// Valideer en sanitize layout items inclusief optionele custom widget titel
$cleanedLayout = [];
foreach ($layout as $item) {
if (!is_array($item) || empty($item['id'])) continue;
$cleaned = [
'id' => substr(trim((string)$item['id']), 0, 64),
'enabled' => !empty($item['enabled']),
'col_span' => in_array((int)($item['col_span'] ?? 6), [4, 5, 6, 7, 8, 12]) ? (int)$item['col_span'] : 6,
'order' => (int)($item['order'] ?? 1),
];
if (!empty($item['custom_title'])) {
$customTitle = trim(strip_tags((string)$item['custom_title']));
if ($customTitle !== '') {
$cleaned['custom_title'] = substr($customTitle, 0, 50);
}
}
$cleanedLayout[] = $cleaned;
}
$stmt = $db->prepare("UPDATE users SET fociz_widget_layout = ? WHERE id = ?");
$stmt->execute([json_encode($layout), $user['id']]);
$stmt->execute([json_encode($cleanedLayout, JSON_UNESCAPED_UNICODE), $user['id']]);
echo json_encode(['success' => true, 'message' => 'Widget indeling succesvol opgeslagen']);
exit;