This commit is contained in:
2026-01-20 21:24:17 +01:00
parent b52a53003c
commit 03452ce973

View File

@@ -531,6 +531,37 @@ class ApiKernel
private function ensureEmailtemplateSection(int $customerId): array private function ensureEmailtemplateSection(int $customerId): array
{ {
$existing = $this->fetchContentSectionBySlug($customerId, 'emailtemplate');
if ($existing) {
$needsUpdate = false;
$updates = [];
if (empty($existing['is_template'])) {
$updates[] = "`is_template` = 1";
$needsUpdate = true;
}
if (($existing['name'] ?? '') !== 'Emailtemplate') {
$updates[] = "`name` = 'Emailtemplate'";
$needsUpdate = true;
}
if (($existing['slug'] ?? '') !== 'emailtemplate') {
$updates[] = "`slug` = 'emailtemplate'";
$needsUpdate = true;
}
if ((int)($existing['position'] ?? 0) !== 0) {
$updates[] = "`position` = 0";
$needsUpdate = true;
}
if ($needsUpdate) {
$table = $this->contentSectionsTable();
if ($this->tableExists($table)) {
$sql = "UPDATE `$table` SET " . implode(',', $updates) . " WHERE `id` = :id AND `customer_id` = :cid LIMIT 1";
$stmt = $this->pdo->prepare($sql);
$stmt->execute([':id' => (int)$existing['id'], ':cid' => $customerId]);
}
$existing = $this->fetchContentSectionById($customerId, (int)$existing['id']) ?? $existing;
}
return $existing;
}
return $this->ensureContentSection($customerId, 'Emailtemplate', 'emailtemplate', true); return $this->ensureContentSection($customerId, 'Emailtemplate', 'emailtemplate', true);
} }