[ #500367 ] Blank line between Trash and Sent
[squirrelmail.git] / src / left_main.php
index f3458cff2faa8aa98c0a39dc8ab0de0551dcffd1..6491ec9687fb9a050a8f6ec4be164e07af94ea3a 100644 (file)
@@ -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 = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
-            $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,11 @@ function formatMailboxName($imapConnection, $box_array) {
 
     /* Crate the link for this folder. */
     $line .= "<A HREF=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" TARGET=\"right\" STYLE=\"text-decoration:none\">";
-    if ($special_color == true)
+    if ($special_color) {
         $line .= "<FONT COLOR=\"$color[11]\">";
+    }
     $line .= str_replace(' ','&nbsp;',$mailbox);
-    if ($special_color == true)
+    if ($special_color == TRUE)
         $line .= "</FONT>";
     $line .= '</A>';
 
@@ -104,7 +82,7 @@ function formatMailboxName($imapConnection, $box_array) {
         $line .= "&nbsp;<SMALL>$unseen_string</SMALL>";
     }
 
-    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 +91,7 @@ function formatMailboxName($imapConnection, $box_array) {
             $urlMailbox = urlencode($real_box);
             $line .= "\n<small>\n" .
                     "&nbsp;&nbsp;(<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("empty")."</A>)" .
-                    "\n</small>\n";
+                    "</small>";
         }
     }
 
@@ -134,7 +112,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 +124,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 +159,8 @@ function create_collapse_link($boxnum) {
     $mailbox = urlencode($boxes[$boxnum]['unformatted']);
 
     /* Create the link for this collapse link. */
-    $link = '<a target="left" style="text-decoration:none" ';
-    $link .= 'href="left_main.php?';
+    $link = '<a target="left" style="text-decoration:none" ' .
+            'href="left_main.php?';
     if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED) {
         $link .= "unfold=$mailbox\">+";
     } else {
@@ -246,7 +221,7 @@ if ($auto_create_special && !isset($auto_create_done)) {
     }
 
     /* Let the world know that autocreation is complete! Hurrah! */
-    $auto_create_done = true;
+    $auto_create_done = TRUE;
     session_register('auto_create_done');
 }
 
@@ -285,7 +260,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(' ','&nbsp;',$clk);
 
@@ -312,12 +287,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;
@@ -333,8 +310,16 @@ for ($i = 0;$i < count($boxes); $i++) {
         $line = "<NOBR><TT>$prefix</TT>";
 
         /* Add the folder name and link. */
+        if (! isset($color[15])) {
+            $color[15] = $color[6];
+        }
+
         if (in_array('noselect', $boxes[$i]['flags'])) {
-            $line .= "<FONT COLOR=\"$color[7]\">";
+            if( isSpecialMailbox( $boxes[$i]['unformatted']) ) {
+                $line .= "<FONT COLOR=\"$color[11]\">";
+            } else {
+                $line .= "<FONT COLOR=\"$color[15]\">";
+            }
             if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
                 $mailbox = str_replace('&nbsp;','',$mailbox);
                 $line .= str_replace(' ', '&nbsp;', $mailbox);