/* Constants:
* PG_SEL_MAX: default value for page_selector_max
- * SUBJ_TRIM_AT: the length at which we trim off subjects
*/
define('PG_SEL_MAX', 10);
-define('SUBJ_TRIM_AT', 55);
function elapsed($start)
{
$row_count,
$allow_server_sort, /* enable/disable server-side sorting */
$truncate_sender, /* number of characters for From/To field (<= 0 for unchanged) */
- $email_address;
+ $email_address,
+ $show_recipient_instead; /* show recipient name instead of default identity */
$color_string = $color[4];
$urlMailbox = urlencode($mailbox);
$bSentFolder = handleAsSent($mailbox);
- // If the From address is the same as $email_address, then handle as Sent
- $from_array = parseAddress($msg['FROM'], 1);
- if (!isset($email_address)) {
- global $datadir, $username;
- $email_address = getPref($datadir, $username, 'email_address');
+ if ((!$bSentFolder) && ($show_recipient_instead)) {
+ // If the From address is the same as $email_address, then handle as Sent
+ $from_array = parseAddress($msg['FROM'], 1);
+ if (!isset($email_address)) {
+ global $datadir, $username;
+ $email_address = getPref($datadir, $username, 'email_address');
+ }
+ $bHandleAsSent = ((isset($from_array[0][0])) && ($from_array[0][0] == $email_address));
}
- $bHandleAsSent = ($bSentFolder) || ((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)
$msg['FROM'] = $msg['TO'];
$senderAddress = _("To:") . ' ' . $senderAddress;
}
- if ( $truncate_sender > 0 && strlen($senderName) > $truncate_sender ) {
- $senderName = substr_replace($senderName, '... ', $truncate_sender);
- }
+ if ($truncate_sender > 0)
+ $senderName = truncateWithEntities($senderName, $truncate_sender);
echo html_tag( 'tr','','','','VALIGN="top"') . "\n";
/* Adjust if the first and second quarters intersect. */
} else if (($cur_pg - $q2_pgs - ceil($q2_pgs/3)) <= $q1_pgs) {
$extra_pgs = $q2_pgs;
- $extra_pgs -= ceil(($cur_pg - $q1_pgs - 1) * 0.75);
- $q2_pgs = ceil(($cur_pg - $q1_pgs - 1) * 0.75);
+ $extra_pgs -= ceil(($cur_pg - $q1_pgs - 1) * 3/4);
+ $q2_pgs = ceil(($cur_pg - $q1_pgs - 1) * 3/4);
$q3_pgs += ceil($extra_pgs / 2);
$q4_pgs += floor($extra_pgs / 2);
/* Adjust if the third and fourth quarter intersect. */
} else if (($cur_pg + $q3_pgs + 1) >= ($tot_pgs - $q4_pgs + 1)) {
$extra_pgs = $q3_pgs;
- $extra_pgs -= ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
- $q3_pgs = ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
+ $extra_pgs -= ceil(($tot_pgs - $cur_pg - $q4_pgs) * 3/4);
+ $q3_pgs = ceil(($tot_pgs - $cur_pg - $q4_pgs) * 3/4);
$q1_pgs += floor($extra_pgs / 2);
$q2_pgs += ceil($extra_pgs / 2);
}
return ($result);
}
-function processSubject($subject, $threadlevel = 0) {
- global $languages, $squirrelmail_language;
- /* Shouldn't ever happen -- caught too many times in the IMAP functions */
- if ($subject == '') {
- return _("(no subject)");
- }
-
- $trim_at = SUBJ_TRIM_AT;
-
- /* if this is threaded, subtract two chars per indentlevel */
- if($threadlevel > 0 && $threadlevel <= 10) {
- $trim_at -= (2*$threadlevel);
- }
-
- if (strlen($subject) <= $trim_at) {
+function truncateWithEntities($subject, $trim_at)
+{
+ $ent_strlen = strlen($subject);
+ if (($trim_at <= 0) || ($ent_strlen <= $trim_at))
return $subject;
- }
- $ent_strlen = $orig_len = strlen($subject);
- $trim_val = $trim_at - 5;
- $ent_offset = 0;
+ global $languages, $squirrelmail_language;
+
/*
* see if this is entities-encoded string
* If so, Iterate through the whole string, find out
* the real number of characters, and if more
- * than 55, substr with an updated trim value.
+ * than $trim_at, substr with an updated trim value.
*/
- $step = $ent_loc = 0;
+ $trim_val = $trim_at;
+ $ent_offset = 0;
+ $ent_loc = 0;
while ( $ent_loc < $trim_val && (($ent_loc = strpos($subject, '&', $ent_offset)) !== false) &&
(($ent_loc_end = strpos($subject, ';', $ent_loc+3)) !== false) ) {
$trim_val += ($ent_loc_end-$ent_loc);
$ent_offset = $ent_loc_end+1;
- ++$step;
}
-
- if (($trim_val > 50) && (strlen($subject) > ($trim_val))&& (strpos($subject,';',$trim_val) < ($trim_val +6))) {
+ if (($trim_val > $trim_at) && ($ent_strlen > $trim_val) && (strpos($subject,';',$trim_val) < ($trim_val + 6))) {
$i = strpos($subject,';',$trim_val);
if ($i) {
$trim_val = strpos($subject,';',$trim_val);
}
}
- if ($ent_strlen <= $trim_at){
+ // only print '...' when we're actually dropping part of the subject
+ if ($ent_strlen <= $trim_val)
return $subject;
- }
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
return $languages[$squirrelmail_language]['XTRA_CODE']('strimwidth', $subject, $trim_val);
}
- // only print '...' when we're actually dropping part of the subject
- if(strlen($subject) <= $trim_val) {
- return $subject;
- } else {
- return substr($subject, 0, $trim_val) . '...';
+ return substr_replace($subject, '...', $trim_val);
+}
+
+function processSubject($subject, $threadlevel = 0) {
+ /* Shouldn't ever happen -- caught too many times in the IMAP functions */
+ if ($subject == '') {
+ return _("(no subject)");
}
+
+ global $truncate_subject; /* number of characters for Subject field (<= 0 for unchanged) */
+ $trim_at = $truncate_subject;
+
+ /* if this is threaded, subtract two chars per indentlevel */
+ if (($threadlevel > 0) && ($threadlevel <= 10))
+ $trim_at -= (2*$threadlevel);
+
+ return truncateWithEntities($subject, $trim_at);
}
function getMbxList($imapConnection, $boxes = 0) {
return (array($start_msg,$end_msg));
}
+// This should go in imap_mailbox.php
function handleAsSent($mailbox) {
global $handleAsSent_result;