Added var $imap_server_type, usage is in the comments. Need to see if I need to...
[squirrelmail.git] / src / folders.php
CommitLineData
a044cee3 1<?
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
30 /** DELETING FOLDERS **/
907165ca 31 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
aae41ae9 32 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
036a8a9d 33 echo _("Delete Folder");
aae41ae9 34 echo "</B></TD></TR>";
f8f9bed9 35 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
225ce239 36 $count_special_folders = 0;
37 for ($i = 0; $i < count($special_folders); $i++) {
60573cd9 38 for ($p = 0; $p < count($special_folders); $p++) {
813eba2f 39 if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
225ce239 40 $count_special_folders++;
41 }
42 }
43 }
44
45 if ($count_special_folders < count($boxes)) {
2a32fc83 46 echo "<FORM ACTION=\"folders_delete.php?PHPSESSID=$PHPSESSID\" METHOD=\"POST\">\n";
225ce239 47 echo "<TT><SELECT NAME=mailbox>\n";
48 for ($i = 0; $i < count($boxes); $i++) {
49 $use_folder = true;
50 for ($p = 0; $p < count($special_folders); $p++) {
51 if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
52 $use_folder = false;
53 } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
54 $use_folder = false;
55 }
56 }
57 if ($use_folder == true) {
58 $box = $boxes[$i]["unformatted-dm"];
59 $box2 = replace_spaces($boxes[$i]["formatted"]);
60 echo " <OPTION VALUE=\"$box\">$box2\n";
e457e585 61 }
60573cd9 62 }
225ce239 63 echo "</SELECT></TT>\n";
64 echo "<INPUT TYPE=SUBMIT VALUE=\"";
65 echo _("Delete");
66 echo "\">\n";
67 echo "</FORM><BR></TD></TR>\n";
68 } else {
69 echo _("No mailboxes found") . "<br><br></td><tr>";
60573cd9 70 }
7ce342dc 71
60573cd9 72
73 /** CREATING FOLDERS **/
aae41ae9 74 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
036a8a9d 75 echo _("Create Folder");
aae41ae9 76 echo "</B></TD></TR>";
f8f9bed9 77 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
2a32fc83 78 echo "<FORM ACTION=\"folders_create.php?PHPSESSID=$PHPSESSID\" METHOD=\"POST\">\n";
907165ca 79 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
036a8a9d 80 echo _("as a subfolder of");
aae41ae9 81 echo "<BR>";
82 echo "<TT><SELECT NAME=subfolder>\n";
d92b6f31 83 if ($default_sub_of_inbox == false)
84 echo "<OPTION SELECTED>[ None ]\n";
85 else
86 echo "<OPTION>[ None ]\n";
87
7ce342dc 88 for ($i = 0; $i < count($boxes); $i++) {
1f97f59a 89 if (count($boxes[$i]["flags"]) > 0) {
90 for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
91 if ($boxes[$i]["flags"][$j] != "noinferiors") {
92 if (($boxes[$i]["unformatted"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
93 $box = $boxes[$i]["unformatted"];
94 $box2 = replace_spaces($boxes[$i]["formatted"]);
95 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
96 } else {
97 $box = $boxes[$i]["unformatted"];
98 $box2 = replace_spaces($boxes[$i]["formatted"]);
99 echo "<OPTION VALUE=\"$box\">$box2\n";
100 }
101 }
102 }
103 } else {
104 if (($boxes[$i]["unformatted"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
105 $box = $boxes[$i]["unformatted"];
106 $box2 = replace_spaces($boxes[$i]["formatted"]);
107 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
108 } else {
109 $box = $boxes[$i]["unformatted"];
110 $box2 = replace_spaces($boxes[$i]["formatted"]);
111 echo "<OPTION VALUE=\"$box\">$box2\n";
112 }
113 }
60573cd9 114 }
7ce342dc 115 echo "</SELECT></TT><BR>\n";
813eba2f 116 if ($show_contain_subfolders_option) {
aae41ae9 117 echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> &nbsp;";
036a8a9d 118 echo _("Let this folder contain subfolders");
aae41ae9 119 echo "<BR>";
813eba2f 120 }
aae41ae9 121 echo "<INPUT TYPE=SUBMIT VALUE=Create>\n";
907165ca 122 echo "</FORM><BR></TD></TR><BR>\n";
60573cd9 123
124 /** RENAMING FOLDERS **/
aae41ae9 125 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
036a8a9d 126 echo _("Rename a Folder");
aae41ae9 127 echo "</B></TD></TR>";
f8f9bed9 128 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
225ce239 129 if ($count_special_folders < count($boxes)) {
2a32fc83 130 echo "<FORM ACTION=\"folders_rename_getname.php?PHPSESSID=$PHPSESSID\" METHOD=\"POST\">\n";
225ce239 131 echo "<TT><SELECT NAME=old>\n";
132 for ($i = 0; $i < count($boxes); $i++) {
133 $use_folder = true;
134 for ($p = 0; $p < count($special_folders); $p++) {
135 if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
136 $use_folder = false;
137 } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
138 $use_folder = false;
139 }
140 }
141 if ($use_folder == true) {
693ccbc9 142 $box = $boxes[$i]["unformatted-dm"];
225ce239 143 $box2 = replace_spaces($boxes[$i]["formatted"]);
144 echo " <OPTION VALUE=\"$box\">$box2\n";
907165ca 145 }
60573cd9 146 }
225ce239 147 echo "</SELECT></TT>\n";
148 echo "<INPUT TYPE=SUBMIT VALUE=\"";
149 echo _("Rename");
150 echo "\">\n";
37578167 151 echo "</FORM></TD></TR>\n";
152 } else {
153 echo _("No mailboxes found") . "<br><br></td></tr>";
154 }
155 $boxes_sub = $boxes;
156
157 /** UNSUBSCRIBE FOLDERS **/
158 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
159 echo _("Unsubscribe/Subscribe");
160 echo "</B></TD></TR>";
161 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
162 if ($count_special_folders < count($boxes)) {
2a32fc83 163 echo "<FORM ACTION=\"folders_subscribe.php?PHPSESSID=$PHPSESSID&method=unsub\" METHOD=\"POST\">\n";
37578167 164 echo "<TT><SELECT NAME=mailbox>\n";
165 for ($i = 0; $i < count($boxes); $i++) {
166 $use_folder = true;
167 for ($p = 0; $p < count($special_folders); $p++) {
168 if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
169 $use_folder = false;
170 } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
171 $use_folder = false;
172 }
173 }
174 if ($use_folder == true) {
175 $box = $boxes[$i]["unformatted-dm"];
176 $box2 = replace_spaces($boxes[$i]["formatted"]);
177 echo " <OPTION VALUE=\"$box\">$box2\n";
178 }
179 }
180 echo "</SELECT></TT>\n";
181 echo "<INPUT TYPE=SUBMIT VALUE=\"";
182 echo _("Unsubscribe");
183 echo "\">\n";
184 echo "</FORM></TD></TR>\n";
185 } else {
186 echo _("No mailboxes found") . "<br><br></td></tr>";
187 }
188 $boxes_sub = $boxes;
189
190 /** SUBSCRIBE TO FOLDERS **/
191
192 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
44e502e4 193 if ($count_special_folders <= count($boxes)) {
37578167 194 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
195 $boxes = sqimap_mailbox_list_all ($imap_stream);
196
2a32fc83 197 echo "<FORM ACTION=\"folders_subscribe.php?PHPSESSID=$PHPSESSID&method=sub\" METHOD=\"POST\">\n";
81a897dc 198 echo "<tt><input type=text size=32 name=mailbox></tt>";
37578167 199 echo "<INPUT TYPE=SUBMIT VALUE=\"";
200 echo _("Subscribe");
201 echo "\">\n";
225ce239 202 echo "</FORM></TD></TR></TABLE><BR>\n";
203 } else {
204 echo _("No mailboxes found") . "<br><br></td></tr></table>";
60573cd9 205 }
60573cd9 206
aa42fbfb 207?>
2aa12d5e 208</BODY></HTML>