Merge branch 'visuelles-Feedback' into devNachCSRF

This commit is contained in:
2026-07-19 23:54:44 +02:00
5 changed files with 348 additions and 21 deletions
+18 -1
View File
@@ -4,6 +4,7 @@ if (session_status() === PHP_SESSION_NONE) {
}
require_once "../model/CommentManager.php";
require_once "../model/UserManager.php";
require_once "../model/ArticleManager.php";
require_once "../../includes/csrf.php";
@@ -211,13 +212,29 @@ try {
$parentCommentId
);
$userManager = UserManager::getInstance();
$user = $userManager->findUser($_SESSION["user_email"]);
$authorName = $_SESSION["user_email"];
if ($user !== null) {
$vorname = trim($user["vorname"] ?? "");
$nachname = trim($user["nachname"] ?? "");
$fullName = trim($vorname . " " . $nachname);
if ($fullName !== "") {
$authorName = $fullName;
}
}
sendCommentResponse(
true,
"Der Kommentar wurde erfolgreich gespeichert.",
$articleId,
[
"commentId" => $commentId,
"author" => $_SESSION["user_email"],
"author" => $authorName,
"content" => $content,
"created" => date("Y-m-d H:i:s"),
"parentCommentId" => $parentCommentId
+10 -11
View File
@@ -76,10 +76,7 @@ class DatabaseArticleManager implements ArticleManagerDAO {
return intval($db->lastInsertId());
} catch (PDOException $e) {
// NEU: Die rohe PDO-Fehlermeldung wird nicht mehr direkt in die
// eigene Exception übernommen (Kapselung), sondern durch eine
// generische, sprechende Meldung ersetzt - analog zu den übrigen
// Methoden dieser Klasse und zu DatabaseUserManager.
throw new InternalServerErrorException("internal_error");
}
}
@@ -284,14 +281,14 @@ class DatabaseArticleManager implements ArticleManagerDAO {
$db = $this->getConnection();
$sql = "SELECT id, title, content, author, category, tags, created
FROM articles
WHERE title LIKE :keyword
OR content LIKE :keyword
OR tags LIKE :keyword";
FROM articles
WHERE title LIKE :keyword
OR content LIKE :keyword
OR tags LIKE :keyword;";
$command = $db->prepare($sql);
// Wildcards für die Suche hinzufügen
// Wildcards für die SQL-Suche hinzufügen
$searchParam = '%' . $cleankeyword . '%';
$command->execute([
@@ -302,10 +299,11 @@ class DatabaseArticleManager implements ArticleManagerDAO {
$filteredArticles = [];
foreach ($rows as $row) {
$likes = $this->getLikesForArticle(intval($row['id']));
$articleId = intval($row['id']);
$likes = $this->getLikesForArticle($articleId);
$filteredArticles[] = new Article(
intval($row['id']),
$articleId,
$row['title'] ?? '',
$row['content'] ?? '',
$row['author'] ?? '',
@@ -323,6 +321,7 @@ class DatabaseArticleManager implements ArticleManagerDAO {
}
}
/**
* Holt alle User-IDs, die einen bestimmten Beitrag geliked haben.
*