From 03452ce973c552655579d0a88101389e2aa60fcf Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Tue, 20 Jan 2026 21:24:17 +0100 Subject: [PATCH] asd --- src/ApiKernel.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/ApiKernel.php b/src/ApiKernel.php index 366c63f..054b15b 100644 --- a/src/ApiKernel.php +++ b/src/ApiKernel.php @@ -531,6 +531,37 @@ class ApiKernel 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); }