Lots of little UI tweaks and some handsome borders in the Options and Folder areas.
[squirrelmail.git] / src / folders_delete.php
CommitLineData
59177427 1<?php
ef870322 2 /**
3 ** folders_delete.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 ** Deltes folders from the IMAP server.
9 ** Called from the folders.php
245a6892 10 **
11 ** $Id$
ef870322 12 **/
13
f740c049 14 include('../src/validate.php');
f740c049 15 include("../functions/page_header.php");
16 include("../functions/imap.php");
17 include("../functions/array.php");
18 include("../functions/tree.php");
19 include("../src/load_prefs.php");
2a32fc83 20
97dd6a62 21 /*
22 * Incoming values:
23 * $mailbox - selected mailbox from the form
24 */
25
e1469126 26 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
97dd6a62 27 $boxes = sqimap_mailbox_list ($imap_stream);
28 $dm = sqimap_get_delimiter($imap_stream);
cdee225a 29
abddc974 30 if (substr($mailbox, -1) == $dm)
31 $mailbox_no_dm = substr($mailbox, 0, strlen($mailbox) - 1);
32 else
33 $mailbox_no_dm = $mailbox;
d92b6f31 34
2c1dc652 35 /** lets see if we CAN move folders to the trash.. otherwise,
36 ** just delete them **/
b140c154 37
38 // Courier IMAP doesn't like subfolders of Trash
2c1dc652 39 if (strtolower($imap_server_type) == "courier") {
2c1dc652 40 $can_move_to_trash = false;
b140c154 41 }
42
43 // If it's already a subfolder of trash, we'll have to delete it
44 else if(eregi("^".$trash_folder.".+", $mailbox)) {
45
46 $can_move_to_trash = false;
47
48 }
49
50 // Otherwise, check if trash folder exits and support sub-folders
51 else {
2c1dc652 52 for ($i = 0; $i < count($boxes); $i++) {
53 if ($boxes[$i]["unformatted"] == $trash_folder) {
e54e0b89 54 $can_move_to_trash = !in_array('noinferiors', $boxes[$i]['flags']);
813eba2f 55 }
56 }
d92b6f31 57 }
54e3c1d8 58
97dd6a62 59 /** First create the top node in the tree **/
60 for ($i = 0;$i < count($boxes);$i++) {
abddc974 61 if (($boxes[$i]["unformatted-dm"] == $mailbox) && (strlen($boxes[$i]["unformatted-dm"]) == strlen($mailbox))) {
97dd6a62 62 $foldersTree[0]["value"] = $mailbox;
63 $foldersTree[0]["doIHaveChildren"] = false;
64 continue;
54e3c1d8 65 }
97dd6a62 66 }
67 // Now create the nodes for subfolders of the parent folder
68 // You can tell that it is a subfolder by tacking the mailbox delimiter
69 // on the end of the $mailbox string, and compare to that.
70 $j = 0;
71 for ($i = 0;$i < count($boxes);$i++) {
abddc974 72 if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox_no_dm . $dm)) == ($mailbox_no_dm . $dm)) {
abddc974 73 addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
54e3c1d8 74 }
8c7dfc99 75 }
abddc974 76// simpleWalkTreePre(0, $foldersTree);
b40316f9 77
97dd6a62 78 /** Lets start removing the folders and messages **/
79 if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/
80 walkTreeInPostOrderCreatingFoldersUnderTrash(0, $imap_stream, $foldersTree, $dm, $mailbox);
81 walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
82 } else { /** if they do NOT wish to move messages to the trash (or cannot)**/
83 walkTreeInPreOrderDeleteFolders(0, $imap_stream, $foldersTree);
84 }
85
54e3c1d8 86 /** Log out this session **/
97dd6a62 87 sqimap_logout($imap_stream);
b40316f9 88
1195c340 89 $location = get_location();
90 header ("Location: $location/folders.php?success=delete");
91 /*
aff57ea5 92 echo "<BR><BR><BR><CENTER><B>";
93 echo _("Folder Deleted!");
94 echo "</B><BR><BR>";
95 echo _("The folder has been successfully deleted.");
9f2215a1 96 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
aff57ea5 97 echo _("Click here");
bd8bf491 98 echo "</A> ";
aff57ea5 99 echo _("to continue.");
aae41ae9 100 echo "</CENTER>";
91f999f6 101
f8f9bed9 102 echo "</BODY></HTML>";
1195c340 103 */
b40316f9 104?>