I believe everything is compatable with all IMAP servers now
[squirrelmail.git] / src / folders_rename_do.php
1 <?
2 include("../config/config.php");
3 include("../functions/strings.php");
4 include("../functions/page_header.php");
5 include("../functions/imap.php");
6 include("../functions/mailbox.php");
7
8 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
9 $dm = findMailboxDelimeter($imapConnection);
10
11 if (strpos($orig, $dm))
12 $old_dir = substr($orig, 0, strrpos($orig, $dm));
13 else
14 $old_dir = "";
15
16 if ($old_dir != "")
17 $newone = "$old_dir$dm$new_name";
18 else
19 $newone = "$new_name";
20
21 fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\n");
22 $data = imapReadData($imapConnection, ".", true, $a, $b);
23
24 /* fputs ($imapConnection, ". RENAME \"$old_name\" \"$mailbox\"\n";
25
26 selectMailbox($imapConnection, $orig, $numMessages);
27 getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
28
29 $mailbox = "$subfolder.$new_name";
30 $old_name = substr($orig, strrpos($orig, ".")+1, strlen($orig));
31 $old_parent = substr($orig, 0, strrpos($orig, "."));
32
33 for ($i = 0; $i < count($boxesUnformatted); $i++) {
34 if (substr($boxesUnformatted[$i], 0, strlen($orig)) == $orig) {
35 $after = substr($boxesUnformatted[$i], strlen($orig)+1, strlen($boxesUnformatted[$i]));
36 selectMailbox($imapConnection, $boxesUnformatted[$i], $numMessages);
37 if (strlen($after) > 0) {
38 createFolder($imapConnection, "$mailbox.$after");
39 if ($numMessages > 0)
40 $success = copyMessages($imapConnection, 1, $numMessages, "$mailbox.$after");
41 else
42 $success = true;
43
44 if ($success == true)
45 removeFolder($imapConnection, "$boxesUnformatted[$i]");
46 }
47 else {
48 createFolder($imapConnection, "$mailbox");
49 if ($numMessages > 0)
50 $success = copyMessages($imapConnection, 1, $numMessages, "$mailbox");
51 else
52 $success = true;
53
54 if ($success == true)
55 removeFolder($imapConnection, "$boxesUnformatted[$i]");
56 }
57 }
58 }
59 */
60 /** Log out this session **/
61 fputs($imapConnection, "1 logout");
62
63 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
64 echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>Return</A>";
65 echo "</BODY></HTML>";
66 ?>
67
68