Bewertungssystem #36

Merged
niklas.ortmann merged 6 commits from Bewertungssystem into dev 2026-06-17 21:29:25 +02:00
Showing only changes of commit eb0a34e959 - Show all commits
+42
View File
@@ -0,0 +1,42 @@
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
require_once __DIR__ . '/../model/Article.php';
require_once __DIR__ . '/../model/ArticleManager.php';
// 2. Prüfen, ob eine gültige Artikel-ID übergeben wurde
if (isset($_GET["id"]) && !empty($_GET["id"])) {
$articleId = intval($_GET["id"]);
$userEmail = $_SESSION["user_email"];
if (!isset($_SESSION["user_email"]) || empty($_SESSION["user_email"])) {
$_SESSION["message"] = "unauthorized_access";
header("Location: ../../index.php?pfad=showArticle&id=" . $articleId);
exit();
}
try {
$articleManager = ArticleManager::getInstance();
$articleManager->toggleLike($articleId, $userEmail);
header("Location: ../../index.php?pfad=showArticle&id=" . $articleId);
exit();
} catch (NotFoundException $e) {
$_SESSION["message"] = "missing_id";
header("Location: ../../index.php");
exit();
} catch (Exception $e) {
$_SESSION["message"] = "internal_error";
header("Location: ../../index.php");
exit();
}
} else {
$_SESSION["message"] = "missing_id";
header("Location: ../../index.php");
exit();
}
?>