Update updateArticle-controller.php

This commit is contained in:
NOrtmann1
2026-05-29 17:29:24 +01:00
parent 222759a1bc
commit e096774233
+1 -25
View File
@@ -4,30 +4,6 @@ require_once '../model/LocalArticleManager.php';
require_once '../model/ArticleManager.php'; require_once '../model/ArticleManager.php';
require_once '../model/Article.php'; require_once '../model/Article.php';
// Angaben aus übergebener ID setzen:
if (isset($_GET["id"])){ // TODO: Später aus Session den Nutzer auslesen und Autorenrechte prüfen!
try {
$articleManager = ArticleManager::getInstance();
$article = $articleManager->getArticle($_GET["id"]);
if($article != null){
$title = $article->getTitle();
$content = $article->getContent();
$category = $article->getCategory();
$author = $article->getAuthor();
$tags = $article->getTags();
}else{
$_SESSION["message"] = "article_not_found";
echo "article_not_found";
}
} catch (Exception $e){
$_SESSION["message"] = "internal_error";
echo "Fehler aufgetreten: " . $e->getMessage();
}
}else{
$_SESSION["message"] = "article_not_found";
}
// Wenn "speichern" gedrückt wurde:
if ($_SERVER["REQUEST_METHOD"] === "POST") { if ($_SERVER["REQUEST_METHOD"] === "POST") {
if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){ if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
$_SESSION["message"] = "missing_parameters"; $_SESSION["message"] = "missing_parameters";
@@ -42,7 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$newTags = $_POST["tags"]; $newTags = $_POST["tags"];
try { try {
$articleManager = ArticleManager::getInstance(); $articleManager = ArticleManager::getInstance(); // TODO: Später aus Session den Nutzer auslesen und Autorenrechte prüfen!
$articleManager->updateArticle(new Article($newTitle, $newContent, $newCategory, $author, $newTags), $author); $articleManager->updateArticle(new Article($newTitle, $newContent, $newCategory, $author, $newTags), $author);
} catch (Exception $e){ } catch (Exception $e){
$_SESSION["message"] = "internal_error"; $_SESSION["message"] = "internal_error";