From 8415b2d3c0d33a6e4b4053496ffffd1d1f61bc22 Mon Sep 17 00:00:00 2001 From: indiri69 Date: Fri, 2 May 2003 21:31:25 +0000 Subject: [PATCH] Change message highlighting so order matters. It will not select the first match it finds (old way was last match). You can also reorder highlighting now. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4842 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mailbox_display.php | 75 +++++++++++++---------------------- src/options_highlight.php | 55 +++++++++++++++++++------ 2 files changed, 71 insertions(+), 59 deletions(-) diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 97f1418b..3d6a87c4 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -134,60 +134,41 @@ function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox, } else { $searchstr = ''; } - /** - * AAAAH! Make my eyes stop bleeding! - * Who wrote this?! - */ + if (is_array($message_highlight_list) && count($message_highlight_list)) { - $msg['TO'] = parseAddress($msg['TO']); - $msg['CC'] = parseAddress($msg['CC']); + $msg['TO'] = parseAddress($msg['TO']); + $msg['CC'] = parseAddress($msg['CC']); 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']); - switch($match_type) { - case('TO'): - case('TO_CC'): - foreach ($msg['TO'] as $address) { - $address[0] = decodeHeader($address[0]); - $address[1] = decodeHeader($address[1]); - if (strstr('^^' . strtolower($address[0]), $high_val) || - strstr('^^' . strtolower($address[1]), $high_val)) { - $hlt_color = $message_highlight_list_part['color']; - continue; + 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 ($msg[$match_type] as $address) { + $address[0] = decodeHeader($address[0]); + $address[1] = decodeHeader($address[1]); + if (strstr('^^' . strtolower($address[0]), $high_val) || + strstr('^^' . strtolower($address[1]), $high_val)) { + $hlt_color = $message_highlight_list_part['color']; + break 4; + } } - } - if($match_type != 'TO_CC') { break; - } - case('CC'): - foreach ($msg['CC'] as $address) { - $address[0] = decodeHeader($address[0]); - $address[1] = decodeHeader($address[1]); - if( strstr('^^' . strtolower($address[0]), $high_val) || - strstr('^^' . strtolower($address[1]), $high_val)) { + default: + if (strstr('^^' . strtolower($msg[$match_type]), $high_val)) { $hlt_color = $message_highlight_list_part['color']; - continue; + break 3; } - } - break; - case('FROM'): - foreach ($msg['FROM'] as $address) { - $address[0] = decodeHeader($address[0]); - $address[1] = decodeHeader($address[1]); - if( strstr('^^' . strtolower($address[0]), $high_val) || - strstr('^^' . strtolower($address[1]), $high_val)) { - $hlt_color = $message_highlight_list_part['color']; - continue; - } - } - break; - default: - if (strstr('^^' . strtolower($msg[$match_type]), $high_val)) { - $hlt_color = $message_highlight_list_part['color']; - continue; - } - break; + break; + } } } } @@ -393,7 +374,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs, $msgs = array(); } - $start = microtime(); + //$start = microtime(); /* If autoexpunge is turned on, then do it now. */ $mbxresponse = sqimap_mailbox_select($imapConnection, $mailbox); $srt = $sort; @@ -507,7 +488,7 @@ function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs, mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color); echo ''; - $t = elapsed($start); + //$t = elapsed($start); //echo("elapsed time = $t seconds\n"); } diff --git a/src/options_highlight.php b/src/options_highlight.php index 2af438b5..fe5b24db 100644 --- a/src/options_highlight.php +++ b/src/options_highlight.php @@ -64,13 +64,34 @@ if (! isset($message_highlight_list)) { $message_highlight_list = array(); } -if ($action == 'delete' && isset($theid)) { - +if (isset($theid) && ($action == 'delete') || + ($action == 'up') || + ($action == 'down')) { $new_rules = array(); - foreach($message_highlight_list as $rid => $rule) { - if($rid != $theid) { - $new_rules[] = $rule; - } + switch($action) { + case('delete'): + foreach($message_highlight_list as $rid => $rule) { + if($rid != $theid) { + $new_rules[] = $rule; + } + } + break; + case('down'): + $theid++; + case('up'): + foreach($message_highlight_list as $rid => $rule) { + if($rid == $theid) { + $temp_rule = $new_rules[$rid-1]; + $new_rules[$rid-1] = $rule; + $new_rules[$rid] = $temp_rule; + } else { + $new_rules[$rid] = $rule; + } + } + break; + default: + $new_rules = $message_highlight_list; + break; } $message_highlight_list = $new_rules; @@ -115,9 +136,10 @@ html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="1" cellspac echo '
[' . _("New") . ']'. ' - ['._("Done").']

'."\n"; -if (count($message_highlight_list) >= 1) { +$mhl_count = count($message_highlight_list); +if ($mhl_count > 0) { echo html_tag( 'table', '', 'center', '', 'width="80%" border="0" cellpadding="3" cellspacing="0"' ) . "\n"; - for ($i=0; $i < count($message_highlight_list); $i++) { + for ($i=0; $i < $mhl_count; $i++) { $match_type = ''; switch ($message_highlight_list[$i]['match_type'] ) { case 'from' : @@ -137,12 +159,21 @@ if (count($message_highlight_list) >= 1) { break; } + $links = '[' . + _("Edit") . + '] [' . + _("Delete"); + if($i > 0) { + $links .= '] [' . _("Up"); + } + if($i+1 < $mhl_count) { + $links .= '] [' . _("Down"); + } + $links .= ']'; + echo html_tag( 'tr', html_tag( 'td', - '[' . - _("Edit") . - '] [' . _("Delete") . ']' , + $links, 'left', $color[4], 'width="20%" nowrap' ) . html_tag( 'td', htmlspecialchars($message_highlight_list[$i]['name']) , -- 2.25.1