cleanup
[bMailZu.git] / messagesAdmin.php
blobf616de153bd97f76e93bf856a8e4a84eec0d10af
1 <?php
2 /**
3 * This file is the messages index in quarantine for logged in users.
4 * It provides a listing of all messages corresponding to:
5 * - attachment ('B')
6 * - spam ('S')
7 * @author Samuel Tran
8 * @author Brian Wong
9 * @author Jeremy Fowler <jfowler06@users.sourceforge.net>
10 * @version 04-03-07
11 * @package MailZu
13 * Copyright (C) 2005 - 2007 MailZu
14 * License: GPL, see LICENSE
16 /**
17 * Include Template class
19 include_once('lib/Template.class.php');
20 /**
21 * Include common output functions
23 include_once('templates/common.template.php');
24 /**
25 * Include quarantine-specific output functions
27 include_once('templates/quarantine.template.php');
29 if (!Auth::is_logged_in()) {
30 Auth::print_login_msg(); // Check if user is logged in
33 // grab the display size limit set in config.php
34 $sizeLimit = isset ( $conf['app']['displaySizeLimit'] ) && is_numeric( $conf['app']['displaySizeLimit'] ) ?
35 $conf['app']['displaySizeLimit'] : 50;
36 // Get current page number
37 $requestedPage = CmnFns::getGlobalVar('page', GET);
39 $_SESSION['sessionNav'] = "Site Quarantine";
41 $db = new DBEngine();
43 $t = new Template(translate('Site Quarantine'));
45 $t->printHTMLHeader();
46 $t->printWelcome();
47 $t->startMain();
49 // Break table into 2 columns, put quick links on left side and all other tables on the right
50 startQuickLinksCol();
51 showQuickLinks(); // Print out My Quick Links
52 startDataDisplayCol();
54 if (! Auth::isMailAdmin()) {
55 CmnFns::do_error_box(translate('Access Denied'));
57 } else {
58 // Draw search engine
59 printSearchEngine($content_type, $_SERVER['PHP_SELF'], 1);
60 echo '<br>';
62 if ( CmnFns::getGlobalVar('search_action', GET) == translate('Clear search results') ) {
63 CmnFns::redirect_js($_SERVER['PHP_SELF'] . '?searchOnly=' . $conf['app']['searchOnly']);
66 $search_array1 = $db->convertSearch2SQL( 'msgs.from_addr', CmnFns::getGlobalVar('f_criterion', GET), CmnFns::getGlobalVar('f_string', GET) );
67 $search_array2 = $db->convertSearch2SQL( 'msgs.subject', CmnFns::getGlobalVar('s_criterion', GET), CmnFns::getGlobalVar('s_string', GET) );
68 $search_array3 = $db->convertSearch2SQL( 'recip.email', CmnFns::getGlobalVar('t_criterion', GET), CmnFns::getGlobalVar('t_string', GET) );
69 $search_array4 = $db->convertSearch2SQL( 'msgs.mail_id', CmnFns::getGlobalVar('m_criterion', GET), CmnFns::getGlobalVar('m_string', GET) );
71 $search_array = array_merge( $search_array1, $search_array2, $search_array3, $search_array4 );
73 $order = array('msgs.time_num', 'from_addr', 'msgs.subject', 'spam_level', 'recip.email', 'msgs.content', 'mail_id');
74 // Arbitrary type for Admin
75 $content_type = (CmnFns::get_ctype() ? CmnFns::get_ctype() : 'A');
77 //echo "Before query: " . date("l dS of F Y h:i:s A") . "<br><br>";
79 if ( CmnFns::getGlobalVar('searchOnly', GET) != 1 ) {
80 // Print a loading message until database returns...
81 printMessage(translate('Retrieving Messages...'));
83 $messages = $db->get_user_messages($content_type, $_SESSION['sessionMail'], CmnFns::get_value_order($order), CmnFns::get_vert_order(), $search_array, 1, 0, $requestedPage);
86 // Compute maximum number of pages
87 $maxPage = (ceil($db->numRows/$sizeLimit)-1);
89 // If $requestedPage > $maxPage, then redirect to $maxPage instead of $requestedPage
90 if ( $requestedPage > $maxPage ) {
91 $query_string = CmnFns::array_to_query_string( $_GET, array( 'page' ) );
92 $query_string = str_replace ( '&amp;', '&', $query_string );
93 CmnFns::redirect_js($_SERVER['PHP_SELF'].'?'.$query_string.'&page='.$maxPage);
96 if ( CmnFns::getGlobalVar('searchOnly', GET) != 1 ) {
97 showMessagesTable($content_type, $messages, $requestedPage, CmnFns::get_value_order($order), CmnFns::get_vert_order(), $db->numRows );
99 // Hide the message after the table loads.
100 hideMessage(translate('Retrieving Messages...'));
105 endDataDisplayCol();
106 $t->endMain();
107 $t->printHTMLFooter();