X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fleft_main.php;h=b65d839332e077dcb4c2dec64d240b12ffb592d7;hb=1e12d1ffb4f54350932a17397d38917db21d64df;hp=8cd03bcd1b75c43b35bb54b9c4999d3c72a3f78e;hpb=ee5b92f2f0cb620f294c5148b01a38a3a37b7bd6;p=squirrelmail.git diff --git a/src/left_main.php b/src/left_main.php index 8cd03bcd..b65d8393 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -3,7 +3,7 @@ /** * left_main.php * - * Copyright (c) 1999-2002 The SquirrelMail Project Team + * Copyright (c) 1999-2003 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * This is the code for the left bar. The left bar shows the folders @@ -17,7 +17,6 @@ define('SM_PATH','../'); /* SquirrelMail required files. */ require_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/array.php'); require_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'functions/plugin.php'); require_once(SM_PATH . 'functions/page_header.php'); @@ -36,7 +35,6 @@ function formatMailboxName($imapConnection, $box_array) { $unseen_notify, $unseen_type, $collapse_folders, $draft_folder, $save_as_draft, $use_special_folder_color; - $real_box = $box_array['unformatted']; $mailbox = str_replace(' ','',$box_array['formatted']); $mailboxURL = urlencode($real_box); @@ -45,8 +43,16 @@ function formatMailboxName($imapConnection, $box_array) { if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) { $mailbox = $regs[2]; } - - list($unseen_string, $unseen) = create_unseen_string($real_box, $box_array, $imapConnection); + $unseen = 0; + $status = array('',''); + if (($unseen_notify == 2 && $real_box == 'INBOX') || + $unseen_notify == 3) { + $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type ); + if ($status !== false) { + $status = $tmp_status; + } + } + list($unseen_string, $unseen) = $status; $special_color = ($use_special_folder_color && isSpecialMailbox($real_box)); /* Start off with a blank line. */ @@ -56,9 +62,10 @@ function formatMailboxName($imapConnection, $box_array) { if ($unseen > 0) { $line .= ''; } /* Create the link for this folder. */ - $line .= ''; - + if ($status !== false) { + $line .= ''; + } if ($special_color) { $line .= ""; } @@ -69,7 +76,9 @@ function formatMailboxName($imapConnection, $box_array) { } if ($special_color == TRUE) $line .= ''; - $line .= ''; + if ($status !== false) { + $line .= ''; + } /* If there are unseen message, close bolding. */ if ($unseen > 0) { $line .= ""; } @@ -79,12 +88,13 @@ function formatMailboxName($imapConnection, $box_array) { $line .= " $unseen_string"; } + /* If it's the trash folder, show a purge link when needed */ if (($move_to_trash) && ($real_box == $trash_folder)) { if (! isset($numMessages)) { $numMessages = sqimap_get_num_messages($imapConnection, $real_box); } - if ($numMessages > 0) { + if (($numMessages > 0) or ($box_array['parent'] == 1)) { $urlMailbox = urlencode($real_box); $line .= "\n\n" . "  ("._("purge").")" . @@ -181,8 +191,8 @@ function create_collapse_link($boxnum) { * @return array[0] unseen message string (for display) * @return array[1] unseen message count */ -function create_unseen_string($boxName, $boxArray, $imapConnection) { - global $boxes, $unseen_type, $color; +function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) { + global $boxes, $unseen_type, $color, $unseen_cum; /* Initialize the return value. */ $result = array(0,0); @@ -194,14 +204,18 @@ function create_unseen_string($boxName, $boxArray, $imapConnection) { $totalMessageCount = 0; /* Collect the counts for this box alone. */ - $boxUnseenCount = sqimap_unseen_messages($imapConnection, $boxName); + $status = sqimap_status_messages($imapConnection, $boxName); + $boxUnseenCount = $status['UNSEEN']; + if ($boxUnseenCount === false) { + return false; + } if ($unseen_type == 2) { - $boxMessageCount = sqimap_get_num_messages($imapConnection, $boxName); + $boxMessageCount = $status['MESSAGES']; } /* Initialize the total counts. */ - if ($boxArray['collapse'] == SM_BOX_COLLAPSED) { + if ($boxArray['collapse'] == SM_BOX_COLLAPSED && $unseen_cum) { /* Collect the counts for this boxes subfolders. */ $curBoxLength = strlen($boxName); $boxCount = count($boxes); @@ -215,11 +229,11 @@ function create_unseen_string($boxName, $boxArray, $imapConnection) { if (($boxName != $boxes[$i]['unformatted']) && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName) && !in_array('noselect', $boxes[$i]['flags'])) { - $subUnseenCount = sqimap_unseen_messages($imapConnection, $boxes[$i]['unformatted']); + $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']); + $subUnseenCount = $status['UNSEEN']; if ($unseen_type == 2) { - $subMessageCount = sqimap_get_num_messages($imapConnection, $boxes[$i]['unformatted']); + $subMessageCount = $status['MESSAGES'];; } - /* Add the counts for this subfolder to the total. */ $totalUnseenCount += $subUnseenCount; $totalMessageCount += $subMessageCount; @@ -273,7 +287,7 @@ function listBoxes ($boxes, $j=0 ) { $mailbox = $boxes->mailboxname_full; $leader = ''; for ($k = 0; $k < $j; $k++) { - $leader.= '   '; + $leader.= '   '; } $mailboxURL = urlencode($mailbox); @@ -296,14 +310,14 @@ function listBoxes ($boxes, $j=0 ) { $link = '$leader + "; + $link .= "unfold=$mailboxURL\">$leader + "; } else { - $link .= "fold=$mailboxURL\">$leader - "; + $link .= "fold=$mailboxURL\">$leader - "; } $link .= ''; $pre .= $link; } else { - $pre.= $leader . '   '; + $pre.= $leader . '   '; } @@ -312,39 +326,40 @@ function listBoxes ($boxes, $j=0 ) { if (($move_to_trash) && ($mailbox == $trash_folder)) { if (! isset($numMessages)) { - $numMessages = sqimap_get_num_messages($imapConnection, $mailbox); + $status = sqimap_status_messages($imapConnection, $mailbox); + $numMessages = $status['MESSAGES']; } if ($numMessages > 0) { $urlMailbox = urlencode($mailbox); $pre .= "\n\n" . - "  ("._("purge").")" . + "  ("._("purge").")" . ""; } } else { if (!$boxes->is_noselect) { - $pre .= ""; + $pre .= ""; $end .= ''; } } /* If there are unseen message, close bolding. */ - if ($unseen > 0) { $end .= ""; } + if ($unseen > 0) { $end .= ""; } /* Print unseen information. */ if (isset($unseen_found) && $unseen_found) { - $end .= " $unseen_string"; + $end .= " $unseen_string"; } $font = ''; $fontend = ''; if ($boxes->is_special) { - $font = ""; - $fontend = ""; + $font = ""; + $fontend = ""; } if (!$boxes->is_root) { - echo "" . $pre .$font. $boxes->mailboxname_sub .$fontend . $end. '
'; + echo "" . $pre .$font. $boxes->mailboxname_sub .$fontend . $end. '
'; $j++; } if (!$collapse || $boxes->is_root) { @@ -383,16 +398,16 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { } else $unseen = 0; /* If there are unseen message, bold the line. */ - if ($unseen > 0) { $pre .= ''; } + if ($unseen > 0) { $pre .= ''; } /* color special boxes */ if ($boxes->is_special) { - $pre .= ""; - $end .= ""; + $pre .= ""; + $end .= ''; } /* If there are unseen message, close bolding. */ - if ($unseen > 0) { $end .= ""; } + if ($unseen > 0) { $end .= ''; } /* Print unseen information. */ if (isset($unseen_found) && $unseen_found) { @@ -406,12 +421,12 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { if ($numMessages > 0) { $urlMailbox = urlencode($mailbox); $pre .= "\n\n" . - "  ("._("purge").")" . + "  ("._("purge").")" . ""; } } else { if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */ - $pre .= ""; + $pre .= ""; $end .= ''; } } @@ -427,7 +442,7 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { } else if ($boxes->is_draft) { $folder_img = '../images/draft.gif'; } else $folder_img = '../images/folder.gif'; - $folder_img = '  '; + $folder_img = '  '; } else $folder_img = ''; if (!isset($boxes->mbxs[0])) { echo ' ' . html_tag( 'div', @@ -451,9 +466,9 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); } if ($collapse) { - $link = ''." "; + $link = ''." "; } else { - $link = ''.""; + $link = ''.""; } $collapse_link = $link; } else $collapse_link=''; @@ -461,13 +476,13 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub . $end , 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n"; - echo ' '."\n"; + echo ' '."\n"; } } if ($collapse) { - $visible = ' STYLE="display:none;"'; + $visible = ' style="display:none;"'; } else { - $visible = ' STYLE="display:block;"'; + $visible = ' style="display:block;"'; } if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */ @@ -508,10 +523,10 @@ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 1 * Using stristr since older preferences may contain "None" and "none". */ if (isset($left_refresh) && ($left_refresh != '') && - !stristr($left_refresh, "none")){ - $xtra = "\n\n" . - "\n". - "\n"; + !stristr($left_refresh, 'none')){ + $xtra = "\n\n" . + "\n". + "\n"; } else { $xtra = ''; } @@ -696,7 +711,7 @@ ECHO; $xtra .= << + + ECHO; @@ -797,23 +812,23 @@ if ($auto_create_special && !isset($auto_create_done)) { sqsession_register($auto_create_done, 'auto_create_done'); } -echo "\n\n"; +echo "\n\n"; do_hook('left_main_before'); if ($advanced_tree) { /* nice future feature, needs layout !! volunteers? */ $right_pos = $left_size - 20; echo '
'; - echo ''; - echo ''; - echo '
'; - echo '


'; + echo ''; + echo ''; + echo '
'; + echo '


'; } echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) . html_tag( 'tr' ) . html_tag( 'td', '', 'left' ) . - '
'. _("Folders") . "
\n\n"; + '
'. _("Folders") . "
\n\n"; if ($date_format != 6) { /* First, display the clock. */ @@ -852,7 +867,7 @@ if ($date_format != 6) { /* Next, display the refresh button. */ echo '('. - _("refresh folder list") . ')

'; + _("refresh folder list") . ')

'; /* Lastly, display the folder list. */ if ( $collapse_folders ) { @@ -892,7 +907,7 @@ for ($i = 0; $i < count($boxes); $i++) { } else { $prefix = str_replace(' ',' ',$prefix); } - $line = "$prefix"; + $line = "$prefix"; /* Add the folder name and link. */ if (! isset($color[15])) { @@ -901,21 +916,21 @@ for ($i = 0; $i < count($boxes); $i++) { if (in_array('noselect', $boxes[$i]['flags'])) { if( isSpecialMailbox( $boxes[$i]['unformatted']) ) { - $line .= ""; + $line .= ""; } else { - $line .= ""; + $line .= ""; } if (ereg("^( *)([^ ]*)", $mailbox, $regs)) { $mailbox = str_replace(' ','',$mailbox); $line .= str_replace(' ', ' ', $mailbox); } - $line .= ''; + $line .= ''; } else { $line .= formatMailboxName($imapConnection, $boxes[$i]); } /* Put the final touches on our folder line. */ - $line .= "
\n"; + $line .= "
\n"; /* Output the line for this folder. */ echo $line; @@ -924,14 +939,14 @@ for ($i = 0; $i < count($boxes); $i++) { } else { /* expiremental code */ $boxes = sqimap_mailbox_tree($imapConnection); if (isset($advanced_tree) && $advanced_tree) { - echo '


'; - echo '
'."\n\n"; + echo '

'; + echo '
'."\n\n"; if (!isset($mbx)) $mbx=NULL; ListAdvancedBoxes($boxes, $mbx); echo '
'."\n"; - echo ''."\n"; + echo ''."\n"; } else { ListBoxes($boxes); }