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 (!($t % 2)) {
if (!isset($color[12])) {
$color[12] = '#EAEAEA';
}
$color_string = $color[12];
}
}
$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');
}
$bHandleAsSent = ((isset($from_array[0][0])) && ($from_array[0][0] == $email_address));
} else {
$bHandleAsSent = $bSentFolder;
}
// If this is a Sent message, display To address instead of From
if ($bHandleAsSent) {
$sFrom = $sTo;
}
// Passing 1 below results in only 1 address being parsed, thus defeating the following code
$sFrom = parseAddress($sFrom/*,1*/);
/*
* This is done in case you're looking into Sent folders,
* because you can have multiple receivers.
*/
$senderNames = $sFrom;
$senderName = '';
$senderAddress = '';
if (sizeof($senderNames)){
foreach ($senderNames as $senderNames_part) {
if ($senderName != '') {
$senderName .= ', ';
$senderAddress .= ', ';
}
$sender_address_part = htmlspecialchars($senderNames_part[0]);
$sender_name_part = str_replace(' ',' ', decodeHeader($senderNames_part[1]));
if ($sender_name_part) {
$senderName .= $sender_name_part;
$senderAddress .= $sender_name_part . ' <' . $sender_address_part . '>';
} else {
$senderName .= $sender_address_part;
$senderAddress .= $sender_address_part;
}
}
}
// If Sent, prefix with To: but only if not Sent folder
if ($bHandleAsSent ^ $bSentFolder) {
$senderName = _("To") . ': ' . $senderName;
$senderAddress = _("To") . ': ' . $senderAddress;
}
// this is a column property which can apply to multiple columns. Do not use vars for one column
// only. instead we should use something like this:
// 1ed column $aMailbox['columns']['SUBJECT'] value: aray with properties ...
// 2ed column $aMailbox['columns']['FROM'] value: aray with properties ...
// NB in case of the sentfolder this could be the TO field
// properties array example:
// 'truncate' => length (0 is no truncate)
// 'prefix => if (x in b then do that )
if ($truncate_sender > 0) {
$senderName = truncateWithEntities($senderName, $truncate_sender);
}
$flag = $flag_end = $fontstr = $fontstr_end = $italic = $italic_end = '';
$bold = '';
$bold_end = '';
foreach ($aFlags as $sFlag => $value) {
switch ($sFlag) {
case '\\flagged':
if ($value) {
$flag = "";
$flag_end = '';
}
break;
case '\\seen':
if ($value) {
$bold = '';
$bold_end = '';
}
break;
case '\\deleted':
if ($value) {
$fontstr = "";
$fontstr_end = '';
}
break;
}
}
if ($bHandleAsSent) {
$italic = '';
$italic_end = '';
}
if ($where && $what) {
$searchstr = '&where='.$where.'&what='.$what;
} else {
$searchstr = '';
}
/*
* Message highlight code
*/
$matches = array('TO' => 'sTo', 'CC' => 'sCc', 'FROM' => 'sFrom', 'SUBJECT' => 'sSubject');
if (is_array($message_highlight_list) && count($message_highlight_list)) {
$sTo = parseAddress($sTo);
$sCc = parseAddress($sCc);
foreach ($message_highlight_list as $message_highlight_list_part) {
if (trim($message_highlight_list_part['value']) != '') {
$high_val = strtolower($message_highlight_list_part['value']);
$match_type = strtoupper($message_highlight_list_part['match_type']);
if($match_type == 'TO_CC') {
$match = array('TO', 'CC');
} else {
$match = array($match_type);
}
foreach($match as $match_type) {
switch($match_type) {
case('TO'):
case('CC'):
case('FROM'):
foreach ($$matches[$match_type] as $address) {
$address[0] = decodeHeader($address[0], true, false);
$address[1] = decodeHeader($address[1], true, false);
if (strstr('^^' . strtolower($address[0]), $high_val) ||
strstr('^^' . strtolower($address[1]), $high_val)) {
$hlt_color = $message_highlight_list_part['color'];
break 4;
}
}
break;
default:
$headertest = strtolower(decodeHeader($$matches[$match_type], true, false));
if (strstr('^^' . $headertest, $high_val)) {
$hlt_color = $message_highlight_list_part['color'];
break 3;
}
break;
}
}
}
}
} /* end Message highlight code */
if (!isset($hlt_color)) {
$hlt_color = $color_string;
}
$col = 0;
$sSubject = str_replace(' ', ' ', decodeHeader($sSubject));
$subject = processSubject($sSubject, $iIndent);
$row_extra = 'valign="top"';
// this stuff does the auto row highlighting on mouseover
//
if ($javascript_on && $fancy_index_highlite) {
$mouseoverColor = $color[5];
// set this to an empty string to turn off extra
// highlighting of checked rows
//
//$clickedColor = '';
if (!empty($color[16]))
$clickedColor = $color[16];
else
$clickedColor = $color[2];
$row_extra .= ' onmouseover="setPointer(this, ' . $t . ', \'over\', \'' . $hlt_color . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');" onmouseout="setPointer(this, ' . $t . ', \'out\', \'' . $hlt_color . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');" onmousedown="setPointer(this, ' . $t . ', \'click\', \'' . $hlt_color . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');"';
}
if ($javascript_on && $fancy_index_highlite)
echo "";
echo html_tag( 'tr', '', '', '', $row_extra) . "\n";
// this does the auto-checking of the checkbox no matter
// where on the row you click
//
$javascript_auto_click = '';
$checkbox_javascript = '';
if ($javascript_on && $fancy_index_highlite) {
$javascript_auto_click = ' onMouseDown="row_click(\'msg[' . $t . ']\')"';
$checkbox_javascript = ' onClick="this.checked = !this.checked;"';
}
if (sizeof($index_order)) {
// figure out which columns should serve as labels for checkbox:
// we try to grab the two columns before and after the checkbox,
// except the subject column, since it is the link that opens
// the message view
//
// if $javascript_on is set, then the highlighting code takes
// care of this; just skip it
//
$show_label_columns = array();
if (!($javascript_on && $fancy_index_highlite)) {
$get_next_two = 0;
$last_order_part = 0;
$last_last_order_part = 0;
foreach ($index_order as $index_order_part) {
if ($index_order_part == 1) {
$get_next_two = 1;
if ($last_last_order_part != 4)
$show_label_columns[] = $last_last_order_part;
if ($last_order_part != 4)
$show_label_columns[] = $last_order_part;
} else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != 4) {
$show_label_columns[] = $index_order_part;
$get_next_two++;
}
$last_last_order_part = $last_order_part;
$last_order_part = $index_order_part;
}
}
// build the actual columns for display
//
foreach ($index_order as $index_order_part) {
if (in_array($index_order_part, $show_label_columns)) {
$label_start = '';
} else {
$label_start = '';
$label_end = '';
}
switch ($index_order_part) {
case 1: /* checkbox */
echo html_tag( 'td',
addCheckBox("msg[$t]", $checkall, $iId, $checkbox_javascript),
'center',
$hlt_color, $javascript_auto_click);
break;
case 2: /* from */
if ($senderAddress != $senderName) {
$senderAddress = strtr($senderAddress, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
$title = ' title="' . str_replace(array('"', '<', '>'), array("''", '<', '>'), $senderAddress) . '"';
} else {
$title = '';
}
echo html_tag( 'td',
$label_start . $italic . $bold . $flag . $fontstr . $senderName .
$fontstr_end . $flag_end . $bold_end . $italic_end . $label_end,
'left',
$hlt_color, $title . $javascript_auto_click);
break;
case 3: /* date */
if ($sDate == '') {
$sDate = _("Unknown date");
}
echo html_tag( 'td',
$label_start . $bold . $flag . $fontstr . $sDate .
$fontstr_end . $flag_end . $bold_end . $label_end,
'center',
$hlt_color,
'style="white-space: nowrap;"' . $javascript_auto_click );
break;
case 4: /* subject */
$td_str = $bold;
if ($iIndent) {
$td_str .= str_repeat(" ",$iIndent);
}
$td_str .= ''), array("''", '<', '>'), $title);
$td_str .= " title=\"$title\"";
}
$td_str .= ">$flag$subject$flag_end$bold_end";
echo html_tag( 'td', $td_str, 'left', $hlt_color, $javascript_auto_click );
break;
case 5: /* flags */
// icon message markers
//
if ($use_icons && $icon_theme != 'none') {
$td_str = "";
if (isset($aFlags['\\flagged']) && $aFlags['\\flagged'] == true) {
$td_str .= ' ';
}
if ($default_use_priority) {
if ( ($iPrio == 1) || ($iPrio == 2) ) {
$td_str .= '
';
}
else if ($iPrio == 5) {
$td_str .= '
';
}
else {
$td_str .= '
';
}
}
if ($sType1 == 'mixed') {
$td_str .= '
';
} else {
$td_str .= '
';
}
$msg_icon = '';
if (!isset($aFlags['\\seen']) || ($aFlags['\\seen']) == false) {
$msg_alt = '(' . _("New") . ')';
$msg_title = '(' . _("New") . ')';
$msg_icon .= SM_PATH . 'images/themes/' . $icon_theme . '/msg_new';
} else {
$msg_alt = '(' . _("Read") . ')';
$msg_title = '(' . _("Read") . ')';
$msg_icon .= SM_PATH . 'images/themes/' . $icon_theme . '/msg_read';
}
if (isset($aFlags['\\deleted']) && ($aFlags['\\deleted']) == true) {
$msg_icon .= '_deleted';
}
if (isset($aFlags['\\answered']) && ($aFlags['\\answered']) == true) {
$msg_alt = '(' . _("Answered") . ')';
$msg_title = '(' . _("Answered") . ')';
$msg_icon .= '_reply';
}
$td_str .= '
';
$td_str .= '';
echo html_tag( 'td',
$label_start . $td_str . $label_end,
'right',
$hlt_color,
'style="white-space: nowrap;"' . $javascript_auto_click );
}
// plain text message markers
//
else {
$stuff = false;
$td_str = "";
if (isset($aFlags['\\answered']) && $aFlags['\\answered'] == true) {
$td_str .= _("A");
$stuff = true;
}
if ($sType1 == 'mixed') {
$td_str .= '+';
$stuff = true;
}
if ($default_use_priority) {
if ( ($iPrio == 1) || ($iPrio == 2) ) {
$td_str .= "!";
$stuff = true;
}
if ($iPrio == 5) {
$td_str .= "?";
$stuff = true;
}
}
if (isset($aFlags['\\deleted']) && $aFlags['\\deleted'] == true) {
$td_str .= "D";
$stuff = true;
}
if (!$stuff) {
$td_str .= ' ';
}
$td_str .= '';
echo html_tag( 'td',
$label_start . $td_str . $label_end,
'center',
$hlt_color,
'style="white-space: nowrap;"' . $javascript_auto_click );
}
break;
case 6: /* size */
echo html_tag( 'td',
$label_start . $bold . $fontstr . show_readable_size($iSize) .
$fontstr_end . $bold_end . $label_end,
'right',
$hlt_color, $javascript_auto_click );
break;
}
++$col;
}
}
/* html for separationlines between rows */
if ($last) {
echo ''."\n";
} else {
echo '' . "\n" . '
|