Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
de9d9e2965
@ -21,6 +21,18 @@ if ($checkResult->num_rows === 0) {
|
||||
include __DIR__ . '/404.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_review']) && isset($_POST['delete_review_id'])) {
|
||||
if (!empty($_SESSION['user_roles']) && in_array('ADMIN', $_SESSION['user_roles'], true)) {
|
||||
$deleteId = (int)$_POST['delete_review_id'];
|
||||
$delStmt = $conn->prepare("DELETE FROM reviews WHERE reviewID = ?");
|
||||
$delStmt->bind_param("i", $deleteId);
|
||||
$delStmt->execute();
|
||||
$delStmt->close();
|
||||
echo "<script>window.location.href = 'productpage.php?id=" . $productId . "';</script>";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
@ -340,7 +352,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_SESSION['user_id'])) {
|
||||
<?php
|
||||
// HIER ANGEPASST: profilePicture und createdAt zum SELECT hinzugefügt
|
||||
$stmt = mysqli_prepare($conn,
|
||||
" SELECT rating, comment, users.displayname, users.profilePicture, reviews.createdAt
|
||||
" SELECT reviews.reviewID, rating, comment, users.displayname, users.profilePicture, reviews.createdAt
|
||||
FROM reviews
|
||||
INNER JOIN users ON reviews.userID = users.userID
|
||||
WHERE productID = ? ORDER BY rating DESC");
|
||||
@ -396,6 +408,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_SESSION['user_id'])) {
|
||||
<div class="review-comment">
|
||||
<?= nl2br(htmlspecialchars($review['comment'])) ?>
|
||||
</div>
|
||||
<?php if (!empty($_SESSION['user_roles']) && in_array('ADMIN', $_SESSION['user_roles'], true)): ?>
|
||||
<div class="review-admin-actions" style="margin-top: 10px; text-align: right;">
|
||||
<form method="post" action="productpage.php?id=<?= $productId ?>" onsubmit="return confirm('Bewertung wirklich löschen?');">
|
||||
<input type="hidden" name="delete_review_id" value="<?= $review['reviewID'] ?>">
|
||||
<button type="submit" name="delete_review" style="background-color: #ef4444; color: white; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 0.8rem;">Löschen</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user