author can be edited and added in news moderation page

This commit is contained in:
2026-04-24 17:41:59 +02:00
parent 125c255115
commit fa984e7391
2 changed files with 23 additions and 10 deletions

View File

@@ -382,13 +382,14 @@ function handle_create_news($input) {
try {
$stmt = $pdo->prepare("
INSERT INTO news (municipality_id, title, content)
VALUES (:mid, :title, :content)
INSERT INTO news (municipality_id, title, content, author_name)
VALUES (:mid, :title, :content, :author)
");
$stmt->execute([
':mid' => $input['municipality_id'],
':title' => $input['title'],
':content' => $input['content']
':content' => $input['content'],
':author' => $input['author_name'] ?? 'Stadtverwaltung'
]);
json_response(['message' => 'News created successfully.', 'news_id' => (int) $pdo->lastInsertId()], 201);
} catch (PDOException $e) {
@@ -411,7 +412,7 @@ function handle_update_news($input) {
$set = [];
$params = [':id' => $input['news_id']];
foreach (['title', 'content'] as $field) {
foreach (['title', 'content', 'author_name'] as $field) {
if (isset($input[$field]) && $input[$field] !== '') {
$set[] = "$field = :$field";
$params[":$field"] = $input[$field];