X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fleft_main.php;h=99121dee1aa027d4d51ca8d67c6e047655798250;hp=83175f63ae67eaf741072c6deb4ff675ddadea95;hb=b9f7585798177fd77a151ea644324b8833fef810;hpb=82d304a0501324b276cabab1870755d5352bd21c diff --git a/src/left_main.php b/src/left_main.php index 83175f63..99121dee 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -3,17 +3,20 @@ /** * left_main.php * - * Copyright (c) 1999-2004 The SquirrelMail Project Team + * Copyright (c) 1999-2005 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 * available, and has cookie information. * - * $Id$ + * @version $Id$ * @package squirrelmail */ -/** Path for SquirrelMail required files. */ +/** + * Path for SquirrelMail required files. + * @ignore + */ define('SM_PATH','../'); /* SquirrelMail required files. */ @@ -32,11 +35,8 @@ define('SM_BOX_COLLAPSED', 1); function formatMailboxName($imapConnection, $box_array) { - global $folder_prefix, $trash_folder, $sent_folder, - $color, $move_to_sent, $move_to_trash, - $unseen_notify, $unseen_type, $collapse_folders, - $draft_folder, $save_as_draft, - $use_special_folder_color; + global $trash_folder, $color, $move_to_trash, + $unseen_notify, $unseen_type, $use_special_folder_color; $real_box = $box_array['unformatted']; $mailbox = str_replace(' ','',$box_array['formatted']); $mailboxURL = urlencode($real_box); @@ -49,10 +49,10 @@ function formatMailboxName($imapConnection, $box_array) { $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; - } + $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)); @@ -61,12 +61,12 @@ function formatMailboxName($imapConnection, $box_array) { $line = ''; /* If there are unseen message, bold the line. */ - if ($unseen > 0) { $line .= ''; } + if ($unseen > 0) { $line .= ''; } /* Create the link for this folder. */ if ($status !== false) { - $line .= ''; + $line .= ''; } if ($special_color) { $line .= ""; @@ -74,20 +74,20 @@ function formatMailboxName($imapConnection, $box_array) { if ( $mailbox == 'INBOX' ) { $line .= _("INBOX"); } else { - $line .= str_replace(' ',' ',$mailbox); + $line .= str_replace(array(' ','<','>'),array(' ','<','>'),$mailbox); } if ($special_color == TRUE) $line .= ''; if ($status !== false) { - $line .= ''; + $line .= ''; } /* If there are unseen message, close bolding. */ - if ($unseen > 0) { $line .= ""; } + if ($unseen > 0) { $line .= ""; } /* Print unseen information. */ if ($unseen_string != '') { - $line .= " $unseen_string"; + $line .= " $unseen_string"; } /* If it's the trash folder, show a purge link when needed */ @@ -99,8 +99,8 @@ function formatMailboxName($imapConnection, $box_array) { if (($numMessages > 0) or ($box_array['parent'] == 1)) { $urlMailbox = urlencode($real_box); $line .= "\n\n" . - "  ("._("purge").")" . - ""; + '  ['._("Purge").']' . + ''; } } @@ -170,7 +170,7 @@ function compute_folder_children(&$parbox, $boxcount) { * currently appropriate. */ function create_collapse_link($boxnum) { - global $boxes, $imapConnection, $unseen_notify, $color, $use_icons, $icon_theme; + global $boxes, $unseen_notify, $color, $use_icons, $icon_theme; $mailbox = urlencode($boxes[$boxnum]['unformatted']); /* Create the link for this collapse link. */ @@ -178,13 +178,13 @@ function create_collapse_link($boxnum) { 'href="left_main.php?'; if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED) { if ($use_icons && $icon_theme != 'none') { - $link .= "unfold=$mailbox\">"; + $link .= "unfold=$mailbox\">'; } else { $link .= "unfold=$mailbox\">+"; } } else { if ($use_icons && $icon_theme != 'none') { - $link .= "fold=$mailbox\">"; + $link .= "fold=$mailbox\">'; } else { $link .= "fold=$mailbox\">-"; } @@ -207,7 +207,7 @@ function create_collapse_link($boxnum) { * @return array unseen message string (for display), unseen message count */ function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type) { - global $boxes, $unseen_type, $color, $unseen_cum; + global $boxes, $color, $unseen_cum; /* Initialize the return value. */ $result = array(0,0); @@ -222,7 +222,7 @@ function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type $status = sqimap_status_messages($imapConnection, $boxName); $boxUnseenCount = $status['UNSEEN']; if ($boxUnseenCount === false) { - return false; + return false; } if ($unseen_type == 2) { $boxMessageCount = $status['MESSAGES']; @@ -242,10 +242,10 @@ function create_unseen_string($boxName, $boxArray, $imapConnection, $unseen_type /* Collect the counts for this subfolder. */ if (($boxName != $boxes[$i]['unformatted']) - && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName) - && !in_array('noselect', $boxes[$i]['flags'])) { - $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']); - $subUnseenCount = $status['UNSEEN']; + && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName) + && !in_array('noselect', $boxes[$i]['flags'])) { + $status = sqimap_status_messages($imapConnection, $boxes[$i]['unformatted']); + $subUnseenCount = $status['UNSEEN']; if ($unseen_type == 2) { $subMessageCount = $status['MESSAGES'];; } @@ -293,9 +293,9 @@ function is_parent_box($curbox_name, $parbox_name) { } function ListBoxes ($boxes, $j=0 ) { - global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type, - $move_to_trash, $trash_folder, $collapse_folders, $imapConnection, - $use_icons, $icon_theme; + global $data_dir, $username, $color, $unseen_notify, $unseen_type, + $move_to_trash, $trash_folder, $collapse_folders, $imapConnection, + $use_icons, $icon_theme, $use_special_folder_color; if (!isset($boxes) || empty($boxes)) return; @@ -352,13 +352,13 @@ function ListBoxes ($boxes, $j=0 ) { $link = '$leader "; + $link .= "unfold=$mailboxURL\">$leader '; } else { $link .= "unfold=$mailboxURL\">$leader+ "; } } else { if ($use_icons && $icon_theme != 'none') { - $link .= "fold=$mailboxURL\">$leader "; + $link .= "fold=$mailboxURL\">$leader '; } else { $link .= "fold=$mailboxURL\">$leader- "; } @@ -377,16 +377,16 @@ function ListBoxes ($boxes, $j=0 ) { if ($unseen > 0) { $pre .= ''; } - $pre .= ""; + $pre .= ""; + $end .= ''; if ($unseen > 0) { $end .= ''; } - $end .= ''; if ($boxes->total > 0) { if ($unseen > 0) { $pre .= ''; } - $pre .= ""; + $pre .= ""; if ($unseen > 0) { $end .= ''; } @@ -395,19 +395,19 @@ function ListBoxes ($boxes, $j=0 ) { $end .= " $unseen_string"; } $end .= "\n\n" . - "  ("._("purge").")" . - ""; + '  ['._("Purge").']'. + ''; } } else { if (!$boxes->is_noselect) { if ($unseen > 0) { $pre .= ''; } - $pre .= ""; + $pre .= ""; + $end .= ''; if ($unseen > 0) { $end .= ''; } - $end .= ''; } /* Print unseen information. */ if ($unseen_found) { @@ -418,20 +418,20 @@ function ListBoxes ($boxes, $j=0 ) { $font = ''; $fontend = ''; - if ($boxes->is_special) { + if ($use_special_folder_color && $boxes->is_special) { $font = ""; $fontend = ""; } // let plugins fiddle with end of line $end .= concat_hook_function('left_main_after_each_folder', - array(isset($numMessages) ? $numMessages : '', + array(isset($numMessages) ? $numMessages : '', $boxes->mailboxname_full, $imapConnection)); $end .= ''; if (!$boxes->is_root) { - echo "" . $pre .$font. $boxes->mailboxname_sub .$fontend . $end. '
' . "\n"; + echo "" . $pre .$font. str_replace(array(' ','<','>'),array(' ','<','>'),$boxes->mailboxname_sub) .$fontend . $end. '
' . "\n"; $j++; } @@ -443,8 +443,8 @@ function ListBoxes ($boxes, $j=0 ) { } function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { - global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type, - $move_to_trash, $trash_folder, $collapse_folders; + global $data_dir, $username, $color, $unseen_notify, $unseen_type, + $move_to_trash, $trash_folder, $collapse_folders, $use_special_folder_color; if (!isset($boxes) || empty($boxes)) return; @@ -499,7 +499,7 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { if ($unseen > 0) { $pre .= ''; } /* color special boxes */ - if ($boxes->is_special) { + if ($use_special_folder_color && $boxes->is_special) { $pre .= ""; $end .= ''; } @@ -516,17 +516,16 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { if (! isset($numMessages)) { $numMessages = $boxes->total; } - $pre = "" . $pre; + $pre = "" . $pre; $end .= ''; if ($numMessages > 0) { - $urlMailbox = urlencode($mailbox); $end .= "\n\n" . - "  ("._("purge").")" . - ""; + '  ['._("Purge").']'. + ''; } } else { if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */ - $pre = "" . $pre; + $pre = "" . $pre; $end .= ''; } } @@ -534,7 +533,7 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { // let plugins fiddle with end of line global $imapConnection; $end .= concat_hook_function('left_main_after_each_folder', - array(isset($numMessages) ? $numMessages : '', + array(isset($numMessages) ? $numMessages : '', $boxes->mailboxname_full, $imapConnection)); if (!$boxes->is_root) { @@ -558,7 +557,7 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { } if (!isset($boxes->mbxs[0])) { echo ' ' . html_tag( 'div', - ''. $pre . $folder_img . ''. $boxes->mailboxname_sub . $end, + ''. $pre . $folder_img . ''. str_replace(array(' ','<','>'),array(' ','<','>'),$boxes->mailboxname_sub) . $end, 'left', '', 'class="mbx_sub" id="' .$j. '"' ) . "\n"; } else { /* get collapse information */ @@ -659,156 +658,139 @@ if (! isset($oldway) || $oldway=="" ) { } if ($advanced_tree) { -$xtra .= << - - - - - -ECHO; +$xtra .= 'old_col = masterf.cols;'."\n". +' colPat.exec(old_col);'."\n". +' if (direction) {'."\n". +' new_col_width = parseInt(RegExp.$1) + 25;'."\n". +' } else {'."\n". +' if (parseInt(RegExp.$1) > 35) {'."\n". +' new_col_width = parseInt(RegExp.$1) - 25;'."\n". +' }'."\n". +' }'."\n". +' masterf.cols = calc_col(new_col_width);'."\n". +' }'."\n". +'//-->'."\n". +''."\n"; /* style definitions */ -$xtra .= << - - - - -ECHO; - +$xtra .= ''."\n"; } displayHtmlHeader( 'SquirrelMail', $xtra ); - +sqgetGlobalVar('auto_create_done',$auto_create_done,SQ_SESSION); /* If requested and not yet complete, attempt to autocreate folders. */ if ($auto_create_special && !isset($auto_create_done)) { $autocreate = array($sent_folder, $trash_folder, $draft_folder); @@ -929,8 +889,15 @@ if ($auto_create_special && !isset($auto_create_done)) { if (($folder != '') && ($folder != 'none')) { if ( !sqimap_mailbox_exists($imapConnection, $folder)) { sqimap_mailbox_create($imapConnection, $folder, ''); - } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) { - sqimap_subscribe($imapConnection, $folder); + } else { + // check for subscription is useless and expensive, just + // surpress the NO response. Unless we're on Mecury, which + // will just subscribe a folder again if it's already + // subscribed. + if ( strtolower($imap_server_type) != 'mercury32' || + !sqimap_mailbox_is_subscribed($imapConnection, $folder) ) { + sqimap_subscribe($imapConnection, $folder, false); + } } } } @@ -940,33 +907,37 @@ if ($auto_create_special && !isset($auto_create_done)) { sqsession_register($auto_create_done, 'auto_create_done'); } -if ($advanced_tree) - echo "\n\n"; -else - echo "\n\n"; +if ($advanced_tree) { + echo "\n\n"; +} else { + 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 '


';*/ } 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"; + html_tag( 'table', '', '', '', 'border="0" cellspacing="0" cellpadding="0" width="98%"' ) . + html_tag( 'tr' ) . + html_tag( 'td', '', 'center' ) . + ''. _("Folders") . "
\n\n"; if ($date_format != 6) { /* First, display the clock. */ if ($hour_format == 1) { - $hr = 'G:i'; + $hr = 'H:i'; if ($date_format == 4) { $hr .= ':s'; } @@ -979,6 +950,9 @@ if ($date_format != 6) { } switch( $date_format ) { + case 0: + $clk = date('Y-m-d '.$hr. ' T', time()); + break; case 1: $clk = date('m/d/y '.$hr, time()); break; @@ -994,13 +968,14 @@ if ($date_format != 6) { } $clk = str_replace(' ',' ',$clk); - echo '
' . str_replace(' ',' ',_("Last Refresh")) . - ": $clk
"; + echo '' + . str_replace(' ', ' ', _("Last Refresh")) + . ":
$clk

"; } /* Next, display the refresh button. */ -echo '('. - _("refresh folder list") . ')

'; +echo '
'; /* Lastly, display the folder list. */ if ( $collapse_folders ) { @@ -1082,7 +1057,7 @@ for ($i = 0; $i < count($boxes); $i++) { } /* Put the final touches on our folder line. */ - $line .= "
\n"; + $line .= "
\n"; /* Output the line for this folder. */ echo $line; @@ -1103,14 +1078,13 @@ for ($i = 0; $i < count($boxes); $i++) { echo ''; echo ''."\n"; } else { - //sqimap_get_status_mbx_tree($imap_stream,$boxes) + //sqimap_get_status_mbx_tree($imap_stream,$boxes) ListBoxes($boxes); } } /* if ($oldway) else ... */ do_hook('left_main_after'); sqimap_logout($imapConnection); -echo '' . "\n". - "
\n"; - ?> + +