added html addr book search file
[squirrelmail.git] / src / folders.php
CommitLineData
59177427 1<?php
2a32fc83 2 session_start();
3
d068c0ec 4 if (!isset($config_php))
5 include("../config/config.php");
6 if (!isset($strings_php))
7 include("../functions/strings.php");
8 if (!isset($page_header_php))
9 include("../functions/page_header.php");
10 if (!isset($imap_php))
11 include("../functions/imap.php");
12 if (!isset($array_php))
13 include("../functions/array.php");
aa42fbfb 14
d3cdb279 15 include("../src/load_prefs.php");
16
f8f9bed9 17 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
18
19 displayPageHeader($color, "None");
aa42fbfb 20
21 echo "<TABLE WIDTH=100% COLS=1 ALIGN=CENTER>\n";
f8f9bed9 22 echo " <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>\n";
036a8a9d 23 echo _("Folders");
aa42fbfb 24 echo " </TD></TR>\n";
25 echo "</TABLE>\n";
26
e1469126 27 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
813eba2f 28 $boxes = sqimap_mailbox_list($imapConnection);
60573cd9 29
d7e3602c 30 /** Cyrus Folder Options**/
31//Creates the Sent and Trash folder
90790bd4 32 if (($sent_create == "true") || ($trash_create == "true")) {
33 if ($sent_create == "true") {
34 sqimap_mailbox_create ($imapConnection, $sent_folder, "");
35 }
d7e3602c 36 if ($trash_create == "true") {
90790bd4 37 sqimap_mailbox_create ($imapConnection, $trash_folder, "");
38 }
90790bd4 39 echo "<BR><BR><CENTER><b>";
40 echo _("Mailboxes Created Successfully!");
9f2215a1 41 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
d7e3602c 42 echo _("Click here");
43 echo "</A> ";
44 echo _("to continue.");
45 echo "</CENTER>";
46 echo "</BODY></HTML>";
90790bd4 47
48 exit;
49 }
50
d7e3602c 51//display form option for creating Sent and Trash folder
52 if ($imap_server_type == "cyrus") {
90790bd4 53 if ((!sqimap_mailbox_exists ($imapConnection, $sent_folder)) || (!sqimap_mailbox_exists ($imapConnection, $trash_folder))) {
54 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
55 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
56 echo _("Special Folder Options");
57 echo "</B></TD></TR>";
58 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
59 echo _("In order for SquirrelMail to provide the full set of options you need to create the special folders listed below. Just click the check box and hit the create button.");
9f2215a1 60 echo "<FORM ACTION=\"folders.php\" METHOD=\"POST\">\n";
90790bd4 61 if (!sqimap_mailbox_exists ($imapConnection, $sent_folder)) {
62 echo _("Create Sent") . "<INPUT TYPE=checkbox NAME=sent_create value=true><br>\n";
63 }
64 if (!sqimap_mailbox_exists ($imapConnection, $trash_folder)){
65 echo _("Create Trash") . "<INPUT TYPE=checkbox NAME=trash_create value=true><br>\n";
66 echo "<INPUT TYPE=submit VALUE=Create>";
67 echo "</FORM></TD></TR>\n";
68 }
69 }
70 }
71
60573cd9 72 /** DELETING FOLDERS **/
907165ca 73 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
aae41ae9 74 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
036a8a9d 75 echo _("Delete Folder");
aae41ae9 76 echo "</B></TD></TR>";
f8f9bed9 77 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
1e0628fb 78
225ce239 79 $count_special_folders = 0;
4bbba0d8 80 $num_max = 1;
81 if ($move_to_trash)
82 $num_max++;
83 if ($move_to_sent)
84 $num_max++;
85
86 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++) {
1e0628fb 87 if (strtolower($boxes[$i]["unformatted"]) == "inbox")
88 $count_special_folders++;
89 else if ($boxes[$i]["unformatted"] == $trash_folder)
90 $count_special_folders++;
91 else if ($boxes[$i]["unformatted"] == $sent_folder)
92 $count_special_folders++;
93 }
225ce239 94
95 if ($count_special_folders < count($boxes)) {
9f2215a1 96 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
225ce239 97 echo "<TT><SELECT NAME=mailbox>\n";
98 for ($i = 0; $i < count($boxes); $i++) {
99 $use_folder = true;
1e0628fb 100 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
101 ($boxes[$i]["unformatted"] != $trash_folder) &&
102 ($boxes[$i]["unformatted"] != $sent_folder))
103 {
225ce239 104 $box = $boxes[$i]["unformatted-dm"];
105 $box2 = replace_spaces($boxes[$i]["formatted"]);
106 echo " <OPTION VALUE=\"$box\">$box2\n";
e457e585 107 }
60573cd9 108 }
225ce239 109 echo "</SELECT></TT>\n";
110 echo "<INPUT TYPE=SUBMIT VALUE=\"";
111 echo _("Delete");
112 echo "\">\n";
113 echo "</FORM><BR></TD></TR>\n";
114 } else {
115 echo _("No mailboxes found") . "<br><br></td><tr>";
60573cd9 116 }
7ce342dc 117
60573cd9 118
119 /** CREATING FOLDERS **/
aae41ae9 120 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
036a8a9d 121 echo _("Create Folder");
aae41ae9 122 echo "</B></TD></TR>";
f8f9bed9 123 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
9f2215a1 124 echo "<FORM ACTION=\"folders_create.php\" METHOD=\"POST\">\n";
907165ca 125 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
036a8a9d 126 echo _("as a subfolder of");
aae41ae9 127 echo "<BR>";
128 echo "<TT><SELECT NAME=subfolder>\n";
d92b6f31 129 if ($default_sub_of_inbox == false)
130 echo "<OPTION SELECTED>[ None ]\n";
131 else
132 echo "<OPTION>[ None ]\n";
133
7ce342dc 134 for ($i = 0; $i < count($boxes); $i++) {
1f97f59a 135 if (count($boxes[$i]["flags"]) > 0) {
136 for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
137 if ($boxes[$i]["flags"][$j] != "noinferiors") {
1e0628fb 138 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
1f97f59a 139 $box = $boxes[$i]["unformatted"];
140 $box2 = replace_spaces($boxes[$i]["formatted"]);
141 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
142 } else {
143 $box = $boxes[$i]["unformatted"];
144 $box2 = replace_spaces($boxes[$i]["formatted"]);
145 echo "<OPTION VALUE=\"$box\">$box2\n";
146 }
147 }
148 }
149 } else {
1e0628fb 150 if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) {
1f97f59a 151 $box = $boxes[$i]["unformatted"];
152 $box2 = replace_spaces($boxes[$i]["formatted"]);
153 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
154 } else {
155 $box = $boxes[$i]["unformatted"];
156 $box2 = replace_spaces($boxes[$i]["formatted"]);
157 echo "<OPTION VALUE=\"$box\">$box2\n";
158 }
159 }
60573cd9 160 }
7ce342dc 161 echo "</SELECT></TT><BR>\n";
813eba2f 162 if ($show_contain_subfolders_option) {
aae41ae9 163 echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> &nbsp;";
036a8a9d 164 echo _("Let this folder contain subfolders");
aae41ae9 165 echo "<BR>";
813eba2f 166 }
aae41ae9 167 echo "<INPUT TYPE=SUBMIT VALUE=Create>\n";
907165ca 168 echo "</FORM><BR></TD></TR><BR>\n";
60573cd9 169
170 /** RENAMING FOLDERS **/
aae41ae9 171 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
036a8a9d 172 echo _("Rename a Folder");
aae41ae9 173 echo "</B></TD></TR>";
f8f9bed9 174 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
225ce239 175 if ($count_special_folders < count($boxes)) {
9f2215a1 176 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n";
225ce239 177 echo "<TT><SELECT NAME=old>\n";
178 for ($i = 0; $i < count($boxes); $i++) {
179 $use_folder = true;
1e0628fb 180
181 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
182 ($boxes[$i]["unformatted"] != $trash_folder) &&
183 ($boxes[$i]["unformatted"] != $sent_folder))
184 {
693ccbc9 185 $box = $boxes[$i]["unformatted-dm"];
225ce239 186 $box2 = replace_spaces($boxes[$i]["formatted"]);
187 echo " <OPTION VALUE=\"$box\">$box2\n";
907165ca 188 }
60573cd9 189 }
225ce239 190 echo "</SELECT></TT>\n";
191 echo "<INPUT TYPE=SUBMIT VALUE=\"";
192 echo _("Rename");
193 echo "\">\n";
37578167 194 echo "</FORM></TD></TR>\n";
195 } else {
196 echo _("No mailboxes found") . "<br><br></td></tr>";
197 }
198 $boxes_sub = $boxes;
199
200 /** UNSUBSCRIBE FOLDERS **/
201 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
202 echo _("Unsubscribe/Subscribe");
203 echo "</B></TD></TR>";
204 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
205 if ($count_special_folders < count($boxes)) {
9f2215a1 206 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
37578167 207 echo "<TT><SELECT NAME=mailbox>\n";
208 for ($i = 0; $i < count($boxes); $i++) {
209 $use_folder = true;
1e0628fb 210 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
211 ($boxes[$i]["unformatted"] != $trash_folder) &&
212 ($boxes[$i]["unformatted"] != $sent_folder))
213 {
37578167 214 $box = $boxes[$i]["unformatted-dm"];
215 $box2 = replace_spaces($boxes[$i]["formatted"]);
216 echo " <OPTION VALUE=\"$box\">$box2\n";
217 }
218 }
219 echo "</SELECT></TT>\n";
220 echo "<INPUT TYPE=SUBMIT VALUE=\"";
221 echo _("Unsubscribe");
222 echo "\">\n";
223 echo "</FORM></TD></TR>\n";
224 } else {
225 echo _("No mailboxes found") . "<br><br></td></tr>";
226 }
227 $boxes_sub = $boxes;
228
229 /** SUBSCRIBE TO FOLDERS **/
230
231 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
24f6a107 232 if ($count_special_folders <= count($boxes)) {
37578167 233 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
32b3d87e 234 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
37578167 235
9f2215a1 236 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
32b3d87e 237 echo "<tt><select name=mailbox>";
238 for ($i = 0; $i < count($boxes_all); $i++) {
239 $use_folder = true;
1e0628fb 240 for ($p = 0; $p < count ($boxes); $p++) {
241 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
242 $use_folder = false;
243 continue;
244 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
245 $use_folder = false;
246 }
247 }
248 if ($use_folder == true) {
32b3d87e 249 $box = $boxes_all[$i]["unformatted-dm"];
250 $box2 = replace_spaces($boxes_all[$i]["formatted"]);
251 echo " <OPTION VALUE=\"$box\">$box2\n";
252 }
253 }
254 echo "</select></tt>";
37578167 255 echo "<INPUT TYPE=SUBMIT VALUE=\"";
256 echo _("Subscribe");
257 echo "\">\n";
225ce239 258 echo "</FORM></TD></TR></TABLE><BR>\n";
259 } else {
260 echo _("No mailboxes found") . "<br><br></td></tr></table>";
60573cd9 261 }
60573cd9 262
aa42fbfb 263?>
2aa12d5e 264</BODY></HTML>