-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.php
188 lines (154 loc) · 5.61 KB
/
dashboard.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
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
177
178
179
180
181
182
183
184
185
186
187
<?php
require_once 'core/init.php';
require_once 'core/func/profiles.php';
require_once 'core/func/notifications.php';
verify_login();
if (user_is_at_least_role(ROLE_ADMIN)) {
$display = 1;
}
else{
$display = 2;
}
?>
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<!-- CONTENT STARTS HERE -->
<?php if($display == 2 && user_can(PERM_VIEW_PROFILES)){?><!-- FEATURED USERS -->
<div id="featured">
<div class="featuredHead">
<p><b>Featured Users</b></p>
</div>
<div class="pictures">
<ul><!-- Div will fit 8 profiles -->
<?php
$rUsers = get_random_profiles($_SESSION['user_id']);
if ($rUsers) {
foreach ($rUsers as $rUser) {
?>
<li>
<span><a href="" onClick="get_profile(<?=$rUser->user_id?>)"><img src=<?php echo get_profile_image(IMG_SMALL, $rUser->user_id); ?>></a></span>
<span><?php echo $rUser->first_name ?></span>
</li>
<?php
}
}
?>
</ul>
</div>
</div>
<?php } ?>
<!-- NOTIFICATIONS -->
<?php if($display == 2){ ?>
<div id="notifications">
<div class="notificationHead">
<p><b>Notifications</b></p>
</div>
<div class="notePictures">
<ul>
<?php
$notifications = get_notifications($_SESSION['user_id']);
if ($notifications) {
foreach ($notifications as $notification) {
?>
<li class="<?php if ($notification->seen) echo 'seen'; ?>" onClick="seen_notification(this, <?=$notification->notification_id?>)">
<span><img src=<?php echo get_profile_image(IMG_THUMB, $notification->sender_id); ?>></span>
<i class="fa fa-trash" onClick="delete_notification(this, <?=$notification->notification_id?>)"></i>
<span><?php echo truncate($notification->content, $length=65, $dots="...") ?></span>
</li>
<?php
}
}
?>
</ul>
</div>
</div>
<?php } ?>
<?php $profile = get_profile($_SESSION['user_id'])?>
<?php if($display == 2 && $profile){ ?><!-- PROFILE OVERVIEW -->
<div id="pOverview">
<div class="pOverviewLink">
<i class="fa fa-user fa-2x"></i>
<p><b>Your Profile</b></p>
</div>
<a href="" onClick="get_profile(<?=$_SESSION['user_id']?>)"><img src=<?php echo get_profile_image(IMG_MEDIUM, $_SESSION['user_id']); ?>></a>
<p><?=$_SESSION['first_name']?> <?=$_SESSION['last_name']?></p>
<p><?php echo $profile->age; ?></p>
</div>
<?php } ?>
<?php if($display == 1){ ?><!-- USER REPORTS -->
<div id="userReports">
<div class="userReportsHead">
<p><b>User Reports</b></p>
</div>
<div class="reportPictures">
<ul>
<table id="heading">
<tr>
<td class="A">Reporter</td>
<td class="B">Reported</td>
<td class="C">Reason</td>
<td class="D">Time</td>
</tr>
</table>
<?php
$reports = get_report_notifications();
if ($reports) {
foreach ($reports as $report) {
?>
<li class="<?php if ($report->seen) echo 'seen'; ?>" onClick="get_report(<?=$report->notification_id?>); seen_notification(this, <?=$report->notification_id?>);">
<span>
<a href="" onClick="get_profile(<?=$report->sender_id?>)"><img src=<?php echo get_profile_image(IMG_THUMB, $report->sender_id); ?>></a>
<a href="" onClick="get_profile(<?=$report->user_id?>)"><img src=<?php echo get_profile_image(IMG_THUMB, $report->user_id); ?>></a>
</span>
<i class="fa fa-trash" onClick="delete_notification(this, <?=$report->notification_id?>)"></i>
<span style="margin-left: 15px;"><?php echo truncate($report->content, $length=65, $dots="...") ?></span>
<span style="position: relative;line-height: 51px;float:right;margin: 0 15px 0 10px;"> <?php echo $report->date_time ?> </span>
</li>
<?php
}
}
?>
</ul>
</div>
</div>
<?php } ?>
<div id="clearDash"></div>
<!--CONTENT HERE -->
<script type="text/javascript">
function delete_notification(el, notification_id) {
event.preventDefault();
$.post( "ajax/delete_notification.php", {notification_id:notification_id}, function( data ) {
if (data == 'success') {
$(el).parent().remove();
}
});
}
function seen_notification(el,notification_id){
event.preventDefault();
$.post("ajax/set_notification.php", {notification_id:notification_id}, function( data ) {
if (data == 'success') {
//CSS
$(el).css('background-color','rgba(255, 240, 221, 0.0)');
}
});
}
function get_profile(id) {
event.preventDefault();
$.post('ajax/get_profile.php', {id:id}, function(data) {
// Callback function
show_modal(data, 'modal-profile');
});
}
function get_report(id) {
event.preventDefault();
$.post('ajax/get_report.php', {id:id}, function(data) {
// Callback function
show_modal(data, "modal-dialog dialog-user-report");
});
}
</script>
<!-- REPORT MODAL FOR SHOW MORE -->
</main><!-- #main -->
</div><!-- #primary -->
<?php get_footer(); ?>