6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Handles all interaction between the user and the other folder
10 * scripts which do most of the work. Also handles the Special
16 require_once('../src/validate.php');
17 require_once('../functions/imap.php');
18 require_once('../functions/array.php');
19 require_once('../functions/plugin.php');
21 displayPageHeader($color, 'None');
26 <table bgcolor
="<?php echo $color[0] ?>" width
="95%" align
="center" cellpadding
="2" cellspacing
="0" border
="0">
27 <tr
><td align
="center">
29 <b
><?php
echo _("Folders"); ?
></b
>
31 <table width
="100%" border
="0" cellpadding
="5" cellspacing
="0">
32 <tr
><td bgcolor
="<?php echo $color[4] ?>" align
="center">
36 if ((isset($success) && $success) ||
37 (isset($sent_create) && $sent_create == 'true') ||
38 (isset($trash_create) && $trash_create == 'true')) {
39 echo "<table width=\"100%\" align=center cellpadding=4 cellspacing=0 border=0>\n" .
40 " <tr><td align=center>\n";
41 if ($success == "subscribe") {
42 echo "<b>" . _("Subscribed successfully!") . "</b><br>";
43 } else if ($success == "unsubscribe") {
44 echo "<b>" . _("Unsubscribed successfully!") . "</b><br>";
45 } else if ($success == "delete") {
46 echo "<b>" . _("Deleted folder successfully!") . "</b><br>";
47 } else if ($success == "create") {
48 echo "<b>" . _("Created folder successfully!") . "</b><br>";
49 } else if ($success == "rename") {
50 echo "<b>" . _("Renamed successfully!") . "</b><br>";
53 echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>".
59 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
60 $boxes = sqimap_mailbox_list($imapConnection);
62 /** CREATING FOLDERS **/
63 echo "<TABLE WIDTH=\"70%\" COLS=1 ALIGN=CENTER cellpadding=4 cellspacing=0 border=0>\n".
64 "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>".
67 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>".
68 "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n".
69 "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n".
70 _("as a subfolder of").
72 "<TT><SELECT NAME=subfolder>\n";
73 if ($default_sub_of_inbox == false) {
74 echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n";
76 echo '<OPTION VALUE="">[ '._("None")." ]\n";
79 for ($i = 0; $i < count($boxes); $i++
) {
80 if (!in_array('noinferiors', $boxes[$i]['flags'])) {
81 if ((strtolower($boxes[$i]['unformatted']) == 'inbox') &&
82 $default_sub_of_inbox) {
83 $box = $boxes[$i]['unformatted'];
84 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
85 echo "<OPTION SELECTED VALUE=\"$box\">$box2</option>\n";
87 $box = $boxes[$i]['unformatted'];
88 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
89 if (strtolower($imap_server_type) != 'courier' ||
90 strtolower($box) != "inbox.trash")
91 echo "<OPTION VALUE=\"$box\">$box2</option>\n";
95 echo "</SELECT></TT>\n";
96 if ($show_contain_subfolders_option) {
97 echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> ";
98 echo _("Let this folder contain subfolders");
101 echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n";
102 echo "</FORM></TD></TR>\n";
104 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
106 /** RENAMING FOLDERS **/
107 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>".
108 _("Rename a Folder").
110 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
112 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n".
113 "<TT><SELECT NAME=old>\n";
114 for ($i = 0; $i < count($boxes); $i++
) {
117 if ((strtolower($boxes[$i]['unformatted']) != 'inbox') &&
118 ($boxes[$i]['unformatted'] != $trash_folder) &&
119 ($boxes[$i]['unformatted'] != $sent_folder) &&
120 ($boxes[$i]['unformatted'] != $draft_folder)) {
121 $box = $boxes[$i]['unformatted-dm'];
123 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
124 if (strtolower($imap_server_type) != 'courier' ||
strtolower($box) != 'inbox.trash') {
125 echo "<OPTION VALUE=\"$box\">$box2</option>\n";
129 echo "</SELECT></TT>\n".
130 "<INPUT TYPE=SUBMIT VALUE=\"".
133 "</FORM></TD></TR>\n";
135 echo _("No folders found") . "<br><br></td></tr>";
139 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
141 /** DELETING FOLDERS **/
142 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
143 echo _("Delete Folder");
144 echo "</B></TD></TR>";
145 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
147 $count_special_folders = 0;
149 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash) {
155 if ($save_as_draft) {
158 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
159 if (strtolower($boxes[$p]['unformatted']) == 'inbox')
160 $count_special_folders++
;
161 else if (strtolower($imap_server_type) == 'courier' &&
162 strtolower($boxes[$p]['unformatted']) == 'inbox.trash')
163 $count_special_folders++
;
164 else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
165 $count_special_folders++
;
166 else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
167 $count_special_folders++
;
168 else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
169 $count_special_folders++
;
172 if ($count_special_folders < count($boxes)) {
173 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n";
174 echo "<TT><SELECT NAME=mailbox>\n";
175 for ($i = 0; $i < count($boxes); $i++
) {
177 if ((strtolower($boxes[$i]['unformatted']) != 'inbox') &&
178 ($boxes[$i]['unformatted'] != $trash_folder) &&
179 ($boxes[$i]['unformatted'] != $sent_folder) &&
180 ($boxes[$i]['unformatted'] != $draft_folder) &&
181 ((strtolower($imap_server_type) != 'courier') ||
182 (strtolower($boxes[$i]['unformatted']) != 'inbox.trash'))) {
183 $box = $boxes[$i]['unformatted-dm'];
184 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
185 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
188 echo "</SELECT></TT>\n";
189 echo "<INPUT TYPE=SUBMIT VALUE=\"";
192 echo "</FORM></TD></TR>\n";
194 echo _("No folders found") . "<br><br></td><tr>";
196 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n";
198 /** UNSUBSCRIBE FOLDERS **/
199 echo "<TABLE WIDTH=\"70%\" COLS=2 ALIGN=CENTER cellpadding=4 cellspacing=0 border=0>\n";
200 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=2><B>";
201 echo _("Unsubscribe") . "/" . _("Subscribe");
202 echo "</B></TD></TR>\n";
203 echo "<TR><TD BGCOLOR=\"$color[0]\" width=\"50%\" ALIGN=CENTER>\n";
204 if ($count_special_folders < count($boxes)) {
205 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
206 echo "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
207 for ($i = 0; $i < count($boxes); $i++
) {
209 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
210 ($boxes[$i]["unformatted"] != $trash_folder) &&
211 ($boxes[$i]["unformatted"] != $sent_folder) &&
212 ($boxes[$i]["unformatted"] != $draft_folder)) {
213 $box = $boxes[$i]["unformatted-dm"];
214 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
215 echo " <OPTION VALUE=\"$box\">$box2\n";
218 echo "</SELECT></TT><br><br>\n";
219 echo "<INPUT TYPE=SUBMIT VALUE=\"";
220 echo _("Unsubscribe");
222 echo "</FORM></TD>\n";
224 echo _("No folders were found to unsubscribe from!") . "</td>";
228 /** SUBSCRIBE TO FOLDERS **/
229 echo "<TD BGCOLOR=\"$color[0]\" width=\"50%\" ALIGN=CENTER>";
230 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
231 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
235 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
237 for ($p = 0; $p < count ($boxes); $p++
) {
238 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
241 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
245 if ($use_folder == true) {
246 $box[$q] = $boxes_all[$i]["unformatted-dm"];
247 $box2[$q] = $boxes_all[$i]["unformatted-disp"];
251 sqimap_logout($imap_stream);
254 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
255 echo "<tt><select name=\"mailbox[]\" multiple size=8>";
257 for ($q = 0; $q < count($box); $q++
) {
258 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
260 echo "</select></tt><br><br>";
261 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
262 echo "</FORM></TD></TR></TABLE><BR>\n";
264 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
267 do_hook("folders_bottom");
278 sqimap_logout($imapConnection);