36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
session_start();
|
|
require_once '../model/LocalArticleManager.php';
|
|
require_once '../model/ArticleManager.php';
|
|
require_once '../model/Article.php';
|
|
|
|
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();
|
|
} elseif(!isset($id)) {
|
|
$_SESSION["message"] = "missing_id";
|
|
}else{
|
|
|
|
$newTitle = $_POST["title"];
|
|
$newContent = $_POST["content"];
|
|
$newCategory = $_POST["category"];
|
|
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
|
$newTags = $_POST["tags"];
|
|
|
|
try {
|
|
$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";
|
|
}
|
|
$_SESSION["message"] = "new_article";
|
|
// Weiterleitung zur Homepage
|
|
header("location: ../../index.php");
|
|
exit();
|
|
|
|
}
|
|
}
|
|
|
|
?>
|