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