Pārlūkot izejas kodu

In order to make sent_subfolders work I had to change a lot of code.
I may have messed up something in the process so PLEASE TEST THIS
CARFULLY.

In my system (that uses uw) it almost work. The only thing left to
be done is to organize left main in such a way that sent subfolders
are placed to the top.

I've replaced some spare code with a few new functions.
sqimap_mailbox_rename and isSpecialMailbox are the most interesting
in other proceses.

philippe_mingo 23 gadi atpakaļ
vecāks
revīzija
3e4854f7e8

+ 50 - 8
functions/imap_mailbox.php

@@ -137,7 +137,49 @@ function sqimap_mailbox_is_subscribed($imap_stream, $folder)
     return false;
 }
 
+/*
+    Renames a mailbox
+*/
+function sqimap_mailbox_rename( $imap_stream, $old_name, $new_name ) {
 
+    if ( $old_name <> $new_name ) {
+
+        global $delimiter;
+
+        if ( substr( $old_name, -1 ) == $delimiter  ) {
+            $old_name = substr( $old_name, 0, strlen( $old_name ) - 1 );
+            $new_name = substr( $new_name, 0, strlen( $new_name ) - 1 );
+            $postfix = $delimiter;
+            $boxes = sqimap_mailbox_list($imap_stream);
+        } else {
+            $postfix = '';
+            $boxes = FALSE;
+        }
+
+        $cmd = sqimap_session_id() . " RENAME \"" . quoteIMAP($old_name) . "\" \"" .
+               quoteIMAP($new_name) . "\"\r\n";
+        fputs($imap_stream, $cmd);
+        $data = sqimap_read_data($imap_stream, sqimap_session_id(),
+                                 TRUE, $response, $message);
+        sqimap_unsubscribe($imap_stream, $old_name.$postfix);
+        sqimap_subscribe($imap_stream, $new_name.$postfix);
+
+        if ( $boxes ) {
+            // Sub-unsub subfolders
+            $l = strlen( $old_name ) + 1;
+            $p = 'unformatted';
+            foreach ( $boxes as $box ) {
+                if ( substr( $box[$p], 0, $l ) == $old_name . $delimiter ) {
+                    sqimap_unsubscribe($imap_stream, $box[$p]);
+                    sqimap_subscribe($imap_stream,
+                                     $new_name . $delimiter . substr( $box[$p], $l ) );
+                }
+            }
+        }
+
+    }
+
+}
 
 /******************************************************************************
  **  Formats a mailbox into 4 parts for the $boxes array
@@ -481,14 +523,14 @@ function sqimap_mailbox_list_all ($imap_stream)
                  $read_ary[$i], $regs)) {
             $i ++;
             $read_ary[$i] = $regs[1] . '"' . 
-			    addslashes(trim($read_ary[$i])) .
-			    '"' . $regs[2];
+                            addslashes(trim($read_ary[$i])) .
+                            '"' . $regs[2];
         }
         if (substr ($read_ary[$i], 0, $lsid) != $ssid ) {
             
             /* Store the raw IMAP reply */
             $boxes[$g]["raw"] = $read_ary[$i];
-            
+
             /* Count number of delimiters ($delimiter) in folder name */
             $mailbox = find_mailbox_name($read_ary[$i]);
             $dm_count =  substr_count($mailbox, $delimiter);
@@ -534,9 +576,9 @@ function sqimap_mailbox_list_all ($imap_stream)
             if (isset($read_mlbx[1]) &&
                 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$", 
                      $read_mlbx[0], $regs)) {
-                $read_mlbx[0] = $regs[1] . '"' . 
-				    addslashes(trim($read_mlbx[1])) .
-				    '"' . $regs[2];
+                $read_mlbx[0] = $regs[1] . '"' .
+                                addslashes(trim($read_mlbx[1])) .
+                                '"' . $regs[2];
             }
             
             $flags = substr($read_mlbx[0], strpos($read_mlbx[0], "(")+1);
@@ -544,7 +586,7 @@ function sqimap_mailbox_list_all ($imap_stream)
             $flags = str_replace('\\', '', $flags);
             $flags = trim(strtolower($flags));
             if ($flags) {
-                $boxes[$g]['flags'] = explode(" ", $flags);
+                $boxes[$g]['flags'] = explode(' ', $flags);
             }
             else {
                 $boxes[$g]['flags'] = array();
@@ -553,7 +595,7 @@ function sqimap_mailbox_list_all ($imap_stream)
         $g++;
     }
     if(is_array($boxes)) {
-        $boxes = ary_sort ($boxes, "unformatted", 1);
+        $boxes = ary_sort ($boxes, 'unformatted', 1);
     }
     
     return $boxes;

+ 0 - 1
functions/page_header.php

@@ -81,7 +81,6 @@ function checkForm() {
         i++;
     }
     if( pos >= 0 ) {
-        // document.write( "Si tio" );
         document.forms[i-1].elements[pos].focus();
     }
     

+ 38 - 27
plugins/sent_subfolders/setup.php

@@ -149,40 +149,51 @@ function sent_subfolders_update_sentfolder() {
     global $username, $data_dir, $key, $imapServerAddress, $imapPort;
     global $use_sent_subfolders, $move_to_sent;
 
-    if ($use_sent_subfolders && $move_to_sent) {
+    if ($use_sent_subfolders || $move_to_sent) {
         $year = date('Y');
         $month = date('m');
         $quarter = sent_subfolder_getQuarter($month);
 
+        /*
+            Regarding the structure we've got three main possibilities.
+            One sent holder. level 0.
+            Multiple year holders with messages in it. level 1.
+            Multiple year folders with holders in it. level 2.
+        */
         switch ($sent_subfolders_setting) {
-            case SMPREF_SENT_SUBFOLDERS_YEARLY:
-                $sent_subfolder = $sent_subfolders_base
-                                . $delimiter . $year;
-                $year_folder = $sent_subfolder;
-                break;
-            case SMPREF_SENT_SUBFOLDERS_QUARTERLY:
-                $sent_subfolder = $sent_subfolders_base
-                                . $delimiter . $year
-                                . $delimiter . $quarter;
-                $year_folder = $sent_subfolders_base
-                                . $delimiter . $year;
-                break;
-            case SMPREF_SENT_SUBFOLDERS_MONTHLY:
-                $sent_subfolder = $sent_subfolders_base
-                                . $delimiter . $year
-                                . $delimiter . $month;
-                $year_folder = $sent_subfolders_base
-                                . $delimiter . $year;
-                break;
-            case SMPREF_SENT_SUBFOLDERS_DISABLED:
-            default:
-                $sent_subfolder = $sent_folder;
-                $year_folder = $sent_folder;
+        case SMPREF_SENT_SUBFOLDERS_YEARLY:
+            $level = 1;
+            $sent_subfolder = $sent_subfolders_base
+                            . $year;
+            $year_folder = $sent_subfolder;
+            break;
+        case SMPREF_SENT_SUBFOLDERS_QUARTERLY:
+            $level = 2;
+            $sent_subfolder = $sent_subfolders_base
+                            . $year
+                            . $delimiter . $quarter;
+            $year_folder = $sent_subfolders_base
+                            . $delimiter . $year;
+            break;
+        case SMPREF_SENT_SUBFOLDERS_MONTHLY:
+            $level = 2;
+            $sent_subfolder = $sent_subfolders_base
+                            . $year
+                            . $delimiter . $month;
+            $year_folder = $sent_subfolders_base
+                            . $delimiter . $year;
+            break;
+        case SMPREF_SENT_SUBFOLDERS_DISABLED:
+        default:
+            $level = 0;
+            $sent_subfolder = $sent_folder;
+            $year_folder = $sent_folder;
         }
 
         /* If this folder is NOT the current sent folder, update stuff. */
         if ($sent_subfolder != $sent_folder) {
             /* First, update the sent folder. */
+
             setPref($data_dir, $username, 'sent_folder', $sent_subfolder);
             setPref($data_dir, $username, 'move_to_sent', SMPREF_ON);
             $sent_folder = $sent_subfolder;
@@ -196,7 +207,7 @@ function sent_subfolders_update_sentfolder() {
 
                 /* Auto-create the year folder, if it does not yet exist. */
                 if (!sqimap_mailbox_exists($ic, $year_folder)) {
-                    sqimap_mailbox_create($ic, $year_folder, '');
+                    sqimap_mailbox_create($ic, $year_folder, ($level==1)?'':'noselect');
                 } else if (!sqimap_mailbox_is_subscribed($ic, $year_folder)) {
                     sqimap_subscribe($ic, $year_folder);
                 }
@@ -204,8 +215,8 @@ function sent_subfolders_update_sentfolder() {
                 /* Auto-create the subfolder, if it does not yet exist. */
                 if (!sqimap_mailbox_exists($ic, $sent_folder)) {
                     sqimap_mailbox_create($ic, $sent_folder, '');
-                } else if (!sqimap_mailbox_is_subscribed($ic, $sent_folder)) {
-                    sqimap_subscribe($ic, $sent_folder);
+                } else if (!sqimap_mailbox_is_subscribed($ic, $sent_subfolder)) {
+                    sqimap_subscribe($ic, $sent_subfolder);
                 }
 
                 /* Close the imap connection. */

+ 75 - 87
src/folders.php

@@ -13,22 +13,6 @@
  * $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/imap.php');
 require_once('../functions/array.php');
@@ -49,11 +33,11 @@ displayPageHeader($color, 'None');
 
 <?php
 
-if ((isset($success) && $success) || 
-    (isset($sent_create) && $sent_create == "true") || 
-    (isset($trash_create) && $trash_create == "true")) {
-    echo "<table width=\"100%\" align=center cellpadding=4 cellspacing=0 border=0>\n";
-    echo "   <tr><td align=center>\n";
+if ((isset($success) && $success) ||
+    (isset($sent_create) && $sent_create == 'true') ||
+    (isset($trash_create) && $trash_create == 'true')) {
+    echo "<table width=\"100%\" align=center cellpadding=4 cellspacing=0 border=0>\n" .
+         "   <tr><td align=center>\n";
     if ($success == "subscribe") {
         echo "<b>" . _("Subscribed successfully!") . "</b><br>";
     } else if ($success == "unsubscribe") {
@@ -66,9 +50,9 @@ if ((isset($success) && $success) ||
         echo "<b>" . _("Renamed successfully!") . "</b><br>";
     }
 
-    echo "   <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>";
-    echo "   </td></tr>\n";
-    echo "</table><br>\n";
+    echo "   <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>".
+         "   </td></tr>\n";
+         "</table><br>\n";
 } else {
     echo "<br>";
 }
@@ -76,17 +60,16 @@ $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort,
 $boxes = sqimap_mailbox_list($imapConnection);
 
 /** CREATING FOLDERS **/
-echo "<TABLE WIDTH=\"70%\" COLS=1 ALIGN=CENTER cellpadding=4 cellspacing=0 border=0>\n";
-
-echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
-echo _("Create Folder");
-echo "</B></TD></TR>";
-echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
-echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
-echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
-echo _("as a subfolder of");
-echo "<BR>";
-echo "<TT><SELECT NAME=subfolder>\n";
+echo "<TABLE WIDTH=\"70%\" COLS=1 ALIGN=CENTER cellpadding=4 cellspacing=0 border=0>\n".
+     "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>".
+     _("Create Folder").
+     "</B></TD></TR>".
+     "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>".
+     "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n".
+     "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n".
+     _("as a subfolder of").
+     "<BR>".
+     "<TT><SELECT NAME=subfolder>\n";
 if ($default_sub_of_inbox == false) {
     echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
 } else {
@@ -95,16 +78,17 @@ if ($default_sub_of_inbox == false) {
 
 for ($i = 0; $i < count($boxes); $i++) {
     if (!in_array('noinferiors', $boxes[$i]['flags'])) {
-        if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
-            $box = $boxes[$i]["unformatted"];
-            $box2 = str_replace(' ', '&nbsp;', $boxes[$i]["unformatted-disp"]);
-            echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
+        if ((strtolower($boxes[$i]['unformatted']) == 'inbox') &&
+            $default_sub_of_inbox) {
+            $box = $boxes[$i]['unformatted'];
+            $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
+            echo "<OPTION SELECTED VALUE=\"$box\">$box2</option>\n";
         } else {
-            $box = $boxes[$i]["unformatted"];
-            $box2 = str_replace(' ', '&nbsp;', $boxes[$i]["unformatted-disp"]);
-            if (strtolower($imap_server_type) != "courier" ||
+            $box = $boxes[$i]['unformatted'];
+            $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
+            if (strtolower($imap_server_type) != 'courier' ||
                   strtolower($box) != "inbox.trash")
-                echo "<OPTION VALUE=\"$box\">$box2\n";
+                echo "<OPTION VALUE=\"$box\">$box2</option>\n";
         }
     }
 }
@@ -113,38 +97,40 @@ if ($show_contain_subfolders_option) {
     echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> &nbsp;";
     echo _("Let this folder contain subfolders");
     echo "<BR>";
-}   
+}
 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
 echo "</FORM></TD></TR>\n";
 
 echo "<tr><td bgcolor=\"$color[4]\">&nbsp;</td></tr>\n";
 
 /** RENAMING FOLDERS **/
-echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
-echo _("Rename a Folder");
-echo "</B></TD></TR>";
-echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
+echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>".
+     _("Rename a Folder").
+     "</B></TD></TR>".
+     "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
 if ($count_special_folders < count($boxes)) {
-    echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
-    echo "<TT><SELECT NAME=old>\n";
+    echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n".
+         "<TT><SELECT NAME=old>\n";
     for ($i = 0; $i < count($boxes); $i++) {
         $use_folder = true;
 
-        if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && 
-            ($boxes[$i]["unformatted"] != $trash_folder)  &&
-            ($boxes[$i]["unformatted"] != $sent_folder) &&
-            ($boxes[$i]["unformatted"] != $draft_folder)) {	
-	    $box = $boxes[$i]["unformatted-dm"];
-	    $box2 = str_replace(' ', '&nbsp;', $boxes[$i]["unformatted-disp"]);
-	    if (strtolower($imap_server_type) != "courier" || strtolower($box) != "inbox.trash")
-                echo "<OPTION VALUE=\"$box\">$box2\n";
+        if ((strtolower($boxes[$i]['unformatted']) != 'inbox') &&
+            ($boxes[$i]['unformatted'] != $trash_folder)  &&
+            ($boxes[$i]['unformatted'] != $sent_folder) &&
+            ($boxes[$i]['unformatted'] != $draft_folder)) {
+            $box = $boxes[$i]['unformatted-dm'];
+
+            $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
+            if (strtolower($imap_server_type) != 'courier' || strtolower($box) != 'inbox.trash') {
+                echo "<OPTION VALUE=\"$box\">$box2</option>\n";
+            }
         }
     }
-    echo "</SELECT></TT>\n";
-    echo "<INPUT TYPE=SUBMIT VALUE=\"";
-    echo _("Rename");
-    echo "\">\n";
-    echo "</FORM></TD></TR>\n";
+    echo "</SELECT></TT>\n".
+         "<INPUT TYPE=SUBMIT VALUE=\"".
+         _("Rename").
+         "\">\n".
+         "</FORM></TD></TR>\n";
 } else {
     echo _("No folders found") . "<br><br></td></tr>";
 }
@@ -159,25 +145,27 @@ echo "</B></TD></TR>";
 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
 
 $count_special_folders = 0;
-    $num_max = 1;
-    if (strtolower($imap_server_type) == "courier" || $move_to_trash)
-            $num_max++;
-    if ($move_to_sent)
-            $num_max++;
-    if ($save_as_draft)
-            $num_max++;
-
+$num_max = 1;
+if (strtolower($imap_server_type) == "courier" || $move_to_trash) {
+        $num_max++;
+}
+if ($move_to_sent) {
+        $num_max++;
+}
+if ($save_as_draft) {
+        $num_max++;
+}
 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++) {
-    if (strtolower($boxes[$p]["unformatted"]) == "inbox")
+    if (strtolower($boxes[$p]['unformatted']) == 'inbox')
         $count_special_folders++;
-    else if (strtolower($imap_server_type) == "courier" &&
-            strtolower($boxes[$p]["unformatted"]) == "inbox.trash")
+    else if (strtolower($imap_server_type) == 'courier' &&
+            strtolower($boxes[$p]['unformatted']) == 'inbox.trash')
         $count_special_folders++;
-    else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
+    else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
         $count_special_folders++;
-    else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
+    else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
         $count_special_folders++;
-    else if ($boxes[$p]["unformatted"] == $draft_folder && $draft_folder)
+    else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
         $count_special_folders++;
 }
 
@@ -186,15 +174,15 @@ if ($count_special_folders < count($boxes)) {
     echo "<TT><SELECT NAME=mailbox>\n";
     for ($i = 0; $i < count($boxes); $i++) {
         $use_folder = true;
-        if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
-            ($boxes[$i]["unformatted"] != $trash_folder) && 
-            ($boxes[$i]["unformatted"] != $sent_folder) &&
-            ($boxes[$i]["unformatted"] != $draft_folder) &&
-            ((strtolower($imap_server_type) != "courier") ||
-             (strtolower($boxes[$i]["unformatted"]) != "inbox.trash"))) {
-            $box = $boxes[$i]["unformatted-dm"];
-            $box2 = str_replace(' ', '&nbsp;', $boxes[$i]["unformatted-disp"]);
-            echo "         <OPTION VALUE=\"$box\">$box2\n";
+        if ((strtolower($boxes[$i]['unformatted']) != 'inbox') &&
+            ($boxes[$i]['unformatted'] != $trash_folder) &&
+            ($boxes[$i]['unformatted'] != $sent_folder) &&
+            ($boxes[$i]['unformatted'] != $draft_folder) &&
+            ((strtolower($imap_server_type) != 'courier') ||
+             (strtolower($boxes[$i]['unformatted']) != 'inbox.trash'))) {
+            $box = $boxes[$i]['unformatted-dm'];
+            $box2 = str_replace(' ', '&nbsp;', $boxes[$i]['unformatted-disp']);
+            echo "         <OPTION VALUE=\"$box\">$box2</option>\n";
         }
     }
     echo "</SELECT></TT>\n";
@@ -290,4 +278,4 @@ do_hook("folders_bottom");
    sqimap_logout($imapConnection);
 ?>
 
-</body></html>
+</body></html>

+ 34 - 49
src/folders_create.php

@@ -12,57 +12,42 @@
  * $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/imap.php');
 require_once('../functions/display_messages.php');
 
-   $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-   global $delimiter;
-
-   if (strpos($folder_name, "\"") || strpos($folder_name, "\\") ||
-       strpos($folder_name, "'") || strpos($folder_name, "$delimiter")) {
-      echo "<html><body bgcolor=$color[4]>";
-      plain_error_message(_("Illegal folder name.  Please select a different name.")."<BR><A HREF=\"../src/folders.php\">"._("Click here to go back")."</A>.", $color);
-      sqimap_logout($imapConnection);
-      exit;
-   }
-
-   if (isset($contain_subs) && $contain_subs == true)
-      $folder_name = "$folder_name$delimiter";
-
-   if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) {
-      $folder_prefix = $folder_prefix . $delimiter;
-   }
-   if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){
-      $subfolder_orig = $subfolder;
-      $subfolder = $folder_prefix . $subfolder;
-   } else {
-      $subfolder_orig = $subfolder;
-   }
-
-   if (trim($subfolder_orig) == '') {
-      sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, "");
-   } else {
-      sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, "");
-   }
-
-   $location = get_location();
-   header ("Location: $location/folders.php?success=create");
-   sqimap_logout($imapConnection);
+$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+global $delimiter;
+
+if (strpos($folder_name, "\"") || strpos($folder_name, "\\") ||
+    strpos($folder_name, "'") || strpos($folder_name, "$delimiter")) {
+    echo "<html><body bgcolor=$color[4]>";
+    plain_error_message(_("Illegal folder name.  Please select a different name.")."<BR><A HREF=\"../src/folders.php\">"._("Click here to go back")."</A>.", $color);
+    sqimap_logout($imapConnection);
+    exit;
+}
+
+if (isset($contain_subs) && $contain_subs ) {
+    $folder_name = "$folder_name$delimiter";
+}
+
+if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) {
+    $folder_prefix = $folder_prefix . $delimiter;
+}
+if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){
+    $subfolder_orig = $subfolder;
+    $subfolder = $folder_prefix . $subfolder;
+} else {
+    $subfolder_orig = $subfolder;
+}
+
+if (trim($subfolder_orig) == '') {
+    sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, '');
+} else {
+    sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, '');
+}
+
+$location = get_location();
+header ("Location: $location/folders.php?success=create");
+sqimap_logout($imapConnection);
 ?>

+ 74 - 89
src/folders_delete.php

@@ -12,108 +12,93 @@
  * $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/imap.php');
 require_once('../functions/array.php');
 require_once('../functions/tree.php');
 
-   /*
-   *  Incoming values:
-   *     $mailbox - selected mailbox from the form
-   */
-   
-   $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-   $boxes = sqimap_mailbox_list ($imap_stream);
-   global $delimiter;
-   
-   if (substr($mailbox, -1) == $delimiter)
-      $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1); 
-   else
-      $mailbox_no_dm = $mailbox;
-
-   /** lets see if we CAN move folders to the trash.. otherwise, 
+/*
+*  Incoming values:
+*     $mailbox - selected mailbox from the form
+*/
+
+$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+$boxes = sqimap_mailbox_list ($imap_stream);
+global $delimiter;
+
+if (substr($mailbox, -1) == $delimiter)
+    $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1);
+else
+    $mailbox_no_dm = $mailbox;
+
+/** lets see if we CAN move folders to the trash.. otherwise,
     ** just delete them **/
 
-   // Courier IMAP doesn't like subfolders of Trash
-   if (strtolower($imap_server_type) == "courier") {
-      $can_move_to_trash = false;
-   } 
+// Courier IMAP doesn't like subfolders of Trash
+if (strtolower($imap_server_type) == "courier") {
+    $can_move_to_trash = false;
+}
 
-   // If it's already a subfolder of trash, we'll have to delete it
-   else if(eregi("^".$trash_folder.".+", $mailbox)) {
+// If it's already a subfolder of trash, we'll have to delete it
+else if(eregi("^".$trash_folder.".+", $mailbox)) {
 
-      $can_move_to_trash = false;
+    $can_move_to_trash = false;
 
-   }
+}
 
-   // Otherwise, check if trash folder exits and support sub-folders
-   else {
-      for ($i = 0; $i < count($boxes); $i++) {
-         if ($boxes[$i]["unformatted"] == $trash_folder) {
+// Otherwise, check if trash folder exits and support sub-folders
+else {
+    for ($i = 0; $i < count($boxes); $i++) {
+        if ($boxes[$i]["unformatted"] == $trash_folder) {
             $can_move_to_trash = !in_array('noinferiors', $boxes[$i]['flags']);
-         }
-      }
-   }
-
-   /** First create the top node in the tree **/
-   for ($i = 0;$i < count($boxes);$i++) {
-      if (($boxes[$i]["unformatted-dm"] == $mailbox) && (strlen($boxes[$i]["unformatted-dm"]) == strlen($mailbox))) {
-         $foldersTree[0]["value"] = $mailbox;
-         $foldersTree[0]["doIHaveChildren"] = false;
-         continue;
-      }
-   }
-   // Now create the nodes for subfolders of the parent folder 
-   // You can tell that it is a subfolder by tacking the mailbox delimiter
-   //    on the end of the $mailbox string, and compare to that.
-   $j = 0;
-   for ($i = 0;$i < count($boxes);$i++) {
-      if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $delimiter)) == ($mailbox_no_dm . $delimiter)) {
-         addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
-      }
-   }
+        }
+    }
+}
+
+/** First create the top node in the tree **/
+for ($i = 0;$i < count($boxes);$i++) {
+    if (($boxes[$i]["unformatted-dm"] == $mailbox) && (strlen($boxes[$i]["unformatted-dm"]) == strlen($mailbox))) {
+        $foldersTree[0]["value"] = $mailbox;
+        $foldersTree[0]["doIHaveChildren"] = false;
+        continue;
+    }
+}
+// Now create the nodes for subfolders of the parent folder
+// You can tell that it is a subfolder by tacking the mailbox delimiter
+//    on the end of the $mailbox string, and compare to that.
+$j = 0;
+for ($i = 0;$i < count($boxes);$i++) {
+    if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $delimiter)) == ($mailbox_no_dm . $delimiter)) {
+        addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
+    }
+}
 //   simpleWalkTreePre(0, $foldersTree);
 
-   /** Lets start removing the folders and messages **/
-   if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/
-      walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $mailbox);
-      walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
-   } else { /** if they do NOT wish to move messages to the trash (or cannot)**/
-      walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
-   }
-
-   /** Log out this session **/
-   sqimap_logout($imap_stream);
-
-   $location = get_location();
-   header ("Location: $location/folders.php?success=delete");
-   /*
-   echo "<BR><BR><BR><CENTER><B>";
-   echo _("Folder Deleted!");
-   echo "</B><BR><BR>";
-   echo _("The folder has been successfully deleted.");
-   echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
-   echo _("Click here");
-   echo "</A> ";
-   echo _("to continue.");
-   echo "</CENTER>"; 
-   
-   echo "</BODY></HTML>";
-   */
+/** Lets start removing the folders and messages **/
+if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/
+    walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $mailbox);
+    walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
+} else { /** if they do NOT wish to move messages to the trash (or cannot)**/
+    walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
+}
+
+/** Log out this session **/
+sqimap_logout($imap_stream);
+
+$location = get_location();
+header ("Location: $location/folders.php?success=delete");
+/*
+echo "<BR><BR><BR><CENTER><B>";
+echo _("Folder Deleted!");
+echo "</B><BR><BR>";
+echo _("The folder has been successfully deleted.");
+echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
+echo _("Click here");
+echo "</A> ";
+echo _("to continue.");
+echo "</CENTER>";
+
+echo "</BODY></HTML>";
+*/
 ?>

+ 25 - 63
src/folders_rename_do.php

@@ -6,82 +6,44 @@
  * Copyright (c) 1999-2002 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
- * Does the actual renaming of files on the IMAP server. 
+ * Does the actual renaming of files on the IMAP server.
  * Called from the folders.php
  *
  * $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. ***/
-/*****************************************************************/
+global $delimiter, $base_uri;
 
 require_once('../src/validate.php');
 require_once('../functions/imap.php');
 
-   if($old_name == $new_name) {
-      $location = get_location();
-      header ("Location: $location/folders.php");
-      exit;
-   }
+if ($old_name <> $new_name) {
 
-   $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-   global $delimiter;
+    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
 
-   if (strpos($orig, $delimiter))
-      $old_dir = substr($orig, 0, strrpos($orig, $delimiter));
-   else
-      $old_dir = "";
+    if (strpos($orig, $delimiter)) {
+        $old_dir = substr($orig, 0, strrpos($orig, $delimiter));
+    } else {
+        $old_dir = '';
+    }
 
-   if ($old_dir != "")
-      $newone = "$old_dir$delimiter$new_name";
-   else
-      $newone = "$new_name";
+    if ($old_dir != '') {
+        $newone = $old_dir . $delimiter . $new_name;
+    } else {
+        $newone = $new_name;
+    }
 
-   $cmd = sqimap_session_id() . " RENAME \"" . quoteIMAP($orig) . "\" \"" .
-      quoteIMAP($newone) . "\"\r\n";
-   fputs ($imapConnection, $cmd);
-   $data = sqimap_read_data($imapConnection, sqimap_session_id(), true, $a, $b);
+    // Renaming a folder doesn't renames the folder but leaves you unsubscribed
+    //    at least on Cyrus IMAP servers.
+    if (isset($isfolder)) {
+        $newone = $newone.$delimiter;
+        $orig = $orig.$delimiter;
+    }
+    sqimap_mailbox_rename( $imapConnection, $orig, $newone );
 
-   // Renaming a folder doesn't renames the folder but leaves you unsubscribed
-   //    at least on Cyrus IMAP servers.
-   if (isset($isfolder)) {
-      $newone = $newone.$delimiter;
-      $orig = $orig.$delimiter;
-   }   
-   sqimap_unsubscribe($imapConnection, $orig);
-   sqimap_subscribe($imapConnection, $newone);
+    // Log out this session 
+    sqimap_logout($imapConnection);
 
-   fputs ($imapConnection, sqimap_session_id() . " LIST \"\" \"" . quoteIMAP($newone) .
-      "*\"\r\n");
-   $data = sqimap_read_data($imapConnection, sqimap_session_id(), true, $a, $b);
-   for ($i=0; $i < count($data); $i++)
-   {
-      $name = find_mailbox_name($data[$i]);
-
-      if ($name != $newone) // don't try to resubscribe when renaming ab to abc
-      {
-        sqimap_unsubscribe($imapConnection, $name);
-        $name = substr($name, strlen($orig));
-        $name = $newone . $name;
-        sqimap_subscribe($imapConnection, $name);
-      }
-   }
-
-   /** Log out this session **/
-   sqimap_logout($imapConnection);
-   $location = get_location();
-   header ("Location: $location/folders.php?success=rename");
+}
+header ('Location: ' . $base_uri . 'src/folders.php');
 ?>

+ 38 - 48
src/folders_rename_getname.php

@@ -12,58 +12,48 @@
  * $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. ***/
-/*****************************************************************/
+global $delimiter;
 
 require_once('../src/validate.php');
 require_once('../functions/imap.php');
 
-   $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
 
-   global $delimiter;
-   if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) {
-      $isfolder = true;
-      $old = substr($old, 0, strlen($old) - 1);
-   }
-   
-   if (strpos($old, $delimiter)) {
-      $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old));
-      $old_parent = substr($old, 0, strrpos($old, $delimiter));
-   } else {
-      $old_name = $old;
-      $old_parent = "";
-   }
+echo $old;
 
-   displayPageHeader($color, 'None');
-   echo "<br><TABLE align=center border=0 WIDTH=\"95%\" COLS=1>";
-   echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
-   echo _("Rename a folder");
-   echo "</B></TD></TR>";
-   echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
-   echo "<FORM ACTION=\"folders_rename_do.php\" METHOD=\"POST\">\n";
-   echo _("New name:");
-   echo "<br><B>$old_parent . </B><INPUT TYPE=TEXT SIZE=25 NAME=new_name VALUE=\"$old_name\"><BR>\n";
-   if (isset($isfolder))
-      echo "<INPUT TYPE=HIDDEN NAME=isfolder VALUE=\"true\">";
-   printf("<INPUT TYPE=HIDDEN NAME=orig VALUE=\"%s\">\n", $old);
-   printf("<INPUT TYPE=HIDDEN NAME=old_name VALUE=\"%s\">\n", $old_name);
-   echo "<INPUT TYPE=SUBMIT VALUE=\""._("Submit")."\">\n";
-   echo "</FORM><BR></TD></TR>";
-   echo "</TABLE>";
+if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) {
+    $isfolder = TRUE;
+    $old = substr($old, 0, strlen($old) - 1);
+} else {
+    $isfolder = FALSE;
+}
 
-   /** Log out this session **/
-   sqimap_logout($imapConnection);
-?>
+if (strpos($old, $delimiter)) {
+    $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old));
+    $old_parent = substr($old, 0, strrpos($old, $delimiter));
+} else {
+    $old_name = $old;
+    $old_parent = '';
+}
+
+displayPageHeader($color, 'None');
+echo "<br><TABLE align=center border=0 WIDTH=\"95%\" COLS=1>".
+     "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>".
+     _("Rename a folder").
+     "</B></TD></TR>".
+     "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
+     "<FORM ACTION=\"folders_rename_do.php\" METHOD=\"POST\">\n".
+     _("New name:").
+     "<br><B>$old_parent $delimiter </B><INPUT TYPE=TEXT SIZE=25 NAME=new_name VALUE=\"$old_name\"><BR>\n";
+if ( $isfolder ) {
+    echo "<INPUT TYPE=HIDDEN NAME=isfolder VALUE=\"true\">";
+}
+printf("<INPUT TYPE=HIDDEN NAME=orig VALUE=\"%s\">\n", $old);
+printf("<INPUT TYPE=HIDDEN NAME=old_name VALUE=\"%s\">\n", $old_name);
+echo "<INPUT TYPE=SUBMIT VALUE=\""._("Submit")."\">\n".
+     "</FORM><BR></TD></TR>".
+     "</TABLE>";
+
+/** Log out this session **/
+sqimap_logout($imapConnection);
+?>

+ 39 - 43
src/left_main.php

@@ -10,23 +10,7 @@
  * 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');
@@ -40,7 +24,25 @@ define('SM_BOX_COLLAPSED',   1);
 
 /* --------------------- FUNCTIONS ------------------------- */
 
+function isSpecialMailbox( $box ) {
+
+    global $trash_folder, $sent_folder, $draft_folder,
+           $move_to_trash, $move_to_sent, $save_as_draft;
+
+    $ret = ( (strtolower($box) == 'inbox') ||
+             (($box == $trash_folder) &&
+              ($move_to_trash)) ||
+             ((substr( $sent_folder, 0, strlen( $box ) ) == $box) &&
+              ($move_to_sent)) ||
+             (($box == $draft_folder) &&
+              ($save_as_draft)) );
+
+    return( $ret );
+
+}
+
 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;
@@ -71,15 +73,7 @@ function formatMailboxName($imapConnection, $box_array) {
         }
     }
 
-    $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,8 +83,9 @@ 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)
         $line .= "</FONT>";
@@ -104,7 +99,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);
         }
@@ -134,7 +129,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 +141,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);
@@ -317,7 +309,7 @@ while ($curbox < $boxcount) {
     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,11 +325,15 @@ for ($i = 0;$i < count($boxes); $i++) {
         $line = "<NOBR><TT>$prefix</TT>";
 
         /* Add the folder name and link. */
-	if (! isset($color[15])) {
+        if (! isset($color[15])) {
             $color[15] = $color[6];
-	}
+        }
         if (in_array('noselect', $boxes[$i]['flags'])) {
-            $line .= "<FONT COLOR=\"$color[15]\">";
+            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);
@@ -360,4 +356,4 @@ do_hook('left_main_after');
 
 echo "</BODY></HTML>\n";
 
-?>
+?>