Small fix to folder renaming.
[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, 0);
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 // Renaming a folder doesn't renames the folder but leaves you unsubscribed
27 // at least on Cyrus IMAP servers.
28 fputs ($imapConnection, "sub SUBSCRIBE \"$newone\"\n");
29 $data = imapReadData($imapConnection, "sub", true, $a, $b);
30
31 /** Log out this session **/
32 fputs($imapConnection, "1 logout");
33
34 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
35 echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
36 echo _("Return");
37 echo "</A>";
38 echo "</BODY></HTML>";
39 ?>
40
41