-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommentMenu.php
54 lines (43 loc) · 1.44 KB
/
CommentMenu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
require_once 'Include/Load.php';
$session = App::getSession();
$link = App::getDatabase();
$user = App::getUser();
$user->restrict();
if ($user->has('id')){
$id = App::get('id');
} else {
App::redirect('Posts.php');
}
$comment = $link->query('SELECT * FROM comments WHERE id = :id', ['id' => $id])->fetch();
?>
<?php require_once 'Include/Header.php'; ?>
<div id="navBar">
<h2>Comment Menu</h2>
<?php if ($comment): ?>
<?php if ($session->getKey('user_infos')->id === $comment->user_id): ?>
<a href="EditComment.php?id=<?php echo $id; ?>" class="nav-links">
<span class="material-symbols-outlined">edit</span>
<span class="icon-text">Modify Comment</span>
</a>
<a href="#" class="nav-links" id="deleteComment">
<span class="material-symbols-outlined">delete</span>
<span class="icon-text">Delete Comment</span>
</a>
<?php endif; ?>
<?php else: ?>
<?php App::redirect('Posts.php'); ?>
<?php endif; ?>
</div>
<script>
let deleteCommentLink = document.getElementById('deleteComment');
deleteCommentLink.addEventListener('click', function (evt) {
evt.preventDefault()
if (window.confirm('Your are deleting your Comment')){
window.location = "DeleteComment.php?id=<?php echo $id ?>";
}
})
</script>
<?php require_once 'Include/Mode.php'; ?>
</body>
</html>