Worked on setting answered flag
[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
d7e3602c 30 /** Cyrus Folder Options**/
31//Creates the Sent and Trash folder
32if (($sent_create == "true") || ($trash_create == "true")) {
33 if ($sent_create == "true") {
34 sqimap_mailbox_create ($imapConnection, $sent_folder, "");
35 }
36 if ($trash_create == "true") {
37 sqimap_mailbox_create ($imapConnection, $trash_folder, "");
38 }
39//Major hack, need to right a funtion to check and if mailbox is subscribed to
40 sqimap_subscribe($imapConnection, "INBOX");
41 echo "<BR><BR>";
42 echo _("Mailboxes Created Successfully!");
43 echo "<BR><A HREF=\"webmail.php?PHPSESSID=$PHPSESSID&right_frame=folders.php\" TARGET=_top>";
44 echo _("Click here");
45 echo "</A> ";
46 echo _("to continue.");
47 echo "</CENTER>";
48 echo "</BODY></HTML>";
49exit;
50}
51//display form option for creating Sent and Trash folder
52 if ($imap_server_type == "cyrus") {
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.");
60 echo "<FORM ACTION=\"folders_test.php?PHPSESSID=$PHPSESSID\" METHOD=\"POST\">\n";
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}
60573cd9 71 /** DELETING FOLDERS **/
907165ca 72 echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
aae41ae9 73 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
036a8a9d 74 echo _("Delete Folder");
aae41ae9 75 echo "</B></TD></TR>";
f8f9bed9 76 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
225ce239 77 $count_special_folders = 0;
78 for ($i = 0; $i < count($special_folders); $i++) {
60573cd9 79 for ($p = 0; $p < count($special_folders); $p++) {
813eba2f 80 if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
225ce239 81 $count_special_folders++;
82 }
83 }
84 }
85
86 if ($count_special_folders < count($boxes)) {
2a32fc83 87 echo "<FORM ACTION=\"folders_delete.php?PHPSESSID=$PHPSESSID\" METHOD=\"POST\">\n";
225ce239 88 echo "<TT><SELECT NAME=mailbox>\n";
89 for ($i = 0; $i < count($boxes); $i++) {
90 $use_folder = true;
91 for ($p = 0; $p < count($special_folders); $p++) {
92 if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
93 $use_folder = false;
94 } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
95 $use_folder = false;
96 }
97 }
98 if ($use_folder == true) {
99 $box = $boxes[$i]["unformatted-dm"];
100 $box2 = replace_spaces($boxes[$i]["formatted"]);
101 echo " <OPTION VALUE=\"$box\">$box2\n";
e457e585 102 }
60573cd9 103 }
225ce239 104 echo "</SELECT></TT>\n";
105 echo "<INPUT TYPE=SUBMIT VALUE=\"";
106 echo _("Delete");
107 echo "\">\n";
108 echo "</FORM><BR></TD></TR>\n";
109 } else {
110 echo _("No mailboxes found") . "<br><br></td><tr>";
60573cd9 111 }
7ce342dc 112
60573cd9 113
114 /** CREATING FOLDERS **/
aae41ae9 115 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
036a8a9d 116 echo _("Create Folder");
aae41ae9 117 echo "</B></TD></TR>";
f8f9bed9 118 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
2a32fc83 119 echo "<FORM ACTION=\"folders_create.php?PHPSESSID=$PHPSESSID\" METHOD=\"POST\">\n";
907165ca 120 echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n";
036a8a9d 121 echo _("as a subfolder of");
aae41ae9 122 echo "<BR>";
123 echo "<TT><SELECT NAME=subfolder>\n";
d92b6f31 124 if ($default_sub_of_inbox == false)
125 echo "<OPTION SELECTED>[ None ]\n";
126 else
127 echo "<OPTION>[ None ]\n";
128
7ce342dc 129 for ($i = 0; $i < count($boxes); $i++) {
1f97f59a 130 if (count($boxes[$i]["flags"]) > 0) {
131 for ($j = 0; $j < count($boxes[$i]["flags"]); $j++) {
132 if ($boxes[$i]["flags"][$j] != "noinferiors") {
133 if (($boxes[$i]["unformatted"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
134 $box = $boxes[$i]["unformatted"];
135 $box2 = replace_spaces($boxes[$i]["formatted"]);
136 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
137 } else {
138 $box = $boxes[$i]["unformatted"];
139 $box2 = replace_spaces($boxes[$i]["formatted"]);
140 echo "<OPTION VALUE=\"$box\">$box2\n";
141 }
142 }
143 }
144 } else {
145 if (($boxes[$i]["unformatted"] == $special_folders[0]) && ($default_sub_of_inbox == true)) {
146 $box = $boxes[$i]["unformatted"];
147 $box2 = replace_spaces($boxes[$i]["formatted"]);
148 echo "<OPTION SELECTED VALUE=\"$box\">$box2\n";
149 } else {
150 $box = $boxes[$i]["unformatted"];
151 $box2 = replace_spaces($boxes[$i]["formatted"]);
152 echo "<OPTION VALUE=\"$box\">$box2\n";
153 }
154 }
60573cd9 155 }
7ce342dc 156 echo "</SELECT></TT><BR>\n";
813eba2f 157 if ($show_contain_subfolders_option) {
aae41ae9 158 echo "<INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> &nbsp;";
036a8a9d 159 echo _("Let this folder contain subfolders");
aae41ae9 160 echo "<BR>";
813eba2f 161 }
aae41ae9 162 echo "<INPUT TYPE=SUBMIT VALUE=Create>\n";
907165ca 163 echo "</FORM><BR></TD></TR><BR>\n";
60573cd9 164
165 /** RENAMING FOLDERS **/
aae41ae9 166 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
036a8a9d 167 echo _("Rename a Folder");
aae41ae9 168 echo "</B></TD></TR>";
f8f9bed9 169 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
225ce239 170 if ($count_special_folders < count($boxes)) {
2a32fc83 171 echo "<FORM ACTION=\"folders_rename_getname.php?PHPSESSID=$PHPSESSID\" METHOD=\"POST\">\n";
225ce239 172 echo "<TT><SELECT NAME=old>\n";
173 for ($i = 0; $i < count($boxes); $i++) {
174 $use_folder = true;
175 for ($p = 0; $p < count($special_folders); $p++) {
176 if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
177 $use_folder = false;
178 } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
179 $use_folder = false;
180 }
181 }
182 if ($use_folder == true) {
693ccbc9 183 $box = $boxes[$i]["unformatted-dm"];
225ce239 184 $box2 = replace_spaces($boxes[$i]["formatted"]);
185 echo " <OPTION VALUE=\"$box\">$box2\n";
907165ca 186 }
60573cd9 187 }
225ce239 188 echo "</SELECT></TT>\n";
189 echo "<INPUT TYPE=SUBMIT VALUE=\"";
190 echo _("Rename");
191 echo "\">\n";
37578167 192 echo "</FORM></TD></TR>\n";
193 } else {
194 echo _("No mailboxes found") . "<br><br></td></tr>";
195 }
196 $boxes_sub = $boxes;
197
198 /** UNSUBSCRIBE FOLDERS **/
199 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
200 echo _("Unsubscribe/Subscribe");
201 echo "</B></TD></TR>";
202 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
203 if ($count_special_folders < count($boxes)) {
2a32fc83 204 echo "<FORM ACTION=\"folders_subscribe.php?PHPSESSID=$PHPSESSID&method=unsub\" METHOD=\"POST\">\n";
37578167 205 echo "<TT><SELECT NAME=mailbox>\n";
206 for ($i = 0; $i < count($boxes); $i++) {
207 $use_folder = true;
208 for ($p = 0; $p < count($special_folders); $p++) {
209 if ($boxes[$i]["unformatted"] == $special_folders[$p]) {
210 $use_folder = false;
211 } else if (substr($boxes[$i]["unformatted"], 0, strlen($trash_folder)) == $trash_folder) {
212 $use_folder = false;
213 }
214 }
215 if ($use_folder == true) {
216 $box = $boxes[$i]["unformatted-dm"];
217 $box2 = replace_spaces($boxes[$i]["formatted"]);
218 echo " <OPTION VALUE=\"$box\">$box2\n";
219 }
220 }
221 echo "</SELECT></TT>\n";
222 echo "<INPUT TYPE=SUBMIT VALUE=\"";
223 echo _("Unsubscribe");
224 echo "\">\n";
225 echo "</FORM></TD></TR>\n";
226 } else {
227 echo _("No mailboxes found") . "<br><br></td></tr>";
228 }
229 $boxes_sub = $boxes;
230
231 /** SUBSCRIBE TO FOLDERS **/
232
233 echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
24f6a107 234 if ($count_special_folders <= count($boxes)) {
37578167 235 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
236 $boxes = sqimap_mailbox_list_all ($imap_stream);
237
2a32fc83 238 echo "<FORM ACTION=\"folders_subscribe.php?PHPSESSID=$PHPSESSID&method=sub\" METHOD=\"POST\">\n";
81a897dc 239 echo "<tt><input type=text size=32 name=mailbox></tt>";
37578167 240 echo "<INPUT TYPE=SUBMIT VALUE=\"";
241 echo _("Subscribe");
242 echo "\">\n";
225ce239 243 echo "</FORM></TD></TR></TABLE><BR>\n";
244 } else {
245 echo _("No mailboxes found") . "<br><br></td></tr></table>";
60573cd9 246 }
60573cd9 247
aa42fbfb 248?>
2aa12d5e 249</BODY></HTML>