X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fleft_main.php;h=2009a52599ccb69419a96e7c2b647ca72f301e15;hb=184ef883d079064633574cc287f9b6c57627b5d5;hp=a3f2dfade924189c20c843c37b508ea327c94a65;hpb=165829a378d4e41c1a47b46be08fdbd20315077f;p=squirrelmail.git diff --git a/src/left_main.php b/src/left_main.php index a3f2dfad..2009a525 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -3,30 +3,14 @@ /** * left_main.php * - * Copyright (c) 1999-2001 The Squirrelmail Development Team + * Copyright (c) 1999-2002 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$ - / - -/*****************************************************************/ -/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/ -/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/ -/*** + Base level indent should begin at left margin, as ***/ -/*** the require_once below looks. ***/ -/*** + All identation should consist of four space blocks ***/ -/*** + Tab characters are evil. ***/ -/*** + all comments should use "slash-star ... star-slash" ***/ -/*** style -- no pound characters, no slash-slash style ***/ -/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/ -/*** ALWAYS USE { AND } CHARACTERS!!! ***/ -/*** + Please use ' instead of ", when possible. Note " ***/ -/*** should always be used in _( ) function calls. ***/ -/*** Thank you for your help making the SM code more readable. ***/ -/*****************************************************************/ + */ require_once('../src/validate.php'); require_once('../functions/array.php'); @@ -41,11 +25,12 @@ define('SM_BOX_COLLAPSED', 1); /* --------------------- FUNCTIONS ------------------------- */ function formatMailboxName($imapConnection, $box_array) { - global $folder_prefix, $trash_folder, $sent_folder; - global $color, $move_to_sent, $move_to_trash; - global $unseen_notify, $unseen_type, $collapse_folders; - global $draft_folder, $save_as_draft; - global $use_special_folder_color; + + 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; $real_box = $box_array['unformatted']; $mailbox = str_replace(' ','',$box_array['formatted']); @@ -63,23 +48,15 @@ function formatMailboxName($imapConnection, $box_array) { $unseen = sqimap_unseen_messages($imapConnection, $real_box); if ($unseen_type == 1 && $unseen > 0) { $unseen_string = "($unseen)"; - $unseen_found = true; + $unseen_found = TRUE; } else if ($unseen_type == 2) { $numMessages = sqimap_get_num_messages($imapConnection, $real_box); $unseen_string = "($unseen/$numMessages)"; - $unseen_found = true; + $unseen_found = TRUE; } } - $special_color = false; - if ($use_special_folder_color) { - if ((strtolower($real_box) == 'inbox') - || (($real_box == $trash_folder) && ($move_to_trash)) - || (($real_box == $sent_folder) && ($move_to_sent)) - || (($real_box == $draft_folder) && ($save_as_draft))) { - $special_color = true; - } - } + $special_color = ($use_special_folder_color && isSpecialMailbox( $real_box ) ); /* Start off with a blank line. */ $line = ''; @@ -89,10 +66,15 @@ function formatMailboxName($imapConnection, $box_array) { /* Crate the link for this folder. */ $line .= ""; - if ($special_color == true) + if ($special_color) { $line .= ""; - $line .= str_replace(' ',' ',$mailbox); - if ($special_color == true) + } + if ( $mailbox == 'INBOX' ) { + $line .= _("INBOX"); + } else { + $line .= str_replace(' ',' ',$mailbox); + } + if ($special_color == TRUE) $line .= ""; $line .= ''; @@ -104,7 +86,7 @@ function formatMailboxName($imapConnection, $box_array) { $line .= " $unseen_string"; } - if (($move_to_trash == true) && ($real_box == $trash_folder)) { + if (($move_to_trash) && ($real_box == $trash_folder)) { if (! isset($numMessages)) { $numMessages = sqimap_get_num_messages($imapConnection, $real_box); } @@ -113,7 +95,7 @@ function formatMailboxName($imapConnection, $box_array) { $urlMailbox = urlencode($real_box); $line .= "\n\n" . "  ("._("empty").")" . - "\n\n"; + ""; } } @@ -134,7 +116,7 @@ function compute_folder_children(&$parbox, $boxcount) { $parbox_name = $boxes[$parbox]['unformatted']; /* 'Initialize' this parent box to childless. */ - $boxes[$parbox]['parent'] = false; + $boxes[$parbox]['parent'] = FALSE; /* Compute the collapse status for this box. */ if( isset($collapse_folders) && $collapse_folders ) { @@ -146,25 +128,22 @@ function compute_folder_children(&$parbox, $boxcount) { $boxes[$parbox]['collapse'] = $collapse; /* Otherwise, get the name of the next box. */ - if (isset($boxes[$nextbox]['unformatted'])) + if (isset($boxes[$nextbox]['unformatted'])) { $nextbox_name = $boxes[$nextbox]['unformatted']; - else + } else { $nextbox_name = ''; + } /* Compute any children boxes for this box. */ while (($nextbox < $boxcount) && (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) { /* Note that this 'parent' box has at least one child. */ - $boxes[$parbox]['parent'] = true; + $boxes[$parbox]['parent'] = TRUE; /* Compute the visiblity of this box. */ - if ($boxes[$parbox]['visible'] && - ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED)) { - $boxes[$nextbox]['visible'] = true; - } else { - $boxes[$nextbox]['visible'] = false; - } + $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] && + ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED)); /* Compute the visibility of any child boxes. */ compute_folder_children($nextbox, $boxcount); @@ -184,8 +163,8 @@ function create_collapse_link($boxnum) { $mailbox = urlencode($boxes[$boxnum]['unformatted']); /* Create the link for this collapse link. */ - $link = '+"; } else { @@ -234,21 +213,19 @@ displayHtmlHeader( 'SquirrelMail', $xtra ); /* 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 ); + $autocreate = array($sent_folder, $trash_folder, $draft_folder); foreach( $autocreate as $folder ) { - if ($folder != '' && $folder != 'none') { + if (($folder != '') && ($folder != 'none')) { if ( !sqimap_mailbox_exists($imapConnection, $folder)) { sqimap_mailbox_create($imapConnection, $folder, ''); - } elseif ( !sqimap_mailbox_is_subscribed($imapConnection, $folder)) { + } else if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) { sqimap_subscribe($imapConnection, $folder); } } } /* Let the world know that autocreation is complete! Hurrah! */ - $auto_create_done = true; + $auto_create_done = TRUE; session_register('auto_create_done'); } @@ -287,7 +264,7 @@ if ($date_format != 6) { $clk = date($hr, time()); break; default: - $clk = date('D, '.$hr, time()); + $clk = substr( getDayName( date( 'w', time() ) ), 0, 3 ) . date( ', ' . $hr, time() ); } $clk = str_replace(' ',' ',$clk); @@ -314,12 +291,14 @@ $curbox = 0; $boxcount = count($boxes); /* Compute the collapsedness and visibility of each box. */ + while ($curbox < $boxcount) { $boxes[$curbox]['visible'] = TRUE; compute_folder_children($curbox, $boxcount); } -for ($i = 0;$i < count($boxes); $i++) { + +for ($i = 0; $i < count($boxes); $i++) { if ( $boxes[$i]['visible'] ) { $mailbox = $boxes[$i]['formatted']; $mblevel = substr_count($boxes[$i]['unformatted'], $delimiter) + 1; @@ -335,8 +314,16 @@ for ($i = 0;$i < count($boxes); $i++) { $line = "$prefix"; /* Add the folder name and link. */ + if (! isset($color[15])) { + $color[15] = $color[6]; + } + if (in_array('noselect', $boxes[$i]['flags'])) { - $line .= ""; + if( isSpecialMailbox( $boxes[$i]['unformatted']) ) { + $line .= ""; + } else { + $line .= ""; + } if (ereg("^( *)([^ ]*)", $mailbox, $regs)) { $mailbox = str_replace(' ','',$mailbox); $line .= str_replace(' ', ' ', $mailbox);