<?
if(VALID_DOCUMENT != 1) die('what?');
$mailbox = get_var('mailbox');
$query = get_var('query');
$label = get_var('label');
$view = 'list';
$headers = false;
// hack for 20 emails per page only!
$_SESSION['preferences']->prefs['mails-per-page'] = 20;
if($_SESSION['last_headers'] && $_SESSION['last_headers']->name == $mailbox && get_var('return')){
$headers = $_SESSION['last_headers'];
}
else if($mailbox != '' || $query != '' || $label != ''){
$sort_order = get_var('sort_order');
if($sort_order == '')
$sort_order = SORT_BY_DATE;
$start_page = get_var('start_page');
if($start_page == '')
$start_page = 1;
if($mailbox != ''){
$headers = $_SESSION['mboxes']->createMailHeaders($mailbox,$sort_order,$start_page);
if($headers){
$headers->view = $view;
$_SESSION['last_headers'] = $headers;
$_SESSION['last_mailbox'] = $mailbox;
}
}
else if($query != ''){
$type = get_var('type');
if($type === null) $type = 'or';
$subject = get_var('subject');
if($subject === null) $subject = true;
$email = get_var('email');
if($email === null) $email = true;
$body = get_var('body');
if($body === null) $body = true;
$mbox = get_var('mbox');
if($mbox === null) $mbox = get_mailboxes_names();
$headers = $_SESSION['mboxes']->query($query,
$type,
$subject,
$email,
$body,
$mbox);
}
else if($label != ''){
$headers = $_SESSION['mboxes']->getLabeled($label,get_mailboxes_names());
}
}
if($headers){
$headers->print_presentation();
}
else{
?>
<div style="<?=WARNING_STYLE.BIG_STYLE.BOLD_STYLE?>">No Such Mailbox : "<?=$mailbox?>"</div>
<?}?>