fixed renaming problems
[squirrelmail.git] / src / folders.php
index 1887b9db537d4354f954fa3f4e312e27f57c19c2..12da0c38d5eb9cec6c8e105c00ecaa919479ffa0 100644 (file)
    echo _("Delete Folder");
    echo "</B></TD></TR>";
    echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
-   echo "<FORM ACTION=folders_delete.php METHOD=SUBMIT>\n";
-   echo "<TT><SELECT NAME=mailbox>\n";
-   for ($i = 0; $i < count($boxes); $i++) {
-      $use_folder = true;
+   $count_special_folders = 0;
+   for ($i = 0; $i < count($special_folders); $i++) {
       for ($p = 0; $p < count($special_folders); $p++) {
          if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
-            $use_folder = false;
-         } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
-            $use_folder = false;
+            $count_special_folders++;
+         }
+      }   
+   }
+
+   if ($count_special_folders < count($boxes)) {
+      echo "<FORM ACTION=folders_delete.php METHOD=SUBMIT>\n";
+      echo "<TT><SELECT NAME=mailbox>\n";
+      for ($i = 0; $i < count($boxes); $i++) {
+         $use_folder = true;
+         for ($p = 0; $p < count($special_folders); $p++) {
+            if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
+               $use_folder = false;
+            } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
+               $use_folder = false;
+            }
+         }
+         if ($use_folder == true) {
+            $box = $boxes[$i]["unformatted-dm"];
+            $box2 = replace_spaces($boxes[$i]["formatted"]);
+            echo "         <OPTION VALUE=\"$box\">$box2\n";
          }
       }
-      if ($use_folder == true) {
-         $box = $boxes[$i]["unformatted-dm"];
-         $box2 = replace_spaces($boxes[$i]["formatted"]);
-         echo "         <OPTION VALUE=\"$box\">$box2\n";
-      }
+      echo "</SELECT></TT>\n";
+      echo "<INPUT TYPE=SUBMIT VALUE=\"";
+      echo _("Delete");
+      echo "\">\n";
+      echo "</FORM><BR></TD></TR>\n";
+   } else {
+      echo _("No mailboxes found") . "<br><br></td><tr>";
    }
 
-   echo "</SELECT></TT>\n";
-   echo "<INPUT TYPE=SUBMIT VALUE=\"";
-   echo _("Delete");
-   echo "\">\n";
-   echo "</FORM><BR></TD></TR><BR>\n";
 
    /** CREATING FOLDERS **/
    echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
       echo "<OPTION>[ None ]\n";
 
    for ($i = 0; $i < count($boxes); $i++) {
-//      for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
-//         if ($boxes[$i]["flags"][$j] != "noinferiors") {
-            if (($boxes[$i]["unformatted"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
-               $box = $boxes[$i]["unformatted"];
-               $box2 = replace_spaces($boxes[$i]["formatted"]);
-               echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
-            } else {
-               $box = $boxes[$i]["unformatted"];
-               $box2 = replace_spaces($boxes[$i]["formatted"]);
-               echo "<OPTION VALUE=\"$box\">$box2\n";
-            }
-//         }   
-//      }
+      if (count($boxes[$i]["flags"]) > 0) {
+         for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
+            if ($boxes[$i]["flags"][$j] != "noinferiors") {
+               if (($boxes[$i]["unformatted"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
+                  $box = $boxes[$i]["unformatted"];
+                  $box2 = replace_spaces($boxes[$i]["formatted"]);
+                  echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
+               } else {
+                  $box = $boxes[$i]["unformatted"];
+                  $box2 = replace_spaces($boxes[$i]["formatted"]);
+                  echo "<OPTION VALUE=\"$box\">$box2\n";
+               }
+            }   
+         }    
+      } else {
+         if (($boxes[$i]["unformatted"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
+            $box = $boxes[$i]["unformatted"];
+            $box2 = replace_spaces($boxes[$i]["formatted"]);
+            echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
+         } else {
+            $box = $boxes[$i]["unformatted"];
+            $box2 = replace_spaces($boxes[$i]["formatted"]);
+            echo "<OPTION VALUE=\"$box\">$box2\n";
+         }
+      }
    }
    echo "</SELECT></TT><BR>\n";
    if ($show_contain_subfolders_option) {
    echo _("Rename a Folder");
    echo "</B></TD></TR>";
    echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
-   echo "<FORM ACTION=folders_rename_getname.php METHOD=POST>\n";
-   echo "<TT><SELECT NAME=old>\n";
-   for ($i = 0; $i < count($boxes); $i++) {
-      $use_folder = true;
-      for ($p = 0; $p < count($special_folders); $p++) {
-         if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
-            $use_folder = false;
-         } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
-            $use_folder = false;
+   if ($count_special_folders < count($boxes)) {
+      echo "<FORM ACTION=folders_rename_getname.php METHOD=POST>\n";
+      echo "<TT><SELECT NAME=old>\n";
+      for ($i = 0; $i < count($boxes); $i++) {
+         $use_folder = true;
+         for ($p = 0; $p < count($special_folders); $p++) {
+            if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
+               $use_folder = false;
+            } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
+               $use_folder = false;
+            }
+         }
+         if ($use_folder == true) {
+            $box = $boxes[$i]["unformatted-dm"];
+            $box2 = replace_spaces($boxes[$i]["formatted"]);
+            echo "         <OPTION VALUE=\"$box\">$box2\n";
          }
       }
-      if ($use_folder == true) {
-         $box = $boxes[$i]["unformatted"];
-         $box2 = replace_spaces($boxes[$i]["formatted"]);
-         echo "         <OPTION VALUE=\"$box\">$box2\n";
-      }
+      echo "</SELECT></TT>\n";
+      echo "<INPUT TYPE=SUBMIT VALUE=\"";
+      echo _("Rename");
+      echo "\">\n";
+      echo "</FORM></TD></TR></TABLE><BR>\n";
+   } else {
+      echo _("No mailboxes found") . "<br><br></td></tr></table>";
    }
-   echo "</SELECT></TT>\n";
-   echo "<INPUT TYPE=SUBMIT VALUE=\"";
-   echo _("Rename");
-   echo "\">\n";
-   echo "</FORM></TD></TR></TABLE><BR>\n";
 
 ?>
 </BODY></HTML>