diff --git a/php/controller/updateArticle-controller.php b/php/controller/updateArticle-controller.php index 60c1180..93e303b 100644 --- a/php/controller/updateArticle-controller.php +++ b/php/controller/updateArticle-controller.php @@ -2,6 +2,7 @@ session_start(); require_once '../model/LocalArticleManager.php'; require_once '../model/ArticleManager.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! @@ -31,17 +32,18 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") { if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){ $_SESSION["message"] = "missing_parameters"; header("location: ../../index.php?pfad=updateArticle"); + exit(); } else { - $title = $_POST["title"]; - $content = $_POST["content"]; - $category = $_POST["category"]; + $newTitle = $_POST["title"]; + $newContent = $_POST["content"]; + $newCategory = $_POST["category"]; $author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen. - $tags = $_POST["tags"]; + $newTags = $_POST["tags"]; try { $articleManager = ArticleManager::getInstance(); - $articleManager->updateArticle($title, $content, $author, $category, $tags); + $articleManager->updateArticle(new Article($newTitle, $newContent, $newCategory, $author, $newTags), $author); } catch (Exception $e){ $_SESSION["message"] = "internal_error"; }