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>
12 * Copyright (C) 2005 - 2007 MailZu
13 * License: GPL, see LICENSE
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
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) {
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;
40 $mouseover_text = translate('Sort by descending order');
43 $mouseover_text = translate('Sort by ascending order');
46 // If there are messages in quarantine, draw tables
48 // $res is only a subset of the message quarantine
49 // Its number of rows is $sizeLimit
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);
69 <table width
="100%" border
="0" cellspacing
="0" cellpadding
="1" align
="center">
71 <td
class="tableBorder">
73 <!-- Draw
'Showing messages ...' table
-->
74 <table width
="100%" border
="0" cellspacing
="1" cellpadding
="0">
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 )); ?
>
81 <td
class="tableTitle">
83 <?
$link->doLink('javascript: help(\'msg_index\');', '?', '', 'color: #FFFFFF;',
84 translate('Help') . ' - ' . translate('My Quarantine')) ?
>
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%"> </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 . '&
;order
=recip
.email
&
;vert
=' . $new_vert, translate('To
'), '', '', $mouseover_text) ?>
103 <td width="15%" <? echo "from_addr"==$order?' class="reservedCell"':''; ?>>
104 <? $link->doLink($_SERVER['PHP_SELF
'] . '?
' . CmnFns::querystring_exclude_vars( array('order
','vert
'))
105 . '&
;order
=from_addr
&
;vert
=' . $new_vert, translate('From
'), '', '', $mouseover_text) ?>
107 <td width="40%" <? echo "msgs.subject"==$order?' class="reservedCell"':''; ?>>
108 <? $link->doLink($_SERVER['PHP_SELF
'] . '?
' . CmnFns::querystring_exclude_vars( array('order
','vert
'))
109 . '&
;order
=msgs
.subject
&
;vert
=' . $new_vert, translate('Subject
'), '', '', $mouseover_text) ?>
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 . '&
;order
=msgs
.time_num
&
;vert
=' . $new_vert, translate('Date
'), '', '', $mouseover_text) ?>
115 <td width="7%" <? echo "spam_level"==$order?' class="reservedCell"':''; ?>>
116 <? $link->doLink($_SERVER['PHP_SELF
'] . '?
' . CmnFns::querystring_exclude_vars( array('order
','vert
'))
117 . '&
;order
=spam_level
&
;vert
=' . $new_vert, translate('Score
'), '', '', $mouseover_text) ?>
119 <td width="10%" <? echo "msgs.content"==$order?' class="reservedCell"':''; ?>>
120 <? $link->doLink($_SERVER['PHP_SELF
'] . '?
' . CmnFns::querystring_exclude_vars( array('order
','vert
'))
121 . '&
;order
=msgs
.content
&
;vert
=' . $new_vert, translate('Content Type
'), '', '', $mouseover_text) ?>
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 . '&
;order
=mail_id
&
;vert
=' . $new_vert, translate('Mail ID
'), '', '', $mouseover_text) ?>
132 <? // For each line in table, print message fields
133 for ($i = $start_entry; $i < $end_entry; $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
>';
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 "&recip_email=" . urlencode($rs['email
']) .
157 "&$query_string", $subject, '', '',
158 translate('View this message
'), ($rs['rs
']=='v
' || $rs['rs
']=='p
' ? false : true))
159 : "<b>$subject</b>") .
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
']) {
167 $type = translate('Spam
');
170 $type = translate('Banned
');
173 $type = translate('Virus
');
176 $type = translate('Bad Header
');
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
>';
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
'])) );
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
>';
212 * Print Search Engine
213 * $param $content_type
215 function printSearchEngine($content_type, $submit_page, $full_search = false) {
218 <table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
220 <td class="tableBorder">
221 <table width="100%" border="0" cellspacing="1" cellpadding="0">
223 <td class="tableTitle">
224 <a href="javascript: void(0);" onclick="showHideSearch('search
');">› <?=translate('Search
')?></a>
226 <td class="tableTitle">
228 <? $link->doLink('javascript
: help(\'search\'
);', '?
', '', 'color
: #FFFFFF;', translate('Help') . ' - ' . translate('My Re
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>
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">
256 <a href="javascript:CheckAll(document.messages_process_form);"><? echo translate('Select All
'); ?></a> |
257 <a href="javascript:CheckNone(document.messages_process_form);"><? echo translate('Clear All
'); ?></a>
262 // Draw the paging links if more than 1 page
263 echo $pager_html . "\n";
273 * Print 'No message was selected
' warning and 'Back to messages
' link
276 function printNoMesgWarning() {
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();','‹‹ ' . translate('BackMessageIndex'), '', '',
285 translate('BackMessageIndex')); ?
></center
>
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) {
304 <table width
="100%" border
="0" cellspacing
="0" cellpadding
="1" align
="center">
306 <!-- Print table title
-->
307 <td
class="tableBorder">
308 <table width
="100%" border
="0" cellspacing
="1" cellpadding
="0">
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');
317 <td
class="tableTitle">
319 <?
$link->doLink('javascript: help(\'msg_index\');', '?', '', 'color: #FFFFFF;', translate('Help') ) ?
>
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
>
334 <td width
="30%"><?
echo translate('Status'); ?
></td
>
337 <!-- Print table rows
-->
339 for ($i = 0; is_array($res) && $i < count($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>';