author can be edited and added in news moderation page
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user