configured
[bMailZu.git] / templates / quarantine.template.php
blobbabd6ccbe31c8162776b4adad2af56052ebd5dfa
1 <?php
2 /**
3 * This file provides output functions for messagesIndex.php
4 * No data manipulation is done in this file
5 * @author Samuel Tran <stran2005@users.sourceforge.net>
6 * @author Brian Wong <bwsource@users.sourceforge.net>
7 * @author Nicolas Peyrussie <peyrouz@users.sourceforge.net>
8 * @author Jeremy Fowler <jfowler06@users.sourceforge.net>
9 * @version 04-03-2007
10 * @package Templates
12 * Copyright (C) 2005 - 2007 MailZu
13 * License: GPL, see LICENSE
17 /**
18 * Print table listing messages in quarantine
19 * This function prints a table of all spam/attachment in quarantine
20 * for the current user. It also
21 * provides a way for them to release and delete
22 * their messages
23 * @param string $content_type 'B', 'S', ...
24 * @param mixed $res array of message data
25 * @param integer $page current page number
26 * @param string $order previous order field
27 * @param string $vert previous vertical order
28 * @param string $numRows total number of rows in table
30 function showMessagesTable($content_type, $res, $page, $order, $vert, $numRows = 0) {
31 global $link;
32 global $conf;
34 // grab the display size limit set in config.php
35 $sizeLimit = isset ( $conf['app']['displaySizeLimit'] ) && is_numeric( $conf['app']['displaySizeLimit'] ) ?
36 $conf['app']['displaySizeLimit'] : 50;
38 if ('ASC' == $vert) {
39 $new_vert = 'DESC';
40 $mouseover_text = translate('Sort by descending order');
41 } else {
42 $new_vert='ASC';
43 $mouseover_text = translate('Sort by ascending order');
46 // If there are messages in quarantine, draw tables
47 if ( $res ) {
48 // $res is only a subset of the message quarantine
49 // Its number of rows is $sizeLimit
50 $count = $numRows;
51 $start_entry = 0;
52 $end_entry = count($res);
53 $query_string = $_SERVER['QUERY_STRING'];
55 $pager_html = ( $count > $sizeLimit ) ? CmnFns::genMultiPagesLinks( $page, $sizeLimit, $count) : ''; ?>
57 <form name="messages_process_form" action="messagesProcessing.php" method="POST">
59 <input type="hidden" name="ctype" value="<? echo $content_type; ?>">
60 <input type="hidden" name="query_string" value="<? echo $query_string; ?>">
62 <? // Draw 'Release', 'Delete' and 'Delete All' buttons
63 printActionButtons((! CmnFns::didSearch() && ! ("Site Quarantine" == $_SESSION['sessionNav'])) );
64 // Draw 'Select All, Clear All' and multi pages links
65 printSelectAndPager($pager_html);
67 flush(); ?>
69 <table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
70 <tr>
71 <td class="tableBorder">
73 <!-- Draw 'Showing messages ...' table -->
74 <table width="100%" border="0" cellspacing="1" cellpadding="0">
75 <tr>
76 <td colspan="5" class="tableTitle">
77 <? echo translate('Showing messages',
78 array( number_format($page*$sizeLimit+1), number_format($page*$sizeLimit+$end_entry), $count )); ?>
79 </td>
81 <td class="tableTitle">
82 <div align="right">
83 <? $link->doLink('javascript: help(\'msg_index\');', '?', '', 'color: #FFFFFF;',
84 translate('Help') . ' - ' . translate('My Quarantine')) ?>
85 </div>
86 </td>
87 </tr>
88 </table>
90 <!-- Print messages table -->
91 <table width="100%" border="0" cellspacing="1" cellpadding="0">
93 <!-- Print table's headers -->
94 <tr class="rowHeaders">
95 <td width="3%">&nbsp;</td>
96 <? if ( (count($_SESSION['sessionMail']) > 1) || ((Auth::isMailAdmin()) &&
97 ("Site Quarantine" == $_SESSION['sessionNav'] || "Site Pending Requests" == $_SESSION['sessionNav']))) { ?>
98 <td width="15%" <? echo "recip.email"==$order?' class="reservedCell"':''; ?>>
99 <? $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars( array('order','vert'))
100 . '&amp;order=recip.email&amp;vert=' . $new_vert, translate('To'), '', '', $mouseover_text) ?>
101 </td>
102 <? } ?>
103 <td width="15%" <? echo "from_addr"==$order?' class="reservedCell"':''; ?>>
104 <? $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars( array('order','vert'))
105 . '&amp;order=from_addr&amp;vert=' . $new_vert, translate('From'), '', '', $mouseover_text) ?>
106 </td>
107 <td width="40%" <? echo "msgs.subject"==$order?' class="reservedCell"':''; ?>>
108 <? $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars( array('order','vert'))
109 . '&amp;order=msgs.subject&amp;vert=' . $new_vert, translate('Subject'), '', '', $mouseover_text) ?>
110 </td>
111 <td width="10%" <? echo "msgs.time_num"==$order?' class="reservedCell"':''; ?>>
112 <? $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars( array('order','vert'))
113 . '&amp;order=msgs.time_num&amp;vert=' . $new_vert, translate('Date'), '', '', $mouseover_text) ?>
114 </td>
115 <td width="7%" <? echo "spam_level"==$order?' class="reservedCell"':''; ?>>
116 <? $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars( array('order','vert'))
117 . '&amp;order=spam_level&amp;vert=' . $new_vert, translate('Score'), '', '', $mouseover_text) ?>
118 </td>
119 <td width="10%" <? echo "msgs.content"==$order?' class="reservedCell"':''; ?>>
120 <? $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars( array('order','vert'))
121 . '&amp;order=msgs.content&amp;vert=' . $new_vert, translate('Content Type'), '', '', $mouseover_text) ?>
122 </td>
123 <? if ( (Auth::isMailAdmin()) &&
124 ("Site Quarantine" == $_SESSION['sessionNav'] || "Site Pending Requests" == $_SESSION['sessionNav'])) { ?>
125 <td width="10%" <? echo "mail_id"==$order?' class="reservedCell"':''; ?>>
126 <? $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars( array('order','vert'))
127 . '&amp;order=mail_id&amp;vert=' . $new_vert, translate('Mail ID'), '', '', $mouseover_text) ?>
128 </td>
129 <? } ?>
130 </tr>
132 <? // For each line in table, print message fields
133 for ($i = $start_entry; $i < $end_entry; $i++) {
134 $rs = $res[$i];
135 // Make sure that there is a clickable subject
136 $subject = $rs['subject'] ? htmlspecialchars($rs['subject']) : '(none)';
137 $from = $rs['from_addr'] ? htmlspecialchars($rs['from_addr']) : '(none)';
138 if ( (count($_SESSION['sessionMail']) > 1) || (Auth::isMailAdmin() &&
139 ("Site Quarantine" == $_SESSION['sessionNav'] || "Site Pending Requests" == $_SESSION['sessionNav']))) {
140 $to = $rs['email'] ? htmlspecialchars($rs['email']) : '(none)';
142 $class = ( $rs['content'] == 'V' ? 'cellVirus' : 'cellColor') . ($i%2);
143 echo "<tr class=\"$class\" align=\"center\">";
145 echo ' <td><input type="checkbox" onclick="ColorRow(this,\'lightyellow\')"
146 name="mail_id_array[]" value="' . $rs['mail_id'] . '_' . $rs['email'] . '"></td>';
147 if ( (count($_SESSION['sessionMail']) > 1) || (Auth::isMailAdmin() &&
148 ("Site Quarantine" == $_SESSION['sessionNav'] || "Site Pending Requests" == $_SESSION['sessionNav']))) {
149 echo ' <td>' . $to . '</td>';
151 echo ' <td>' . $from . '</td>';
152 echo ' <td>' .
153 // Only allow link to view mail if the mail is stored in SQL
154 ($rs['quar_type'] == 'Q' ?
155 $link->getLink('read_mail.php' . '?mail_id=' . urlencode($rs['mail_id']) .
156 "&amp;recip_email=" . urlencode($rs['email']) .
157 "&amp;$query_string", $subject, '', '',
158 translate('View this message'), ($rs['rs']=='v' || $rs['rs']=='p' ? false : true))
159 : "<b>$subject</b>") .
160 '</td>';
161 echo ' <td>' . CmnFns::formatDateTime($rs['time_num']) . '</td>';
163 echo ' <td>' . ( $rs['content'] == 'S' ? $rs['spam_level'] : 'N/A') . '</td>';
165 switch ($rs['content']) {
166 case 'S':
167 $type = translate('Spam');
168 break;
169 case 'B':
170 $type = translate('Banned');
171 break;
172 case 'V':
173 $type = translate('Virus');
174 break;
175 case 'H':
176 $type = translate('Bad Header');
177 break;
180 echo ( $rs['content'] == 'V' ? '<td class="typeVirus">' : '<td>') . $type . '</td>';
182 if ( Auth::isMailAdmin() &&
183 ("Site Quarantine" == $_SESSION['sessionNav'] || "Site Pending Requests" == $_SESSION['sessionNav'])) {
184 echo ' <td>' . $rs['mail_id'] . '</td>';
187 echo "</tr>\n";
188 } ?>
189 </table>
191 </td>
192 </tr>
193 </table>
195 <? // Draw 'Select All, Clear All' and multi pages links
196 printSelectAndPager($pager_html);
197 // Draw 'Release', 'Delete' and 'Delete All' buttons
198 printActionButtons((! CmnFns::didSearch() && ! ("Site Quarantine" == $_SESSION['sessionNav'])) );
200 unset($res); ?>
202 </form>
203 <? } else {
204 echo '<table width="100%" border="0" cellspacing="1" cellpadding="0">';
205 echo '<tr><td align="center">' . translate('There are no matching records.') . '</td></tr>';
206 echo '</table>';
212 * Print Search Engine
213 * $param $content_type
215 function printSearchEngine($content_type, $submit_page, $full_search = false) {
216 global $link;
218 <table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
219 <tr>
220 <td class="tableBorder">
221 <table width="100%" border="0" cellspacing="1" cellpadding="0">
222 <tr>
223 <td class="tableTitle">
224 <a href="javascript: void(0);" onclick="showHideSearch('search');">&#8250; <?=translate('Search')?></a>
225 </td>
226 <td class="tableTitle">
227 <div align="right">
228 <? $link->doLink('javascript: help(\'search\');', '?', '', 'color: #FFFFFF;', translate('Help') . ' - ' . translate('My Re
229 servations')) ?>
230 </div>
231 </td>
232 </tr>
233 </table>
234 <div id="search" style="display: <?= getShowHide('search') ?>">
235 <table width="100%" border="0" cellspacing="1" cellpadding="0">
236 <tr class="cellColor"><td><center><? CmnFns::searchEngine($content_type, $submit_page, $full_search); ?></center></td></tr>
237 </table>
238 </div>
239 </td>
240 </tr>
241 </table>
247 * Print 'Select All, Clear All' and multi pages links
248 * @param $pager_html multiple pages links
250 function printSelectAndPager($pager_html) {
253 <table class="stdFont" width="100%" border="0" cellspacing="1" cellpadding="0">
254 <tr>
255 <td>
256 <a href="javascript:CheckAll(document.messages_process_form);"><? echo translate('Select All'); ?></a>&nbsp;|&nbsp;
257 <a href="javascript:CheckNone(document.messages_process_form);"><? echo translate('Clear All'); ?></a>
258 </td>
259 <td>
260 <div align="right">
262 // Draw the paging links if more than 1 page
263 echo $pager_html . "\n";
265 </div>
266 </td>
267 </tr>
268 </table>
273 * Print 'No message was selected' warning and 'Back to messages' link
274 * @param none
276 function printNoMesgWarning() {
277 global $link;
279 <table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
280 <tr><td class="tableBorder">
281 <table width="100%" border="0" cellspacing="1" cellpadding="0">
282 <tr class="cellColor"><td>
283 <center><? echo translate('No message was selected'); ?><br>
284 <? $link->doLink('javascript: history.back();','&#8249;&#8249; ' . translate('BackMessageIndex'), '', '',
285 translate('BackMessageIndex')); ?></center>
286 </td></tr>
287 </table>
288 </td></tr>
289 </table>
294 * Print table of messages that were processed without success
295 * for the current user.
296 * @param string $action 'Release', 'Delete', ...
297 * @param string $content_type 'B', 'S', ...
298 * @param mixed $res array of message data
300 function showFailedMessagesTable($action, $content_type, $res) {
301 global $link;
304 <table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
305 <tr>
306 <!-- Print table title -->
307 <td class="tableBorder">
308 <table width="100%" border="0" cellspacing="1" cellpadding="0">
309 <tr>
310 <td colspan="5" class="tableTitle">
311 <? if ( $action == translate('Release') || $action == translate('Release/Request release') )
312 echo translate('A problem occured when trying to release the following messages');
313 elseif ( $action == translate('Delete') || $action == translate('Delete All') )
314 echo translate('A problem occured when trying to delete the following messages');
316 </td>
317 <td class="tableTitle">
318 <div align="right">
319 <? $link->doLink('javascript: help(\'msg_index\');', '?', '', 'color: #FFFFFF;', translate('Help') ) ?>
320 </div>
321 </td>
322 </tr>
323 </table>
325 <!-- Print table headers -->
326 <table width="100%" border="0" cellspacing="1" cellpadding="0">
327 <tr class="rowHeaders">
328 <td width="20%"><? echo translate('From'); ?></td>
329 <td width="30%"><? echo translate('Subject'); ?></td>
330 <td width="10%"><? echo translate('Date'); ?></td>
331 <? if ( 'S' == $content_type ) { ?>
332 <td width="10%"><? echo translate('Score'); ?></td>
333 <? } ?>
334 <td width="30%"><? echo translate('Status'); ?></td>
335 </tr>
337 <!-- Print table rows -->
339 for ($i = 0; is_array($res) && $i < count($res); $i++) {
340 $rs = $res[$i];
341 $subject = $rs['subject'] ? $rs['subject'] : '(none)';
342 $class = 'cellColor' . ($i%2);
343 echo "<tr class=\"$class\" align=\"center\">"
344 . ' <td>' . $rs['from_addr'] . '</td>'
345 . ' <td>' . $subject . '</td>'
346 . ' <td>' . CmnFns::formatDateTime($rs['time_num']) . '</td>';
347 if ( 'S' == $content_type )
348 echo ' <td>' . $rs['spam_level'] . '</td>';
349 echo ' <td>' . $rs['status'] . '</td>';
350 echo "</tr>\n";
351 } ?>
352 </table>
353 </td>
354 </tr>
355 </table>