forked from GibbonEdu/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notifications.php
executable file
·151 lines (140 loc) · 5.58 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
<?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 <https://www.gnu.org/licenses/>.
*/
@session_start() ;
if (is_null($_SESSION[$guid]["username"])) {
print "<div class='error'>" ;
print _("You do not have access to this action.") ;
print "</div>" ;
}
else {
print "<div class='trail'>" ;
print "<div class='trailHead'><a href='" . $_SESSION[$guid]["absoluteURL"] . "'>" . _("Home") . "</a> > </div><div class='trailEnd'>" . _("Notifications") . "</div>" ;
print "</div>" ;
if (isset($_GET["deleteReturn"])) { $deleteReturn=$_GET["deleteReturn"] ; } else { $deleteReturn="" ; }
$deleteReturnMessage="" ;
$class="error" ;
if (!($deleteReturn=="")) {
if ($deleteReturn=="fail1") {
$deleteReturnMessage=_("Your request failed because your inputs were invalid.") ;
}
else if ($deleteReturn=="fail2") {
$deleteReturnMessage=_("Your request failed due to a database error.") ;
}
else if ($deleteReturn=="success0") {
$deleteReturnMessage=_("Your request was completed successfully.") ;
$class="success" ;
}
print "<div class='$class'>" ;
print $deleteReturnMessage;
print "</div>" ;
}
if (isset($_GET["updateReturn"])) { $updateReturn=$_GET["updateReturn"] ; } else { $updateReturn="" ; }
$updateReturnMessage="" ;
$class="error" ;
if (!($updateReturn=="")) {
if ($updateReturn=="fail1") {
$updateReturnMessage=_("Your request failed because your inputs were invalid.") ;
}
else if ($updateReturn=="fail2") {
$updateReturnMessage=_("Your request failed due to a database error.") ;
}
else if ($updateReturn=="success0") {
$updateReturnMessage=_("Your request was completed successfully.") ;
$class="success" ;
}
print "<div class='$class'>" ;
print $updateReturnMessage;
print "</div>" ;
}
//Get notifications
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)
UNION
(SELECT gibbonNotification.*, 'System' AS source FROM gibbonNotification WHERE gibbonModuleID IS NULL AND gibbonPersonID=:gibbonPersonID2)
ORDER BY timestamp DESC, source, text" ;
$resultNotifications=$connection2->prepare($sqlNotifications);
$resultNotifications->execute($dataNotifications);
}
catch(PDOException $e) {
print "<div class='error'>" . $e->getMessage() . "</div>" ;
}
print "<h2>" ;
print _("Notifications") . " <span style='font-size: 65%; font-style: italic; font-weight: normal'> x" . $resultNotifications->rowCount() . "</span>" ;
print "</h2>" ;
print "<div class='linkTop'>" ;
print "<a onclick='return confirm(\"Are you sure you want to delete these records.\")' title='" . _('Delete All Notifications') . "' href='" . $_SESSION[$guid]["absoluteURL"] . "/notificationsDeleteAllProcess.php'><img style='opacity: 0.8; vertical-align: -75%' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/notifications_on_dark.png'>" ;
print "</div>" ;
print "<table cellspacing='0' style='width: 100%'>" ;
print "<tr class='head'>" ;
print "<th>" ;
print _("Source") ;
print "</th>" ;
print "<th>" ;
print _("Date") ;
print "</th>" ;
print "<th>" ;
print _("Message") ;
print "</th>" ;
print "<th>" ;
print _("Count") ;
print "</th>" ;
print "<th style='width: 100px'>" ;
print _("Actions") ;
print "</th>" ;
print "</tr>" ;
$count=0;
$rowNum="odd" ;
if ($resultNotifications->rowCount()<1) {
print "<tr class=$rowNum>" ;
print "<td colspan=5>" ;
print _("There are no records to display.") ;
print "</td>" ;
print "</tr>" ;
}
else {
while ($row=$resultNotifications->fetch() AND $count<20) {
if ($count%2==0) {
$rowNum="even" ;
}
else {
$rowNum="odd" ;
}
$count++ ;
//COLOR ROW BY STATUS!
print "<tr class=$rowNum>" ;
print "<td>" ;
print $row["source"] ;
print "</td>" ;
print "<td>" ;
print dateConvertBack($guid, substr($row["timestamp"],0,10)) ;
print "</td>" ;
print "<td>" ;
print $row["text"] ;
print "</td>" ;
print "<td>" ;
print $row["count"] ;
print "</td>" ;
print "<td>" ;
print "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/notificationsActionProcess.php?action=" . urlencode($row["actionLink"]) . "&gibbonNotificationID=" . $row["gibbonNotificationID"] . "'><img title='" . _('Action & Delete') . "' src='./themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/plus.png'/></a> " ;
print "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/notificationsDeleteProcess.php?gibbonNotificationID=" . $row["gibbonNotificationID"] . "'><img title='" . _('Delete') . "' src='./themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/garbage.png'/></a> " ;
print "</td>" ;
print "</tr>" ;
}
}
print "</table>" ;
}
?>