Fixed some bugs in folder deleting
[squirrelmail.git] / src / folders.php
1 <?
2 if (!isset($config_php))
3 include("../config/config.php");
4 if (!isset($strings_php))
5 include("../functions/strings.php");
6 if (!isset($page_header_php))
7 include("../functions/page_header.php");
8 if (!isset($imap_php))
9 include("../functions/imap.php");
10 if (!isset($array_php))
11 include("../functions/array.php");
12
13 include("../src/load_prefs.php");
14
15 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
16
17 displayPageHeader($color, "None");
18
19 echo "<TABLE WIDTH=100% COLS=1 ALIGN=CENTER>\n";
20 echo " <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>\n";
21 echo " <FONT FACE=\"Arial,Helvetica\">";
22 echo _("Folders");
23 echo "</FONT>\n";
24 echo " </TD></TR>\n";
25 echo "</TABLE>\n";
26
27 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, 0);
28 $boxes = sqimap_mailbox_list($imapConnection);
29
30 /** DELETING FOLDERS **/
31 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
32 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>";
33 echo _("Delete Folder");
34 echo "</B></FONT></TD></TR>";
35 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
36 echo "<FORM ACTION=folders_delete.php METHOD=SUBMIT>\n";
37 echo "<TT><SELECT NAME=mailbox>\n";
38 for ($i = 0; $i < count($boxes); $i++) {
39 $use_folder = true;
40 for ($p = 0; $p < count($special_folders); $p++) {
41 if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
42 $use_folder = false;
43 } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
44 $use_folder = false;
45 }
46 }
47 if ($use_folder == true) {
48 $box = $boxes[$i]["unformatted-dm"];
49 $box2 = replace_spaces($boxes[$i]["formatted"]);
50 echo " <OPTION VALUE=\"$box\">$box2\n";
51 }
52 }
53
54 echo "</SELECT></TT>\n";
55 echo "<FONT FACE=\"Arial,Helvetica\"><INPUT TYPE=SUBMIT VALUE=\"";
56 echo _("Delete");
57 echo "\"></FONT>\n";
58 echo "</FORM><BR></TD></TR><BR>\n";
59
60 /** CREATING FOLDERS **/
61 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>";
62 echo _("Create Folder");
63 echo "</B></FONT></TD></TR>";
64 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
65 echo "<FORM ACTION=folders_create.php METHOD=POST>\n";
66 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
67 echo "<FONT FACE=\"Arial,Helvetica\">";
68 echo _("as a subfolder of");
69 echo "</FONT><BR>";
70 echo "<TT><SELECT NAME=subfolder><FONT FACE=\"Arial,Helvetica\">\n";
71 if ($default_sub_of_inbox == false)
72 echo "<OPTION SELECTED>[ None ]\n";
73 else
74 echo "<OPTION>[ None ]\n";
75
76 for ($i = 0; $i < count($boxes); $i++) {
77 for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
78 if ($boxes[$i]["flags"][$j] != "noinferiors") {
79 if (($boxes[$i]["unformatted"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
80 $box = $boxes[$i]["unformatted"];
81 $box2 = replace_spaces($boxes[$i]["formatted"]);
82 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
83 } else {
84 $box = $boxes[$i]["unformatted"];
85 $box2 = replace_spaces($boxes[$i]["formatted"]);
86 echo "<OPTION VALUE=\"$box\">$box2\n";
87 }
88 }
89 }
90 }
91 echo "</SELECT></TT><BR>\n";
92 echo "<FONT FACE=\"Arial,Helvetica\">";
93 if ($show_contain_subfolders_option) {
94 echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"><FONT FACE=\"Arial,Helvetica\"> &nbsp;";
95 echo _("Let this folder contain subfolders");
96 echo "</FONT><BR>";
97 }
98 echo "<INPUT TYPE=SUBMIT VALUE=Create></FONT>\n";
99 echo "</FORM><BR></TD></TR><BR>\n";
100
101 /** RENAMING FOLDERS **/
102 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>";
103 echo _("Rename a Folder");
104 echo "</B></FONT></TD></TR>";
105 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
106 echo "<FORM ACTION=folders_rename_getname.php METHOD=POST>\n";
107 echo "<TT><SELECT NAME=old><FONT FACE=\"Arial,Helvetica\">\n";
108 for ($i = 0; $i < count($boxes); $i++) {
109 $use_folder = true;
110 for ($p = 0; $p < count($special_folders); $p++) {
111 if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
112 $use_folder = false;
113 } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
114 $use_folder = false;
115 }
116 }
117 if ($use_folder == true) {
118 $box = $boxes[$i]["unformatted"];
119 $box2 = replace_spaces($boxes[$i]["formatted"]);
120 echo " <OPTION VALUE=\"$box\">$box2\n";
121 }
122 }
123 echo "</SELECT></TT>\n";
124 echo "<FONT FACE=\"Arial,Helvetica\"><INPUT TYPE=SUBMIT VALUE=\"";
125 echo _("Rename");
126 echo "\"></FONT>\n";
127 echo "</FORM></TD></TR></TABLE><BR>\n";
128
129 ?>
130 </BODY></HTML>