Compare commits

...

2 Commits

Author SHA1 Message Date
NOrtmann1 1a6403963a Update updateArticle.php 2026-05-29 17:29:26 +01:00
NOrtmann1 e096774233 Update updateArticle-controller.php 2026-05-29 17:29:24 +01:00
2 changed files with 2 additions and 27 deletions
+1 -2
View File
@@ -1,6 +1,5 @@
<?php
session_start();
include_once 'php/controller/updateArticle-controller.php';
include_once 'php/controller/showArticle-controller.php';
?>
<!--
Seite: Beitrag erstellen
+1 -25
View File
@@ -4,30 +4,6 @@ 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!
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(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
$_SESSION["message"] = "missing_parameters";
@@ -42,7 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$newTags = $_POST["tags"];
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);
} catch (Exception $e){
$_SESSION["message"] = "internal_error";