| 1 | <?php |
| 2 | /** |
| 3 | ** folders.php |
| 4 | ** |
| 5 | ** Copyright (c) 1999-2000 The SquirrelMail development team |
| 6 | ** Licensed under the GNU GPL. For full terms see the file COPYING. |
| 7 | ** |
| 8 | ** Handles all interaction between the user and the other folder |
| 9 | ** scripts which do most of the work. Also handles the Special |
| 10 | ** Folders. |
| 11 | ** |
| 12 | ** $Id$ |
| 13 | **/ |
| 14 | |
| 15 | include('../src/validate.php'); |
| 16 | include("../functions/imap.php"); |
| 17 | include("../functions/array.php"); |
| 18 | include("../functions/plugin.php"); |
| 19 | |
| 20 | displayPageHeader($color, _("None")); |
| 21 | |
| 22 | ?> |
| 23 | |
| 24 | <br> |
| 25 | <table bgcolor="<?php echo $color[0] ?>" width="95%" align="center" cellpadding="2" cellspacing="0" border="0"> |
| 26 | <tr><td align="center"> |
| 27 | |
| 28 | <b><?php echo _("Folders"); ?></b> |
| 29 | |
| 30 | <table width="100%" border="0" cellpadding="5" cellspacing="0"> |
| 31 | <tr><td bgcolor="<?php echo $color[4] ?>" align="center"> |
| 32 | |
| 33 | <?php |
| 34 | |
| 35 | if ((isset($success) && $success) || |
| 36 | (isset($sent_create) && $sent_create == "true") || |
| 37 | (isset($trash_create) && $trash_create == "true")) { |
| 38 | echo "<table width=100% align=center cellpadding=2 cellspacing=0 border=0>\n"; |
| 39 | echo " <tr><td align=center>\n"; |
| 40 | if ($success == "subscribe") { |
| 41 | echo "<b>" . _("Subscribed successfully!") . "</b><br>"; |
| 42 | } else if ($success == "unsubscribe") { |
| 43 | echo "<b>" . _("Unsubscribed successfully!") . "</b><br>"; |
| 44 | } else if ($success == "delete") { |
| 45 | echo "<b>" . _("Deleted folder successfully!") . "</b><br>"; |
| 46 | } else if ($success == "create") { |
| 47 | echo "<b>" . _("Created folder successfully!") . "</b><br>"; |
| 48 | } else if ($success == "rename") { |
| 49 | echo "<b>" . _("Renamed successfully!") . "</b><br>"; |
| 50 | } |
| 51 | |
| 52 | echo " <a href=\"../src/left_main.php\" target=left>" . _("refresh folder list") . "</a>"; |
| 53 | echo " </td></tr>\n"; |
| 54 | echo "</table><br>\n"; |
| 55 | } |
| 56 | $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0); |
| 57 | $boxes = sqimap_mailbox_list($imapConnection); |
| 58 | |
| 59 | /** DELETING FOLDERS **/ |
| 60 | echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER cellpadding=2 cellspacing=0 border=0>\n"; |
| 61 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
| 62 | echo _("Delete Folder"); |
| 63 | echo "</B></TD></TR>"; |
| 64 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
| 65 | |
| 66 | $count_special_folders = 0; |
| 67 | $num_max = 1; |
| 68 | if (strtolower($imap_server_type) == "courier" || $move_to_trash) |
| 69 | $num_max++; |
| 70 | if ($move_to_sent) |
| 71 | $num_max++; |
| 72 | |
| 73 | for ($p = 0; $p < count($boxes) && $count_special_folders < $num_max; $p++) { |
| 74 | if (strtolower($boxes[$p]["unformatted"]) == "inbox") |
| 75 | $count_special_folders++; |
| 76 | else if (strtolower($imap_server_type) == "courier" && |
| 77 | strtolower($boxes[$p]["unformatted"]) == "inbox.trash") |
| 78 | $count_special_folders++; |
| 79 | else if ($boxes[$p]["unformatted"] == $trash_folder && $trash_folder) |
| 80 | $count_special_folders++; |
| 81 | else if ($boxes[$p]["unformatted"] == $sent_folder && $sent_folder) |
| 82 | $count_special_folders++; |
| 83 | } |
| 84 | |
| 85 | if ($count_special_folders < count($boxes)) { |
| 86 | echo "<FORM ACTION=\"folders_delete.php\" METHOD=\"POST\">\n"; |
| 87 | echo "<TT><SELECT NAME=mailbox>\n"; |
| 88 | for ($i = 0; $i < count($boxes); $i++) { |
| 89 | $use_folder = true; |
| 90 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
| 91 | ($boxes[$i]["unformatted"] != $trash_folder) && |
| 92 | ($boxes[$i]["unformatted"] != $sent_folder) && |
| 93 | (strtolower($imap_server_type) != "courier" || |
| 94 | strtolower($boxes[$i]["unformatted"]) != "inbox.trash")) |
| 95 | { |
| 96 | $box = $boxes[$i]["unformatted-dm"]; |
| 97 | $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]); |
| 98 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
| 99 | } |
| 100 | } |
| 101 | echo "</SELECT></TT>\n"; |
| 102 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
| 103 | echo _("Delete"); |
| 104 | echo "\">\n"; |
| 105 | echo "</FORM></TD></TR>\n"; |
| 106 | } else { |
| 107 | echo _("No folders found") . "<br><br></td><tr>"; |
| 108 | } |
| 109 | |
| 110 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
| 111 | |
| 112 | /** CREATING FOLDERS **/ |
| 113 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
| 114 | echo _("Create Folder"); |
| 115 | echo "</B></TD></TR>"; |
| 116 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
| 117 | echo "<FORM NAME=cf ACTION=\"folders_create.php\" METHOD=\"POST\">\n"; |
| 118 | echo "<INPUT TYPE=TEXT SIZE=25 NAME=folder_name><BR>\n"; |
| 119 | echo _("as a subfolder of"); |
| 120 | echo "<BR>"; |
| 121 | echo "<TT><SELECT NAME=subfolder>\n"; |
| 122 | if (strtolower($imap_server_type) != "courier"){ |
| 123 | if ($default_sub_of_inbox == false) |
| 124 | echo '<OPTION SELECTED VALUE="">[ '._("None")." ]\n"; |
| 125 | else |
| 126 | echo '<OPTION VALUE="">[ '._("None")." ]\n"; |
| 127 | } |
| 128 | |
| 129 | for ($i = 0; $i < count($boxes); $i++) { |
| 130 | if (!in_array('noinferiors', $boxes[$i]['flags'])) { |
| 131 | if ((strtolower($boxes[$i]["unformatted"]) == "inbox") && ($default_sub_of_inbox == true)) { |
| 132 | $box = $boxes[$i]["unformatted"]; |
| 133 | $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]); |
| 134 | echo "<OPTION SELECTED VALUE=\"$box\">$box2\n"; |
| 135 | } else { |
| 136 | $box = $boxes[$i]["unformatted"]; |
| 137 | $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]); |
| 138 | if (strtolower($imap_server_type) != "courier" || |
| 139 | strtolower($box) != "inbox.trash") |
| 140 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | echo "</SELECT></TT>\n"; |
| 145 | if ($show_contain_subfolders_option) { |
| 146 | echo "<br><INPUT TYPE=CHECKBOX NAME=\"contain_subs\"> "; |
| 147 | echo _("Let this folder contain subfolders"); |
| 148 | echo "<BR>"; |
| 149 | } |
| 150 | echo "<INPUT TYPE=SUBMIT VALUE=\""._("Create")."\">\n"; |
| 151 | echo "</FORM></TD></TR>\n"; |
| 152 | |
| 153 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr>\n"; |
| 154 | |
| 155 | /** RENAMING FOLDERS **/ |
| 156 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER><B>"; |
| 157 | echo _("Rename a Folder"); |
| 158 | echo "</B></TD></TR>"; |
| 159 | echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>"; |
| 160 | if ($count_special_folders < count($boxes)) { |
| 161 | echo "<FORM ACTION=\"folders_rename_getname.php\" METHOD=\"POST\">\n"; |
| 162 | echo "<TT><SELECT NAME=old>\n"; |
| 163 | for ($i = 0; $i < count($boxes); $i++) { |
| 164 | $use_folder = true; |
| 165 | |
| 166 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
| 167 | ($boxes[$i]["unformatted"] != $trash_folder) && |
| 168 | ($boxes[$i]["unformatted"] != $sent_folder)) |
| 169 | { |
| 170 | $box = $boxes[$i]["unformatted-dm"]; |
| 171 | $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]); |
| 172 | if (strtolower($imap_server_type) != "courier" || strtolower($box) != "inbox.trash") |
| 173 | echo "<OPTION VALUE=\"$box\">$box2\n"; |
| 174 | } |
| 175 | } |
| 176 | echo "</SELECT></TT>\n"; |
| 177 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
| 178 | echo _("Rename"); |
| 179 | echo "\">\n"; |
| 180 | echo "</FORM></TD></TR>\n"; |
| 181 | } else { |
| 182 | echo _("No folders found") . "<br><br></td></tr>"; |
| 183 | } |
| 184 | $boxes_sub = $boxes; |
| 185 | |
| 186 | echo "<tr><td bgcolor=\"$color[4]\"> </td></tr></table>\n"; |
| 187 | |
| 188 | /** UNSUBSCRIBE FOLDERS **/ |
| 189 | echo "<TABLE WIDTH=70% COLS=2 ALIGN=CENTER cellpadding=2 cellspacing=1 border=0>\n"; |
| 190 | echo "<TR><TD BGCOLOR=\"$color[9]\" ALIGN=CENTER colspan=2><B>"; |
| 191 | echo _("Unsubscribe") . "/" . _("Subscribe"); |
| 192 | echo "</B></TD></TR>\n"; |
| 193 | echo "<TR><TD BGCOLOR=\"$color[0]\" width=50% ALIGN=CENTER>\n"; |
| 194 | if ($count_special_folders < count($boxes)) { |
| 195 | echo "<FORM ACTION=\"folders_subscribe.php?method=unsub\" METHOD=\"POST\">\n"; |
| 196 | echo "<TT><SELECT NAME=mailbox[] multiple size=8>\n"; |
| 197 | for ($i = 0; $i < count($boxes); $i++) { |
| 198 | $use_folder = true; |
| 199 | if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && |
| 200 | ($boxes[$i]["unformatted"] != $trash_folder) && |
| 201 | ($boxes[$i]["unformatted"] != $sent_folder)) |
| 202 | { |
| 203 | $box = $boxes[$i]["unformatted-dm"]; |
| 204 | $box2 = str_replace(' ', ' ', $boxes[$i]["unformatted-disp"]); |
| 205 | echo " <OPTION VALUE=\"$box\">$box2\n"; |
| 206 | } |
| 207 | } |
| 208 | echo "</SELECT></TT><br>\n"; |
| 209 | echo "<INPUT TYPE=SUBMIT VALUE=\""; |
| 210 | echo _("Unsubscribe"); |
| 211 | echo "\">\n"; |
| 212 | echo "</FORM></TD>\n"; |
| 213 | } else { |
| 214 | echo _("No folders were found to unsubscribe from!") . "</td>"; |
| 215 | } |
| 216 | $boxes_sub = $boxes; |
| 217 | |
| 218 | /** SUBSCRIBE TO FOLDERS **/ |
| 219 | echo "<TD BGCOLOR=\"$color[0]\" widtn=50% ALIGN=CENTER>"; |
| 220 | $imap_stream = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 1); |
| 221 | $boxes_all = sqimap_mailbox_list_all ($imap_stream); |
| 222 | |
| 223 | $box = ""; |
| 224 | $box2 = ""; |
| 225 | for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { |
| 226 | $use_folder = true; |
| 227 | for ($p = 0; $p < count ($boxes); $p++) { |
| 228 | if ($boxes_all[$i]["unformatted"] == $boxes[$p]["unformatted"]) { |
| 229 | $use_folder = false; |
| 230 | continue; |
| 231 | } else if ($boxes_all[$i]["unformatted-dm"] == $folder_prefix) { |
| 232 | $use_folder = false; |
| 233 | } |
| 234 | } |
| 235 | if ($use_folder == true) { |
| 236 | $box[$q] = $boxes_all[$i]["unformatted-dm"]; |
| 237 | $box2[$q] = $boxes_all[$i]["unformatted-disp"]; |
| 238 | $q++; |
| 239 | } |
| 240 | } |
| 241 | sqimap_logout($imap_stream); |
| 242 | |
| 243 | if ($box && $box2) { |
| 244 | echo "<FORM ACTION=\"folders_subscribe.php?method=sub\" METHOD=\"POST\">\n"; |
| 245 | echo "<tt><select name=mailbox[] multiple size=8>"; |
| 246 | |
| 247 | for ($q = 0; $q < count($box); $q++) { |
| 248 | echo " <OPTION VALUE=\"$box[$q]\">".$box2[$q]."\n"; |
| 249 | } |
| 250 | echo "</select></tt><br>"; |
| 251 | echo "<INPUT TYPE=SUBMIT VALUE=\"". _("Subscribe") . "\">\n"; |
| 252 | echo "</FORM></TD></TR></TABLE><BR>\n"; |
| 253 | } else { |
| 254 | echo _("No folders were found to subscribe to!") . "</td></tr></table>"; |
| 255 | } |
| 256 | ?> |
| 257 | |
| 258 | |
| 259 | <?php do_hook("folders_bottom"); ?> |
| 260 | |
| 261 | |
| 262 | </td></tr> |
| 263 | </table> |
| 264 | |
| 265 | </td></tr> |
| 266 | </table> |
| 267 | |
| 268 | <?php |
| 269 | sqimap_logout($imapConnection); |
| 270 | ?> |
| 271 | |
| 272 | </body></html> |