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";
107 /** count special folders **/
108 $count_special_folders = 0;
110 if (strtolower($imap_server_type) == "courier" ||
$move_to_trash) {
116 if ($save_as_draft) {
119 for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++
) {
120 if (strtolower($boxes[$p]['unformatted']) == 'inbox')
121 $count_special_folders++
;
122 else if (strtolower($imap_server_type) == 'courier' &&
123 strtolower($boxes[$p]['unformatted']) == 'inbox.trash')
124 $count_special_folders++
;
125 else if ($boxes[$p]['unformatted'] == $trash_folder && $trash_folder)
126 $count_special_folders++
;
127 else if ($boxes[$p]['unformatted'] == $sent_folder && $sent_folder)
128 $count_special_folders++
;
129 else if ($boxes[$p]['unformatted'] == $draft_folder && $draft_folder)
130 $count_special_folders++
;
134 /** RENAMING FOLDERS **/
135 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>".
136 _("Rename a Folder").
138 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
139 if ($count_special_folders < count($boxes)) {
140 echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"
141 . "<TT><SELECT NAME=old>\n"
142 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
143 for ($i = 0; $i < count($boxes); $i++
) {
146 if ((strtolower($boxes[$i]['unformatted']) != 'inbox') &&
147 ($boxes[$i]['unformatted'] != $trash_folder) &&
148 ($boxes[$i]['unformatted'] != $sent_folder) &&
149 ($boxes[$i]['unformatted'] != $draft_folder)) {
150 $box = $boxes[$i]['unformatted-dm'];
152 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
153 if (strtolower($imap_server_type) != 'courier' ||
strtolower($box) != 'inbox.trash') {
154 echo "<OPTION VALUE=\"$box\">$box2</option>\n";
158 echo "</SELECT></TT>\n".
159 "<INPUT TYPE=SUBMIT VALUE=\"".
162 "</FORM></TD></TR>\n";
164 echo _("No folders found") . "<br><br></td></tr>";
168 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n";
170 /** DELETING FOLDERS **/
171 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>";
172 echo _("Delete Folder");
173 echo "</B></TD></TR>";
174 echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>";
176 if ($count_special_folders < count($boxes)) {
177 echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"
178 . "<TT><SELECT NAME=mailbox>\n"
179 . ' <OPTION VALUE="">[ ' . _("Select a folder") . " ]</OPTION>\n";
180 for ($i = 0; $i < count($boxes); $i++
) {
182 if ((strtolower($boxes[$i]['unformatted']) != 'inbox') &&
183 ($boxes[$i]['unformatted'] != $trash_folder) &&
184 ($boxes[$i]['unformatted'] != $sent_folder) &&
185 ($boxes[$i]['unformatted'] != $draft_folder) &&
186 (!in_array('noselect', $boxes[$i]['flags'])) &&
187 ((strtolower($imap_server_type) != 'courier') ||
188 (strtolower($boxes[$i]['unformatted']) != 'inbox.trash'))) {
189 $box = $boxes[$i]['unformatted-dm'];
190 $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']);
191 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
194 echo "</SELECT></TT>\n";
195 echo "<INPUT TYPE=SUBMIT VALUE=\"";
198 echo "</FORM></TD></TR>\n";
200 echo _("No folders found") . "<br><br></td><tr>";
202 echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n";
204 /** UNSUBSCRIBE FOLDERS **/
205 echo "<TABLE WIDTH=\"70%\" COLS=2 ALIGN=CENTER cellpadding=4 cellspacing=0 border=0>\n";
206 echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=2><B>";
207 echo _("Unsubscribe") . "/" . _("Subscribe");
208 echo "</B></TD></TR>\n";
209 echo "<TR><TD BGCOLOR=\"$color[0]\" width=\"50%\" ALIGN=CENTER>\n";
210 if ($count_special_folders < count($boxes)) {
211 echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n";
212 echo "<TT><SELECT NAME=\"mailbox[]\" multiple size=8>\n";
213 for ($i = 0; $i < count($boxes); $i++
) {
215 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
216 ($boxes[$i]["unformatted"] != $trash_folder) &&
217 ($boxes[$i]["unformatted"] != $sent_folder) &&
218 ($boxes[$i]["unformatted"] != $draft_folder)) {
219 $box = $boxes[$i]["unformatted-dm"];
220 $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]);
221 echo " <OPTION VALUE=\"$box\">$box2\n";
224 echo "</SELECT></TT><br><br>\n";
225 echo "<INPUT TYPE=SUBMIT VALUE=\"";
226 echo _("Unsubscribe");
228 echo "</FORM></TD>\n";
230 echo _("No folders were found to unsubscribe from!") . "</td>";
234 /** SUBSCRIBE TO FOLDERS **/
235 echo "<TD BGCOLOR=\"$color[0]\" width=\"50%\" ALIGN=CENTER>";
236 $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1);
237 $boxes_all = sqimap_mailbox_list_all ($imap_stream);
241 for ($i = 0, $q = 0; $i < count($boxes_all); $i++
) {
243 for ($p = 0; $p < count ($boxes); $p++
) {
244 if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) {
247 } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) {
251 if ($use_folder == true) {
252 $box[$q] = $boxes_all[$i]["unformatted-dm"];
253 $box2[$q] = $boxes_all[$i]["unformatted-disp"];
257 sqimap_logout($imap_stream);
260 echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n";
261 echo "<tt><select name=\"mailbox[]\" multiple size=8>";
263 for ($q = 0; $q < count($box); $q++
) {
264 echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n";
266 echo "</select></tt><br><br>";
267 echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n";
268 echo "</FORM></TD></TR></TABLE><BR>\n";
270 echo _("No folders were found to subscribe to!") . "</td></tr></table>";
273 do_hook("folders_bottom");
284 sqimap_logout($imapConnection);