-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifications.php
More file actions
executable file
·176 lines (154 loc) · 4.39 KB
/
Copy pathnotifications.php
File metadata and controls
executable file
·176 lines (154 loc) · 4.39 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
$page_title = "Notifications";
include 'includes/header.php';
// Redirect if not logged in
if (!is_logged_in()) {
header("Location: login.php");
exit;
}
$user_id = $_SESSION['user_id'];
// Mark all as read if requested
if (isset($_GET['mark_all_read'])) {
mark_all_notifications_read($user_id);
header("Location: notifications.php");
exit;
}
// Get all notifications
$notifications = get_notifications($user_id, 50);
?>
<div class="content-area">
<div class="notifications-header" style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
<h1>Your Notifications</h1>
<a href="notifications.php?mark_all_read=1" class="btn">Mark All as Read</a>
</div>
<div class="card">
<?php if (count($notifications) > 0): ?>
<div class="notifications-list">
<?php foreach ($notifications as $notification): ?>
<a href="<?php echo $notification['link']; ?>" class="notification-item <?php echo $notification['is_read'] ? '' : 'unread'; ?>" data-id="<?php echo $notification['notification_id']; ?>">
<div class="notification-content"><?php echo $notification['content']; ?></div>
<div class="notification-details">
<?php if ($notification['actor_name']): ?>
<span class="notification-actor">From: <?php echo htmlspecialchars($notification['actor_name']); ?></span>
<?php endif; ?>
<span class="notification-time"><?php echo time_elapsed_string($notification['created_at']); ?></span>
</div>
</a>
<?php endforeach; ?>
</div>
<?php else: ?>
<div class="no-notifications" style="padding: 30px; text-align: center;">
<p>You don't have any notifications yet.</p>
<a href="index.php" class="btn" style="margin-top: 15px;">Browse Posts</a>
</div>
<?php endif; ?>
</div>
</div>
<style>
.notification-dropdown {
position: relative;
}
.notification-bell {
position: relative;
display: inline-block;
}
.notification-badge {
position: absolute;
top: -8px;
right: -8px;
background-color: var(--secondary-color);
color: white;
border-radius: 50%;
padding: 0 5px;
font-size: 0.7rem;
min-width: 15px;
height: 15px;
line-height: 15px;
text-align: center;
}
.dropdown-content {
display: none;
position: absolute;
right: 0;
background-color: var(--card-bg);
min-width: 300px;
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
border-radius: 4px;
z-index: 101;
}
.notification-dropdown:hover .dropdown-content,
.notification-dropdown:focus .dropdown-content {
display: block;
}
.dropdown-header, .dropdown-footer {
padding: 10px;
border-bottom: 1px solid var(--border-color);
display: flex;
justify-content: space-between;
align-items: center;
}
.dropdown-footer {
border-top: 1px solid var(--border-color);
border-bottom: none;
}
.dropdown-header h3 {
margin: 0;
font-size: 1rem;
}
.notification-list {
max-height: 300px;
overflow-y: auto;
}
.notification-item {
display: block;
padding: 10px;
border-bottom: 1px solid var(--border-color);
transition: background-color 0.3s;
}
.notification-item:hover {
background-color: #f5f5f5;
text-decoration: none;
}
.notification-item.unread {
background-color: #e8f4fd;
}
.notification-content {
margin-bottom: 5px;
}
.notification-time {
font-size: 0.8rem;
color: var(--text-secondary);
}
.no-notifications {
padding: 15px;
text-align: center;
color: var(--text-secondary);
}
/* .notifications-list {
border-top: 1px solid var(--border-color);
}
.notification-item {
display: block;
padding: 15px;
border-bottom: 1px solid var(--border-color);
transition: background-color 0.3s;
}
.notification-item:hover {
background-color: #f5f5f5;
text-decoration: none;
}
.notification-item.unread {
background-color: #e8f4fd;
}
.notification-content {
margin-bottom: 8px;
color: var(--text-color);
}
.notification-details {
display: flex;
justify-content: space-between;
font-size: 0.8rem;
color: var(--text-secondary);
} */
</style>
<?php include 'includes/footer.php'; ?>