Added BASIC mime support.
[squirrelmail.git] / src / folders.php
index 7b7ec043a66d59175e1a7d9f9e476b01b75ac8bd..5dea2602666118819bb1c256dee906d101dd0087 100644 (file)
    echo "</TABLE>\n";
 
    $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
-
-   fputs($imapConnection, "1 list \"\" *\n");
-   $str = imapReadData($imapConnection);
-
-   for ($i = 0;$i < count($str); $i++) {
-      $mailbox = Chop($str[$i]);
-      // find the quote at the begining of the mailbox name.
-      //    i subtract 1 from the strlen so it doesn't find the quote at the end of the mailbox name.
-      $mailbox = findMailboxName($mailbox);
-      $periodCount = countCharInString($mailbox, ".");
-
-      // indent the correct number of spaces.
-      for ($j = 0;$j < $periodCount;$j++)
-         $boxes[$i] = "$boxes[$i]&nbsp;&nbsp;&nbsp;";
-
-      $boxes[$i] = $boxes[$i] . readShortMailboxName($mailbox, ".");
-      $long_name_boxes[$i] = $mailbox;
-   }
+   getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted);
 
    /** DELETING FOLDERS **/
-
-   echo "<FORM ACTION=folders_delete.php METHOD=POST>\n";
+   echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
+   echo "<TR><TD BGCOLOR=DCDCDC ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Delete Folder</B></FONT></TD></TR>";
+   echo "<TR><TD BGCOLOR=FFFFFF ALIGN=CENTER>";
+   echo "<FORM ACTION=folders_delete.php METHOD=SUBMIT>\n";
    echo "<SELECT NAME=mailbox><FONT FACE=\"Arial,Helvetica\">\n";
-   for ($i = 0; $i < count($str); $i++) {
-      $thisbox = Chop($str[$i]);
-      $thisbox = findMailboxName($thisbox);
+   for ($i = 0; $i < count($boxesUnformatted); $i++) {
       $use_folder = true;
       for ($p = 0; $p < count($special_folders); $p++) {
-         if ($special_folders[$p] == $long_name_boxes[$i])
+         if ($boxesUnformatted[$i] == $special_folders[$p]) {
+            $use_folder = false;
+         } else if (substr($boxesUnformatted[$i], 0, strlen($trash_folder)) == $trash_folder) {
             $use_folder = false;
+         }
       }
+
       if ($use_folder == true)
-         echo "   <OPTION>$thisbox\n";
+         echo "<OPTION>$boxesUnformatted[$i]\n";
    }
    echo "</SELECT>\n";
    echo "<INPUT TYPE=SUBMIT VALUE=Delete>\n";
-   echo "</FORM><BR>\n";
+   echo "</FORM><BR></TD></TR><BR>\n";
 
    /** CREATING FOLDERS **/
+   echo "<TR><TD BGCOLOR=DCDCDC ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Create Folder</B></FONT></TD></TR>";
+   echo "<TR><TD BGCOLOR=FFFFFF ALIGN=CENTER>";
    echo "<FORM ACTION=folders_create.php METHOD=POST>\n";
-   echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name>\n";
-   echo "&nbsp;&nbsp;as a subfolder of&nbsp;&nbsp;";
+   echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
+   echo "&nbsp;&nbsp;as a subfolder of<BR>";
    echo "<SELECT NAME=subfolder><FONT FACE=\"Arial,Helvetica\">\n";
-   for ($i = 0;$i < count($str); $i++) {
-      $thisbox = Chop($str[$i]);
-      $thisbox = findMailboxName($thisbox);
-      $thisbox = getFolderNameMinusINBOX($thisbox);
-      echo "<OPTION>$thisbox\n";
+   for ($i = 0;$i < count($boxesUnformatted); $i++) {
+      echo "<OPTION>$boxesUnformatted[$i]\n";
    }
-   echo "</SELECT>\n";
+   echo "</SELECT><BR>\n";
    echo "<INPUT TYPE=SUBMIT VALUE=Create>\n";
-   echo "</FORM><BR>\n";
+   echo "</FORM><BR></TD></TR><BR>\n";
 
    /** RENAMING FOLDERS **/
-   echo "<FORM ACTION=folders_rename.php METHOD=POST>\n";
-   echo "<SELECT NAME=folder_list><FONT FACE=\"Arial,Helvetica\">\n";
-   for ($i = 0; $i < count($str); $i++) {
+   echo "<TR><TD BGCOLOR=DCDCDC ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Rename or Move Folder</B></FONT></TD></TR>";
+   echo "<TR><TD BGCOLOR=FFFFFF ALIGN=CENTER>";
+   echo "<FORM ACTION=folders_rename_getname.php METHOD=POST>\n";
+   echo "<SELECT NAME=old><FONT FACE=\"Arial,Helvetica\">\n";
+   for ($i = 0; $i < count($boxesUnformatted); $i++) {
       $use_folder = true;
       for ($p = 0; $p < count($special_folders); $p++) {
-         if ($special_folders[$p] == $long_name_boxes[$i])
+         if ($boxesUnformatted[$i] == $special_folders[$p]) {
             $use_folder = false;
+         }
       }
       if ($use_folder == true)
-         echo "   <OPTION>$boxes[$i]\n";
+         echo "   <OPTION>$boxesUnformatted[$i]\n";
    }
    echo "</SELECT>\n";
-   echo "<INPUT TYPE=TEXT SIZE=25 NAME=new_folder_name>\n";
-   echo "<INPUT TYPE=SUBMIT VALUE=Rename>\n";
-   echo "</FORM><BR>\n";
+   echo "<INPUT TYPE=SUBMIT VALUE=\"Rename or Move\">\n";
+   echo "</FORM></TD></TR></TABLE><BR>\n";
 
 ?>
 </BODY></HTML>