forked from GibbonEdu/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotifications.php
executable file
·189 lines (173 loc) · 7.81 KB
/
notifications.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
188
189
<?php
/*
Gibbon, Flexible & Open School System
Copyright (C) 2010, Ross Parker
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@session_start();
if (!isset($_SESSION[$guid]['username'])) {
echo "<div class='error'>";
echo __($guid, 'You do not have access to this action.');
echo '</div>';
} else {
echo "<div class='trail'>";
echo "<div class='trailHead'><a href='".$_SESSION[$guid]['absoluteURL']."'>".__($guid, 'Home')."</a> > </div><div class='trailEnd'>".__($guid, 'Notifications').'</div>';
echo '</div>';
if (isset($_GET['return'])) {
returnProcess($guid, $_GET['return'], null, null);
}
echo "<div class='linkTop'>";
echo "<a onclick='return confirm(\"Are you sure you want to delete these records.\")' href='".$_SESSION[$guid]['absoluteURL']."/notificationsDeleteAllProcess.php'>".__($guid, 'Delete All Notifications')." <img style='vertical-align: -25%' src='".$_SESSION[$guid]['absoluteURL'].'/themes/'.$_SESSION[$guid]['gibbonThemeName']."/img/garbage.png'></a>";
echo '</div>';
//Get and show newnotifications
try {
$dataNotifications = array('gibbonPersonID' => $_SESSION[$guid]['gibbonPersonID'], 'gibbonPersonID2' => $_SESSION[$guid]['gibbonPersonID']);
$sqlNotifications = "(SELECT gibbonNotification.*, gibbonModule.name AS source FROM gibbonNotification JOIN gibbonModule ON (gibbonNotification.gibbonModuleID=gibbonModule.gibbonModuleID) WHERE gibbonPersonID=:gibbonPersonID AND status='New')
UNION
(SELECT gibbonNotification.*, 'System' AS source FROM gibbonNotification WHERE gibbonModuleID IS NULL AND gibbonPersonID=:gibbonPersonID2 AND status='New')
ORDER BY timestamp DESC, source, text";
$resultNotifications = $connection2->prepare($sqlNotifications);
$resultNotifications->execute($dataNotifications);
} catch (PDOException $e) {
echo "<div class='error'>".$e->getMessage().'</div>';
}
echo '<h2>';
echo __($guid, 'New Notifications')." <span style='font-size: 65%; font-style: italic; font-weight: normal'> x".$resultNotifications->rowCount().'</span>';
echo '</h2>';
echo "<table cellspacing='0' style='width: 100%'>";
echo "<tr class='head'>";
echo "<th style='width: 18%'>";
echo __($guid, 'Source');
echo '</th>';
echo "<th style='width: 12%'>";
echo __($guid, 'Date');
echo '</th>';
echo "<th style='width: 51%'>";
echo __($guid, 'Message');
echo '</th>';
echo "<th style='width: 7%'>";
echo __($guid, 'Count');
echo '</th>';
echo "<th style='width: 12%'>";
echo __($guid, 'Actions');
echo '</th>';
echo '</tr>';
$count = 0;
$rowNum = 'odd';
if ($resultNotifications->rowCount() < 1) {
echo "<tr class=$rowNum>";
echo '<td colspan=5>';
echo __($guid, 'There are no records to display.');
echo '</td>';
echo '</tr>';
} else {
while ($row = $resultNotifications->fetch() and $count < 20) {
if ($count % 2 == 0) {
$rowNum = 'even';
} else {
$rowNum = 'odd';
}
++$count;
//COLOR ROW BY STATUS!
echo "<tr class=$rowNum>";
echo '<td>';
echo $row['source'];
echo '</td>';
echo '<td>';
echo dateConvertBack($guid, substr($row['timestamp'], 0, 10));
echo '</td>';
echo '<td>';
echo $row['text'];
echo '</td>';
echo '<td>';
echo $row['count'];
echo '</td>';
echo '<td>';
echo "<a href='".$_SESSION[$guid]['absoluteURL'].'/notificationsActionProcess.php?action='.urlencode($row['actionLink']).'&gibbonNotificationID='.$row['gibbonNotificationID']."'><img title='".__($guid, 'Action & Archive')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/plus.png'/></a> ";
echo "<a href='".$_SESSION[$guid]['absoluteURL'].'/notificationsDeleteProcess.php?gibbonNotificationID='.$row['gibbonNotificationID']."'><img title='".__($guid, 'Delete')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/garbage.png'/></a> ";
echo '</td>';
echo '</tr>';
}
}
echo '</table>';
//Get and show newnotifications
try {
$dataNotifications = array('gibbonPersonID' => $_SESSION[$guid]['gibbonPersonID'], 'gibbonPersonID2' => $_SESSION[$guid]['gibbonPersonID']);
$sqlNotifications = "(SELECT gibbonNotification.*, gibbonModule.name AS source FROM gibbonNotification JOIN gibbonModule ON (gibbonNotification.gibbonModuleID=gibbonModule.gibbonModuleID) WHERE gibbonPersonID=:gibbonPersonID AND status='Archived')
UNION
(SELECT gibbonNotification.*, 'System' AS source FROM gibbonNotification WHERE gibbonModuleID IS NULL AND gibbonPersonID=:gibbonPersonID2 AND status='Archived')
ORDER BY timestamp DESC, source, text LIMIT 0, 50";
$resultNotifications = $connection2->prepare($sqlNotifications);
$resultNotifications->execute($dataNotifications);
} catch (PDOException $e) {
echo "<div class='error'>".$e->getMessage().'</div>';
}
echo '<h2>';
echo __($guid, 'Archived Notifications');
echo '</h2>';
echo "<table cellspacing='0' style='width: 100%'>";
echo "<tr class='head'>";
echo "<th style='width: 18%'>";
echo __($guid, 'Source');
echo '</th>';
echo "<th style='width: 12%'>";
echo __($guid, 'Date');
echo '</th>';
echo "<th style='width: 51%'>";
echo __($guid, 'Message');
echo '</th>';
echo "<th style='width: 7%'>";
echo __($guid, 'Count');
echo '</th>';
echo "<th style='width: 12%'>";
echo __($guid, 'Actions');
echo '</th>';
echo '</tr>';
$count = 0;
$rowNum = 'odd';
if ($resultNotifications->rowCount() < 1) {
echo "<tr class=$rowNum>";
echo '<td colspan=5>';
echo __($guid, 'There are no records to display.');
echo '</td>';
echo '</tr>';
} else {
while ($row = $resultNotifications->fetch() and $count < 20) {
if ($count % 2 == 0) {
$rowNum = 'even';
} else {
$rowNum = 'odd';
}
++$count;
//COLOR ROW BY STATUS!
echo "<tr class=$rowNum>";
echo '<td>';
echo $row['source'];
echo '</td>';
echo '<td>';
echo dateConvertBack($guid, substr($row['timestamp'], 0, 10));
echo '</td>';
echo '<td>';
echo $row['text'];
echo '</td>';
echo '<td>';
echo $row['count'];
echo '</td>';
echo '<td>';
echo "<a href='".$_SESSION[$guid]['absoluteURL'].'/notificationsActionProcess.php?action='.urlencode($row['actionLink']).'&gibbonNotificationID='.$row['gibbonNotificationID']."'><img title='".__($guid, 'Action')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/plus.png'/></a> ";
echo "<a href='".$_SESSION[$guid]['absoluteURL'].'/notificationsDeleteProcess.php?gibbonNotificationID='.$row['gibbonNotificationID']."'><img title='".__($guid, 'Delete')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/garbage.png'/></a> ";
echo '</td>';
echo '</tr>';
}
}
echo '</table>';
}