]>
Commit | Line | Data |
---|---|---|
6df4b805 MR |
1 | <?php |
2 | /* vim: set ts=4 tw=0 sw=4 noet: */ | |
b95d1cdb MR |
3 | require_once 'config.php'; |
4 | require_once $CFG->root . 'lib/db_factory.php'; | |
5 | require_once $CFG->root . 'lib/utils.inc.php'; | |
6df4b805 | 6 | |
b95d1cdb MR |
7 | $util = Utils::getInstance(); |
8 | unset($_SESSION['mailInfo']); | |
6df4b805 | 9 | |
b95d1cdb MR |
10 | if ($util->isLoggedIn()) { |
11 | if (isset($_GET['rowsperpage'])) { | |
12 | $rowsPerPage = $_GET['rowsperpage']; | |
13 | } else { | |
14 | $rowsPerPage = 20; | |
15 | } | |
6df4b805 | 16 | |
b95d1cdb MR |
17 | $pageNum = 1; |
18 | if (isset($_GET['page'])) { | |
19 | $pageNum = $_GET['page']; | |
20 | } | |
6df4b805 | 21 | |
b95d1cdb | 22 | $offset = ($pageNum - 1) * $rowsPerPage; |
6df4b805 | 23 | |
b95d1cdb MR |
24 | $util->setHeading('Quarantine Administration'); |
25 | echo $util->getHeader(); | |
26 | echo $util->getHeading(); | |
27 | ||
28 | echo "<span class=\"user\">{$util->getUser()} | |
bb06f172 | 29 | <a title=\"Logout\" href=\"auth.php?op=logout\">Logout</a></span>"; |
b95d1cdb MR |
30 | $which = ($util->isAdmin() == true) ? 'all' : $util->getUser(); |
31 | $rows = $DB->getQMails($offset, $rowsPerPage, $which); | |
32 | $numrows = $DB->numRows(); | |
33 | echo "<span class=\"total-rows\">$numrows quarantined mail(s)</span>"; | |
34 | echo "<table><tr>"; | |
6df4b805 | 35 | echo "<table><tr><th>Received</th><th>Cause</th>"; |
219d049c | 36 | echo "<th>Sender</th><th>Recipient</th><th>Subject</th><th>Action</th>"; |
60348de6 MR |
37 | echo "<th><input name=\"multiselect\" type=\"checkbox\" "; |
38 | echo "onchange=\"javascript: updateAction(this)\" /></th>"; | |
b95d1cdb | 39 | echo "</tr>"; |
6df4b805 | 40 | |
b95d1cdb MR |
41 | $mailInfo = array(); |
42 | $i = 0; | |
43 | foreach ($rows as $row) { | |
44 | if ($i % 2) | |
45 | echo '<tr class="bg_odd">'; | |
46 | else | |
47 | echo '<tr class="bg_even">'; | |
48 | $id = $row->mail_id; | |
49 | $mailInfo[$id] = serialize($row); | |
50 | $url = urlencode($id); | |
5c7b972e | 51 | $checkbox = "<input name=\"action\" type=\"checkbox\" value=\"$url\" />"; |
bb06f172 MR |
52 | $recipient = "<a title=\"Show Report\" href=\"mail_report.php?id=$url\">{$row->recipient}</a>"; |
53 | $action = "<a title=\"Release Mail\" href=\"quarantine.php?id=$url&op=release\">"; | |
b95d1cdb | 54 | $action .= "<img class=\"nav-img\" src=\"pics/release.png\" alt=\"Release\" /></a>"; |
bb06f172 | 55 | $action .= " <a title=\"Delete Mail\" href=\"quarantine.php?id=$url&op=delete\">"; |
b95d1cdb MR |
56 | $action .= "<img class=\"nav-img\" src=\"pics/delete.png\" alt=\"Delete\" /></a>"; |
57 | $sender = $row->sender; | |
58 | $received = strftime("%c", $row->time_iso); | |
59 | $quaratinefor = $util->convertContent($row->quaratinefor); | |
60 | $subject = $row->subject; | |
6df4b805 MR |
61 | echo "<td>$received</td><td class=\"nav-action\">". |
62 | "$quaratinefor</td><td>$sender</td><td>$recipient</td>". | |
f60d3406 | 63 | "<td>$subject</td><td class=\"nav-action\">$action</td><td class=\"nav-action\">$checkbox</td></tr>"; |
b95d1cdb MR |
64 | $i++; |
65 | } | |
66 | $_SESSION['mailInfo'] = $mailInfo; | |
67 | echo "</table>"; | |
68 | ||
69 | $maxPage = ceil($numrows/$rowsPerPage); | |
70 | $self = $_SERVER['PHP_SELF']; | |
71 | ||
72 | if ($pageNum > 1) { | |
73 | $page = $pageNum - 1; | |
61fd79d7 | 74 | $prev = " <a title=\"Prev Page\" href=\"$self?page=$page&rowsperpage=$rowsPerPage\" |
44aa932e | 75 | class='whitefooter'><img class=\"nav-img\" src=\"pics/go-previous-symbolic.svg\" alt=\"Previous\" /></a> "; |
61fd79d7 MR |
76 | $first = " <a title=\"First Page\" href=\"$self?page=1&rowsperpage=$rowsPerPage\" |
77 | class='whitefooter'><img class=\"nav-img\" src=\"pics/go-first-symbolic.svg\" alt=\"First\" /></a> "; | |
b95d1cdb MR |
78 | } else { |
79 | $prev = ' '; // we're on page one, don't print previous link | |
80 | $first = ' '; // nor the first page link | |
81 | } | |
6df4b805 | 82 | |
b95d1cdb MR |
83 | if ($pageNum < $maxPage) { |
84 | $page = $pageNum + 1; | |
61fd79d7 | 85 | $next = " <a title=\"Next Page\" href=\"$self?page=$page&rowsperpage=$rowsPerPage\" |
44aa932e | 86 | class='whitefooter'><img class=\"nav-img\" src=\"pics/go-next-symbolic.svg\" alt=\"Next\" /></a> "; |
61fd79d7 MR |
87 | $last = " <a title=\"Last Page\" href=\"$self?page=$maxPage&rowsperpage=$rowsPerPage\" |
88 | class='whitefooter'><img class=\"nav-img\" src=\"pics/go-last-symbolic.svg\" alt=\"Last\" /></a> "; | |
b95d1cdb MR |
89 | } else { |
90 | $next = ' '; // we're on the last page, don't print next link | |
91 | $last = ' '; // nor the last page link | |
92 | } | |
93 | $marked = $DB->getMarked($which); | |
94 | $_SESSION['marked'] = serialize($marked); | |
95 | echo '<input class="mail-purge" type="button" value="Purge Mails ('. | |
96 | count($marked).')" onclick="javascript: location.href=\'quarantine.php?op=purge\'"/>'; | |
ebed9332 MR |
97 | echo '<input class="mail-purge" type="button" value="Release checked" |
98 | onclick="javascript: checkAction(\'release\');"/>'; | |
99 | echo '<input class="mail-purge" type="button" value="Delete checked" | |
100 | onclick="javascript: checkAction(\'delete\');"/>'; | |
b95d1cdb MR |
101 | echo "<p class=\"page-nav\">$first$prev Showing page $pageNum of |
102 | $maxPage pages $next$last</p>"; | |
6df4b805 | 103 | |
b95d1cdb MR |
104 | echo $util->getFooter(); |
105 | } else { | |
106 | header('Location: auth.php'); | |
107 | } | |
6df4b805 | 108 | ?> |