In order to make sent_subfolders work I had to change a lot of code.
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 11 Jan 2002 23:28:12 +0000 (23:28 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 11 Jan 2002 23:28:12 +0000 (23:28 +0000)
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.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2119 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_mailbox.php
functions/page_header.php
plugins/sent_subfolders/setup.php
src/folders.php
src/folders_create.php
src/folders_delete.php
src/folders_rename_do.php
src/folders_rename_getname.php
src/left_main.php

index a46ccaed379254587fa9802af58deedc6f52aa1f..0a5e9b8ae99945beac08cfadc932e7aded36c07d 100755 (executable)
@@ -137,7 +137,49 @@ function sqimap_mailbox_is_subscribed($imap_stream, $folder)
     return false;
 }
 
     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
 
 /******************************************************************************
  **  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] . '"' . 
                  $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];
         }
         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);
             /* 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)) {
             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);
             }
             
             $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) {
             $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();
             }
             else {
                 $boxes[$g]['flags'] = array();
@@ -553,7 +595,7 @@ function sqimap_mailbox_list_all ($imap_stream)
         $g++;
     }
     if(is_array($boxes)) {
         $g++;
     }
     if(is_array($boxes)) {
-        $boxes = ary_sort ($boxes, "unformatted", 1);
+        $boxes = ary_sort ($boxes, 'unformatted', 1);
     }
     
     return $boxes;
     }
     
     return $boxes;
index 60c8ec7ab044960cf26798be4266211ec486b569..ef84f2d20d279e4f7a457a0ed22bfdf85f81f24c 100644 (file)
@@ -81,7 +81,6 @@ function checkForm() {
         i++;
     }
     if( pos >= 0 ) {
         i++;
     }
     if( pos >= 0 ) {
-        // document.write( "Si tio" );
         document.forms[i-1].elements[pos].focus();
     }
     
         document.forms[i-1].elements[pos].focus();
     }
     
index 92f665323ad98f94ceea7abcc33cf42ff7b4a89f..2887047775fbd0f063db85c3bb97d9f9a274162b 100644 (file)
@@ -149,40 +149,51 @@ function sent_subfolders_update_sentfolder() {
     global $username, $data_dir, $key, $imapServerAddress, $imapPort;
     global $use_sent_subfolders, $move_to_sent;
 
     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);
 
         $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) {
         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. */
         }
 
         /* 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;
             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)) {
 
                 /* 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);
                 }
                 } 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, '');
                 /* 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. */
                 }
 
                 /* Close the imap connection. */
index eb7d634d7daba771b659e4bc4aa0f0d0b252e223..9adb36b01e699da019795562a6577bd75883304d 100644 (file)
  * $Id$
  */
 
  * $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('../src/validate.php');
 require_once('../functions/imap.php');
 require_once('../functions/array.php');
@@ -49,11 +33,11 @@ displayPageHeader($color, 'None');
 
 <?php
 
 
 <?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") {
     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 "<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>";
 }
 } else {
     echo "<br>";
 }
@@ -76,17 +60,16 @@ $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort,
 $boxes = sqimap_mailbox_list($imapConnection);
 
 /** CREATING FOLDERS **/
 $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 {
 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'])) {
 
 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 {
         } 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")
                   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 "<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 "<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)) {
 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;
 
     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>";
 }
 } 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;
 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++) {
 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++;
         $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++;
         $count_special_folders++;
-    else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder)
+    else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
         $count_special_folders++;
         $count_special_folders++;
-    else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder)
+    else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
         $count_special_folders++;
         $count_special_folders++;
-    else if ($boxes[$p]["unformatted"] == $draft_folder && $draft_folder)
+    else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
         $count_special_folders++;
 }
 
         $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;
     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";
         }
     }
     echo "</SELECT></TT>\n";
@@ -290,4 +278,4 @@ do_hook("folders_bottom");
    sqimap_logout($imapConnection);
 ?>
 
    sqimap_logout($imapConnection);
 ?>
 
-</body></html>
+</body></html>
\ No newline at end of file
index 43beb9edcdf70d9a8c96cb503a137764a86fd208..c0b4de483411228e68e160e29a60b9f541e3f72a 100644 (file)
  * $Id$
  */
 
  * $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');
 
 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);
 ?>
 ?>
index de432553373a73e1914b4db07ae13428a005feb2..4ae96f809e27711ac90dd66de11f27c6590981e7 100644 (file)
  * $Id$
  */
 
  * $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');
 
 
 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 **/
 
     ** 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']);
             $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);
 
 //   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>";
+*/
 ?>
 ?>
index 9d69ba99c6d1ccbbca273730ab4fc86a436e765b..8e03d83b3c6bfea00df2a1fc6f817c63421e7dd3 100644 (file)
@@ -6,82 +6,44 @@
  * Copyright (c) 1999-2002 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * 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$
  */
 
  * 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');
 
 
 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');
 ?>
 ?>
index c5a85c99e71a941bcb3790c835e17b6db85efe98..7896fa5bf6fabdcfe8b57a686119239ef01ec64e 100644 (file)
  * $Id$
  */
 
  * $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');
 
 
 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);
+?>
\ No newline at end of file
index 427d6fc40d2857064fc126c07e22a9687b234999..eb4b537984836e89056f1ab329f0cb8de0e0556d 100644 (file)
  * available, and has cookie information.
  *
  * $Id$
  * 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');
 
 require_once('../src/validate.php');
 require_once('../functions/array.php');
@@ -40,7 +24,25 @@ define('SM_BOX_COLLAPSED',   1);
 
 /* --------------------- FUNCTIONS ------------------------- */
 
 
 /* --------------------- 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) {
 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 $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 = '';
 
     /* 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\">";
 
     /* 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 .= "<FONT COLOR=\"$color[11]\">";
+    }
     $line .= str_replace(' ','&nbsp;',$mailbox);
     if ($special_color == true)
         $line .= "</FONT>";
     $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>";
     }
 
         $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);
         }
         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. */
     $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 ) {
 
     /* 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. */
     $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'];
         $nextbox_name = $boxes[$nextbox]['unformatted'];
-    else
+    } else {
         $nextbox_name = '';
         $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. */
 
     /* 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. */
 
         /* 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);
 
         /* Compute the visibility of any child boxes. */
         compute_folder_children($nextbox, $boxcount);
@@ -317,7 +309,7 @@ while ($curbox < $boxcount) {
     compute_folder_children($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;
     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. */
         $line = "<NOBR><TT>$prefix</TT>";
 
         /* Add the folder name and link. */
-       if (! isset($color[15])) {
+        if (! isset($color[15])) {
             $color[15] = $color[6];
             $color[15] = $color[6];
-       }
+        }
         if (in_array('noselect', $boxes[$i]['flags'])) {
         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);
             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";
 
 
 echo "</BODY></HTML>\n";
 
-?>
+?>
\ No newline at end of file