home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 April
/
CMCD0404.ISO
/
Software
/
Freeware
/
Programare
/
groupoffice-com-2.01
/
modules
/
email
/
navigation.inc
< prev
next >
Wrap
Text File
|
2004-03-08
|
18KB
|
618 lines
<?php
/*
Copyright Intermesh 2003
Author: Merijn Schering <mschering@intermesh.nl>
Version: 1.0 Release date: 08 July 2003
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
*/
if (isset($_REQUEST['unseen_state_changed']))
{
$unseen_state_changed=true;
}
if (isset($_REQUEST['empty_mailbox']) && $_REQUEST['empty_mailbox']=='true')
{
$mail->sort();
if ($mailbox == $account['trash'] || $account['type'] == 'pop3')
{
$mail->delete($mail->messages);
//set this var so we can check if unseen messages were deleted
//if so, the auto mail checker must now too.
$unseen_state_changed = true;
}else
{
$mail->move($account['trash'], $mail->messages);
}
}
if (isset($_REQUEST['delete_message_uid']) && $_REQUEST['delete_message_uid'] > 0)
{
$messages[] = $_REQUEST['delete_message_uid'];
if ($mailbox == $account['trash'] || $account['type'] == 'pop3')
{
$mail->delete($messages);
//set this var so we can check if unseen messages were deleted
//if so, the auto mail checker must now too.
$unseen_state_changed = true;
}else
{
$mail->move($account['trash'], $messages);
}
$task = '';
}
$messages_display = '';
//when this is post request delete selected messages
if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['messages']))
{
switch ($_POST['form_action'])
{
case 'delete':
if ($mailbox == $account['trash'] || $account['type'] == 'pop3' || $account['trash'] == '')
{
$mail->delete($_POST['messages']);
//set this var so we can check if unseen messages were deleted
//if so, the auto mail checker must now too.
$unseen_state_changed = true;
}else
{
$mail->move($account['trash'], $_POST['messages']);
}
break;
case 'move':
$mail->move($_POST['folder'], $_POST['messages']);
break;
case 'markread':
//set this var so we can check if unseen messages were deleted
//if so, the auto mail checker must now too.
$unseen_state_changed = true;
$mail->set_message_flag($mailbox, $_POST['messages'], "\\Seen");
break;
case 'markunread':
//set this var so we can check if unseen messages were deleted
//if so, the auto mail checker must now too.
$unseen_state_changed = true;
$mail->set_message_flag($mailbox, $_POST['messages'], "\\Seen", "reset");
break;
}
}
//determine how to sort messages and sort them
$mail_reverse = isset($_COOKIE['mail_reverse']) ? $_COOKIE['mail_reverse'] : '1';
$mail_sort = isset($_COOKIE['mail_sort']) ? $_COOKIE['mail_sort'] : SORTDATE;
$mail->sort($mail_sort, $mail_reverse);
if ($mail_reverse == 1)
{
$image_string = '<img src="'.$GO_THEME->images['arrow_down'].'" border="0" />';
$mail_reverse=0;
}else
{
$image_string = '<img src="'.$GO_THEME->images['arrow_up'].'" border="0" />';
$mail_reverse=1;
}
//count total and new messages
$mail->count();
$msg_count = $mail->count;
$show = "from";
if ($mail->is_imap() && $account['sent'] != '')
{
if (strpos($mailbox, $account['sent']) === 0)
{
$show = "to";
}
}
$mail->mailbox_info();
$total_size = $mail->mailbox_info["size"];
$unseen = $mail->unseen;
$_SESSION['unseen_in_mailbox'] = isset($_SESSION['unseen_in_mailbox']) ? $_SESSION['unseen_in_mailbox'] : $unseen;
if (isset($unseen_state_changed) && $account['auto_check'] == '1')
{
if ($unseen != $_SESSION['unseen_in_mailbox'])
{
$diff = $_SESSION['unseen_in_mailbox'] - $unseen;
$_SESSION['notified_new_mail'] -= $diff;
}
}
$_SESSION['unseen_in_mailbox'] = $unseen;
//loop through messages and display them
if ($msg_count > 0)
{
$email_filter = array();
$subject_filter = array();
$filters = array();
//if there are new messages get the filters
if ($mail->unseen > 0)
{
$email->get_filters($account['id']);
while ($email->next_record())
{
$filter["field"] = $email->f("field");
$filter["folder"] = $email->f("folder");
$filter["keyword"] = $email->f("keyword");
$filters[] = $filter;
}
}
$mail->next_message_id = $first_row;
$row_count = 0;
while($mail->next_message() && ($row_count < $max_rows || $max_rows == 0))
{
$row_count++;
$continue = false;
//check if message is new and apply users filters to new messages only in the inbox folder.
if ($mail->f('new') == 1)
{
if (strtolower($mailbox) == "inbox")
{
for ($i=0;$i<sizeof($filters);$i++)
{
if ($filters[$i]["folder"])
{
$field = $mail->f($filters[$i]["field"]);
if (!is_array($field))
{
if (eregi($filters[$i]["keyword"], $field))
{
$messages[] = $mail->f("uid");
if ($mail->move($filters[$i]["folder"], $messages))
{
$msg_count--;
$unseen--;
$continue = true;
break;
}
}
}else
{
for ($x=0;$x<sizeof($field);$x++)
{
if (eregi($filters[$i]["keyword"], $field[$x]))
{
$messages[] = $mail->f("uid");
if ($mail->move($filters[$i]["folder"], $messages))
{
$msg_count--;
$unseen--;
$continue = true;
break;
}
}
}
}
}
}
}
if ($continue)
{
continue;
}
$class = ' class="Table4"';
$image = '<img src="'.$GO_THEME->images['newmail'].'" border="0" width="16" height="16" />';
}else
{
if ($mail->f('answered'))
{
$image = '<img src="'.$GO_THEME->images['mail_repl'].'" border="0" width="16" height="16" />';
}else
{
$image = '<img src="'.$GO_THEME->images['mail'].'" border="0" width="16" height="16" />';
}
if($mail->f('uid')==$uid)
{
$class = ' class="Table5"';
}else
{
$class = ' class="Table1"';
}
}
//check if message has attachments
if ($mail->f("attachment"))
{
$attachment = '<img src="'.$GO_THEME->images['attach'].'" border="0" />';
}else
{
$attachment = ' ';
}
switch ($mail->f("priority"))
{
case "4":
$priority = '<img src="'.$GO_THEME->images['low_priority'].'" width="8" height="16" />';
break;
case "2":
$priority = '<img src="'.$GO_THEME->images['high_priority'].'" width="8" height="16" />';
break;
default:
$priority = '';
break;
}
//display message
$subject = $mail->f('subject') ? $mail->f('subject') : $ml_no_subject;
$short_subject = cut_string($subject, 50);
if ($show == "from")
{
$short_from = cut_string($mail->f('from'), 40);
}else
{
$to = '';
$to_array = $mail->f("to");
for ($i=0;$i<sizeof($to_array);$i++)
{
if ($i != 0)
{
$to .= ", ";
}
$to .= $to_array[$i];
}
if ($to == "")
{
$to = $ml_no_reciepent;
}
$short_to = cut_string($to, 50);
}
$messages_display .= '<tr'.$class.' id="'.$mail->f('uid').'">';
$messages_display .= '<td nowrap><input type="checkbox" name="messages[]" value="'.$mail->f('uid').'" onclick="javascript:item_click(this);" /></td>';
$messages_display .= '<td nowrap>'.$priority.' </td>';
$messages_display .= '<td nowrap>'.$attachment.' </td>';
$messages_display .= '<td nowrap width="20">'.$image.'</td>';
if ($show=="from")
{
$messages_display .= "<td nowrap><a href=\"message.php?account_id=".$account['id']."&uid=".$mail->f('uid')."&mailbox=".$mailbox."&first_row=".$first_row."&return_to=".urlencode($link_back)."\" title=\"".$mail->f('from')." <".$mail->f("sender").">\">".$short_from." </a></td>";
}else
{
$messages_display .= "<td nowrap><a href=\"message.php?account_id=".$account['id']."&uid=".$mail->f('uid')."&mailbox=".$mailbox."&first_row=".$first_row."&return_to=".urlencode($link_back)."\" title=\"".$to."\">".$short_to." </a></td>";
}
$messages_display .= "<td nowrap><a href=\"message.php?account_id=".$account['id']."&uid=".$mail->f('uid')."&mailbox=".$mailbox."&first_row=".$first_row."&return_to=".urlencode($link_back)."\" title=\"".$mail->f('subject')."\">".$short_subject." </a></td>";
$messages_display .= '<td nowrap>'.format_size($mail->f('size')).' </td>';
$messages_display .= '<td nowrap>'.date($_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'], get_time($mail->f('udate'))).'</td>';
$messages_display .= "</tr>\n";
$messages_display .= '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td>';
$messages_display .= "</tr>\n";
}
$messages_display .= '<tr><td colspan="99" class="small" height="18"> '.$msg_count.' '.$ml_messages.' ';
if ($mail->is_imap())
{
$messages_display .= '('.$unseen.' '.$ml_new.')';
}
$messages_display .= ' '.$fbFolderSize.': '.format_size($total_size).'</td></tr>';
$messages_display .= '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td>';
$messages_display .= "</tr>\n";
}
if ($msg_count == 0)
{
$email_folder = $email->get_folder($account['id'], $mailbox);
if ($email_folder['attributes']&LATT_NOSELECT)
{
$messages_display = '<tr><td colspan="99" height="18">'.$ml_no_mailbox.'</td></tr>';
}else
{
$messages_display = '<tr><td colspan="99" height="18">'.$ml_no_messages.'</td></tr>';
}
$messages_display .= '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
}
?>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td valign="top"><?php
require("treeview.inc"); ?>
</td>
<td valign="top">
<input type="hidden" name="first_row" value="<?php echo $first_row; ?>" />
<input type="hidden" name="mailbox" value="<?php echo $mailbox; ?>" />
<input type="hidden" name="form_action" value="delete" />
<table border="0" cellspacing="0" cellpadding="0" class="Table1">
<tr>
<td colspan="6" nowrap>
<?php
if ($account['type'] == "imap" && $email->get_all_folders($account['id'],true) > 0)
{
$dropbox = new dropbox();
$dropbox->add_value('', $ml_move_mail);
if (strtolower($mailbox) != 'inbox')
{
$dropbox->add_value('INBOX',$ml_inbox);
}
while ($email->next_record())
{
if (!($email->f('attributes')&LATT_NOSELECT) && $email->f('name') != $mailbox)
{
$dropbox->add_value($email->f('name'), $email->f('name'));
}
}
$dropbox->print_dropbox('folder','','onchange="javascript:move_mail()"');
}else
{
echo ' ';
}
?>
</td>
<td colspan="2" align="right" class="small" nowrap>
<?php
echo $msg_count." ".$ml_messages;
if ($mail->is_imap())
{
echo " (".$unseen." ".$ml_new.")";
}
?>
</td>
</tr>
<tr>
<td class="TableHead2" width="16"><input type="checkbox" name="dummy" value="dummy" onclick="javascript:invert_selection()" /></td>
<td class="TableHead2" width="8"> </td>
<td class="TableHead2" width="6"> </td>
<td class="TableHead2" width="16"> </td>
<?php
if ($show == "from")
{
echo '<td class="TableHead2" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?newsort='.SORTFROM.'&newreverse='.$mail_reverse.'&mailbox='.urlencode($mailbox).'">'.$ml_from;
if ($mail_sort == SORTFROM)
{
echo ' '.$image_string;
}
echo '</a></td>';
}else
{
echo '<td class="TableHead2" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?newsort='.SORTTO.'&newreverse='.$mail_reverse.'&mailbox='.urlencode($mailbox).'">'.$ml_to;
if ($mail_sort == SORTTO)
{
echo ' '.$image_string;
}
echo '</a></td>';
}
echo '<td class="TableHead2" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?newsort='.SORTSUBJECT.'&newreverse='.$mail_reverse.'&mailbox='.urlencode($mailbox).'">'.$ml_subject;
if ($mail_sort == SORTSUBJECT)
{
echo ' '.$image_string;
}
echo '</a></td>';
echo '<td class="TableHead2" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?newsort='.SORTSIZE.'&newreverse='.$mail_reverse.'&mailbox='.urlencode($mailbox).'">'.$ml_size;
if ($mail_sort == SORTSIZE)
{
echo ' '.$image_string;
}
echo '</a></td>';
echo '<td class="TableHead2" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?newsort='.SORTDATE.'&newreverse='.$mail_reverse.'&mailbox='.urlencode($mailbox).'">'.$strDate;
if ($mail_sort == SORTDATE)
{
echo ' '.$image_string;
}
echo '</a></td></tr>';
echo $messages_display;
$links = '';
$max_links=10;
if ($max_rows != 0)
{
if ($msg_count > $max_rows)
{
$links = '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>';
$next_start = $first_row+$max_rows;
$previous_start = $first_row-$max_rows;
if ($first_row != 0)
{
$links .= '<a href="'.$_SERVER['PHP_SELF'].'?mailbox='.$mailbox.'&first_row=0"><<</a> ';
$links .= '<a href="'.$_SERVER['PHP_SELF'].'?mailbox='.$mailbox.'&first_row='.$previous_start.'">'.$cmdPrevious.'</a> ';
}else
{
$links .= '<font color="#cccccc"><< '.$cmdPrevious.'</font> ';
}
$start = ($first_row-(($max_links/2)*$max_rows));
$end = ($first_row+(($max_links/2)*$max_rows));
if ($start < 0)
{
$end = $end - $start;
$start=0;
}
if ($end > $msg_count)
{
$end = $msg_count;
}
if ($start > 0)
{
$links .= '... ';
}
for ($i=$start;$i<$end;$i+=$max_rows)
{
$page = ($i/$max_rows)+1;
if ($i==$first_row)
{
$links .= '<b><i>'.$page.'</i></b> ';
}else
{
$links .= '<a href="'.$_SERVER['PHP_SELF'].'?mailbox='.$mailbox.'&first_row='.$i.'">'.$page.'</a> ';
}
}
if ($end < $msg_count)
{
$links .= '... ';
}
$last_page = floor($msg_count/$max_rows)*$max_rows;
if ($msg_count > $next_start)
{
$links .= '<a href="'.$_SERVER['PHP_SELF'].'?account_id='.$account['id'].'&mailbox='.$mailbox.'&first_row='.$next_start.'">'.$cmdNext.'</a> ';
$links .= '<a href="'.$_SERVER['PHP_SELF'].'?account_id='.$account['id'].'&mailbox='.$mailbox.'&first_row='.$last_page.'">>></a>';
}else
{
$links .= '<font color="#cccccc">'.$cmdNext.' >></font>';
}
$links .= '</td><td align="right"><a class="normal" href="'.$_SERVER['PHP_SELF'].'?account_id='.$account['id'].'&mailbox='.$mailbox.'&max_rows=0">'.$cmdShowAll.'</a></td></tr></table>';
echo '<tr><td colspan="99" height="20">'.$links.'</td></tr>';
echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
}
}
echo '</table>';
?>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
function move_mail()
{
document.forms[0].form_action.value = 'move';
document.forms[0].submit();
}
function invert_selection()
{
for (var i=0;i<document.forms[0].elements.length;i++)
{
if(document.forms[0].elements[i].type == 'checkbox' && document.forms[0].elements[i].name != 'dummy')
{
document.forms[0].elements[i].checked = !(document.forms[0].elements[i].checked);
item_click(document.forms[0].elements[i]);
}
}
}
function confirm_delete()
{
var count = 0;
for (var i=0;i<document.forms[0].elements.length;i++)
{
if(document.forms[0].elements[i].type == 'checkbox' && document.forms[0].elements[i].name != 'dummy')
{
if (document.forms[0].elements[i].checked == true)
{
count++;
}
}
}
switch (count)
{
case 0:
alert("<?php echo $fbNoSelect; ?>");
break;
<?php
$trash_folder = $account['trash'];
if ($trash_folder == '' || $trash_folder == $mailbox)
{
echo '
case 1:
if (confirm("'.$strDeletePrefix.$ml_message.$strDeleteSuffix.'"))
{
document.forms[0].submit();
}
break;
default:
if (confirm("'.$strDeletePrefix.$strThis.' "+count+" '.$ml_messages2.$strDeleteSuffix.'"))
{
document.forms[0].submit();
}
break;
';
}else
{
echo '
default:
document.forms[0].submit();
break;
';
}
?>
}
}
function confirm_empty_mailbox()
{
if (confirm("<?php echo $ml_confirm_empty_mailbox; ?>"))
{
document.forms[0].empty_mailbox.value='true';
document.forms[0].submit();
}
}
function item_click(check_box)
{
var item = get_object(check_box.value);
if (check_box.checked)
{
if (item.className == 'Table1' || item.className == 'Table5')
{
item.className = 'Table2';
}else
{
item.className = 'Table3';
}
}else
{
if (item.className == 'Table2')
{
item.className = 'Table1';
}else
{
item.className = 'Table4';
}
}
}
function mark_as_read()
{
document.forms[0].form_action.value = 'markread';
document.forms[0].submit();
}
function mark_as_unread()
{
document.forms[0].form_action.value = 'markunread';
document.forms[0].submit();
}
//-->
</script>