Uses the brand new configuration directive email_address to set the
[squirrelmail.git] / src / folders_delete.php
CommitLineData
b40316f9 1<?
2 include("../config/config.php");
3 include("../functions/strings.php");
4 include("../functions/page_header.php");
5 include("../functions/imap.php");
7ce342dc 6 include("../functions/array.php");
b40316f9 7
d3cdb279 8 include("../src/load_prefs.php");
9
aff57ea5 10 echo "<HTML>";
11 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
91f999f6 12 displayPageHeader($color, "None");
13
813eba2f 14 $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
15 $boxes = sqimap_mailbox_list ($imapConnection);
16 $dm = sqimap_get_delimiter($imapConnection);
d92b6f31 17
d92b6f31 18 /** lets see if we CAN move folders to the trash.. otherwise, just delete them **/
813eba2f 19 for ($i = 0; $i < count($boxes[$i]["unformatted"]); $i++) {
20 if ($boxes[$i]["unformatted"] == $trash_folder) {
21 $can_move_to_trash = true;
22 for ($i = 0; $i < count($tmpflags); $i++) {
23 if (strtolower($tmpflags[$i]) == "noinferiors")
24 $can_move_to_trash = false;
25 }
26 }
d92b6f31 27 }
54e3c1d8 28
29 /** Lets start removing the folders and messages **/
d92b6f31 30 if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/
54e3c1d8 31 /** Creates the subfolders under $trash_folder **/
7ce342dc 32 for ($i = 0; $i < count($boxes); $i++) {
813eba2f 33 if (($boxes[$i]["unformatted"] == $mailbox) ||
34 (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
35 $folderWithoutINBOX = getFolderNameMinusINBOX($boxes[$i]["unformatted"], $dm);
36 $flags = getMailboxFlags($imapConnection, $boxes[$i]["raw"]);
d92b6f31 37 for ($b = 0; $b < count($flags); $b++) {
38 $type = $flags[$b];
39 }
40 createFolder($imapConnection, "$trash_folder" . $dm . "$folderWithoutINBOX", $type);
54e3c1d8 41 }
42 }
7ce342dc 43 for ($i = 0; $i < count($boxes); $i++) {
813eba2f 44 if (($boxes[$i]["unformatted"] == $mailbox) ||
45 (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
46 sqimap_mailbox_create($imapConnection, $boxes[$i]["unformatted"], $numMessages);
47 $folder = $boxes[$i]["unformatted"];
54e3c1d8 48
49 if ($numMessages > 0)
813eba2f 50 $success = sqimap_messages_copy($imapConnection, 1, $folder);
54e3c1d8 51 else
52 $success = true;
53
54 if ($success == true)
813eba2f 55 sqimap_mailbox_delete($imapConnection, $boxes[$i]["unformatted"]);
54e3c1d8 56 }
57 }
d92b6f31 58 } else { /** if they do NOT wish to move messages to the trash (or cannot)**/
59 fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
813eba2f 60 $data = sqimap_read_data($imapConnection, "1", false, $response, $message);
d92b6f31 61 while (substr($data[0], strpos($data[0], " ")+1, 4) == "LIST") {
7ce342dc 62 for ($i = 0; $i < count($boxes); $i++) {
813eba2f 63 if (($boxes[$i]["unformatted"] == $mailbox) ||
64 (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
65 sqimap_mailbox_delete($imapConnection, $boxes[$i]["unformatted"], $dm);
d92b6f31 66 }
54e3c1d8 67 }
d92b6f31 68 fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
813eba2f 69 $data = sqimap_read_data($imapConnection , "1", false, $response, $message);
54e3c1d8 70 }
8c7dfc99 71 }
b40316f9 72
54e3c1d8 73 /** Log out this session **/
8c7dfc99 74 fputs($imapConnection, "1 logout");
b40316f9 75
91f999f6 76 echo "<FONT FACE=\"Arial,Helvetica\">";
aff57ea5 77 echo "<BR><BR><BR><CENTER><B>";
78 echo _("Folder Deleted!");
79 echo "</B><BR><BR>";
80 echo _("The folder has been successfully deleted.");
bd8bf491 81 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
aff57ea5 82 echo _("Click here");
bd8bf491 83 echo "</A> ";
aff57ea5 84 echo _("to continue.");
91f999f6 85 echo "</CENTER></FONT>";
86
f8f9bed9 87 echo "</BODY></HTML>";
b40316f9 88?>