X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmailbox_display.php;h=c10f13e358f34b9c5814cfc129dbb709fa758e7e;hb=c435f076fe6b5b58e09ae19a8e216f37b069d802;hp=4231897a0bfb2a2d7aeeedac91b5a45fd6d112d7;hpb=49c1780697e72cbe0de9524d3533f53115962fbb;p=squirrelmail.git diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 4231897a..1f062aa9 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -3,673 +3,1500 @@ /** * mailbox_display.php * - * Copyright (c) 1999-2002 The SquirrelMail Project Team + * Copyright (c) 1999-2004 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * This contains functions that display mailbox information, such as the * table row that has sender, date, subject, etc... * - * $Id$ + * @version $Id$ + * @package squirrelmail */ -require_once('../functions/strings.php'); +/** The standard includes.. */ +require_once(SM_PATH . 'functions/strings.php'); +require_once(SM_PATH . 'functions/html.php'); +require_once(SM_PATH . 'class/html.class.php'); +require_once(SM_PATH . 'functions/imap_mailbox.php'); +require_once(SM_PATH . 'functions/imap_messages.php'); +require_once(SM_PATH . 'functions/imap_asearch.php'); +require_once(SM_PATH . 'functions/mime.php'); +require_once(SM_PATH . 'functions/forms.php'); -define('PG_SEL_MAX', 10); /* Default value for page_selector_max. */ +/** + * default value for page_selector_max + */ +define('PG_SEL_MAX', 10); + +/** + * The number of pages to cache msg headers + */ +define('SQM_MAX_PAGES_IN_CACHE',5); + +/** + * Sort constants used for sorting of messages + */ +define('SQSORT_NONE',0); +define('SQSORT_DATE_ASC',1); +define('SQSORT_DATE_DEC',2); +define('SQSORT_FROM_ASC',3); +define('SQSORT_FROM_DEC',4); +define('SQSORT_SUBJ_ASC',5); +define('SQSORT_SUBJ_DEC',6); +define('SQSORT_SIZE_ASC',7); +define('SQSORT_SIZE_DEC',8); +define('SQSORT_TO_ASC',9); +define('SQSORT_TO_DEC',10); +define('SQSORT_CC_ASC',11); +define('SQSORT_CC_DEC',12); +define('SQSORT_INT_DATE_ASC',13); +define('SQSORT_INT_DATE_DEC',14); + +define('SQSORT_THREAD',32); + + +define('MBX_PREF_SORT',0); +define('MBX_PREF_LIMIT',1); +define('MBX_PREF_AUTO_EXPUNGE',2); +define('MBX_PREF_INTERNALDATE',3); +define('SQM_MAX_MBX_IN_CACHE',3); +// define('MBX_PREF_FUTURE',unique integer key); -function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $start_msg, $where, $what) { +/** + * @param mixed $start UNDOCUMENTED + */ +function elapsed($start) { + + $end = microtime(); + list($start2, $start1) = explode(" ", $start); + list($end2, $end1) = explode(" ", $end); + $diff1 = $end1 - $start1; + $diff2 = $end2 - $start2; + if( $diff2 < 0 ){ + $diff1 -= 1; + $diff2 += 1.0; + } + return $diff2 + $diff1; +} + +/** + * Displays message header row in messages list + * + * @param array $aMsg contains all message related parameters + * @return void + */ + +function printMessageInfo($aMsg) { + // FIX ME, remove these globals as well by adding an array as argument for the user settings + // specificly meant for header display global $checkall, - $color, $msgs, $msort, - $sent_folder, $draft_folder, - $default_use_priority, - $message_highlight_list, - $index_order, - $pos; /* Search postion (if any) */ + $color, + $default_use_priority, + $message_highlight_list, + $index_order, + $truncate_sender, /* number of characters for From/To field (<= 0 for unchanged) */ + $email_address, + $show_recipient_instead, /* show recipient name instead of default identity */ + $use_icons, /* indicates to use icons or text markers */ + $icon_theme; /* icons theming */ $color_string = $color[4]; + + // initialisation: + $mailbox = $aMsg['MAILBOX']; + $msg = $aMsg['HEADER']; + $t = $aMsg['INDX']; + $start_msg = $aMsg['PAGEOFFSET']; + $last = $aMsg['LAST']; + if (isset($aMsg['SEARCH']) && count($aMsg['SEARCH']) >1 ) { + $where = $aMsg['SEARCH'][0]; + $what = $aMsg['SEARCH'][1]; + } else { + $where = false; + $what = false; + } + $iIndent = $aMsg['INDENT']; + + $sSubject = (isset($msg['SUBJECT']) && $msg['SUBJECT'] != '') ? $msg['SUBJECT'] : _("(no subject)"); + $sFrom = (isset($msg['FROM'])) ? $msg['FROM'] : _("Unknown sender"); + $sTo = (isset($msg['TO'])) ? $msg['TO'] : _("Unknown recipient"); + $sCc = (isset($msg['CC'])) ? $msg['CC'] : ''; + $aFlags = (isset($msg['FLAGS'])) ? $msg['FLAGS'] : array(); + $iPrio = (isset($msg['PRIORITY'])) ? $msg['PRIORITY'] : 3; + $iSize = (isset($msg['SIZE'])) ? $msg['SIZE'] : 0; + + // These don't appear to be used... are they safe to remove + $sType0 = (isset($msg['TYPE0'])) ? $msg['TYPE0'] : 'text'; + $sType1 = (isset($msg['TYPE1'])) ? $msg['TYPE1'] : 'plain'; + if (isset($msg['INTERNALDATE'])) { + $sDate = getDateString(getTimeStamp(explode(' ',$msg['INTERNALDATE']))); + } else { + $sDate = (isset($msg['DATE'])) ? getDateString(getTimeStamp(explode(' ',$msg['DATE']))) : ''; + } + $iId = (isset($msg['UID'])) ? $msg['UID'] : false; + + if (!$iId) { + return; + } + if ($GLOBALS['alt_index_colors']) { - if (!isset($GLOBALS['row_count'])) { - $GLOBALS['row_count'] = 0; - } - $GLOBALS['row_count']++; - if ($GLOBALS['row_count'] % 2) { + if (!($t % 2)) { if (!isset($color[12])) { $color[12] = '#EAEAEA'; } $color_string = $color[12]; } } - $msg = $msgs[$key]; - /** - * This is done in case you're looking into Sent folders, - * because you can have multi receiver. - */ - $sendersName = split(',', $msg['FROM']); - $senderName = ''; - for ($index = 0 ; $index < count($sendersName) ; $index++) { - if ($senderName != '') { - $senderName .= ', '; + $urlMailbox = urlencode($mailbox); + + // FIXME, foldertype should be set in right_main.php + // in other words, handle as sent is obsoleted from now. + // We replace that by providing an array to aMailbox with the to shown headers + // that way we are free to show the user different layouts for different folders + $bSentFolder = handleAsSent($mailbox); + if ((!$bSentFolder) && ($show_recipient_instead)) { + // If the From address is the same as $email_address, then handle as Sent + $from_array = parseAddress($sFrom, 1); + if (!isset($email_address)) { + global $data_dir, $username; + $email_address = getPref($data_dir, $username, 'email_address'); } - $senderName .= sqimap_find_displayable_name($sendersName[$index]); + $bHandleAsSent = ((isset($from_array[0][0])) && ($from_array[0][0] == $email_address)); + } else { + $bHandleAsSent = $bSentFolder; } - - if( $mailbox == 'None' ) { - // $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); - $boxes = sqimap_mailbox_list($imapConnection); - // sqimap_logout($imapConnection); - $mailbox = $boxes[0]['unformatted']; - unset( $boxes ); + // If this is a Sent message, display To address instead of From + if ($bHandleAsSent) { + $sFrom = $sTo; } - $urlMailbox = urlencode($mailbox); - $subject = processSubject($msg['SUBJECT']); - echo "
+ |
+
" .
- "
|