Rewrote IMAP functions.
[squirrelmail.git] / src / folders_rename_do.php
CommitLineData
be69e508 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
d3cdb279 8 include("../src/load_prefs.php");
9
b235d629 10 $imapConnection = loginToImapServer($username, $key, $imapServerAddress, 0);
d92b6f31 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
f16d469a 26 // Renaming a folder doesn't renames the folder but leaves you unsubscribed
27 // at least on Cyrus IMAP servers.
23fc64b3 28 fputs ($imapConnection, "sub SUBSCRIBE \"$newone\"\n");
f16d469a 29 $data = imapReadData($imapConnection, "sub", true, $a, $b);
d92b6f31 30
be69e508 31 /** Log out this session **/
32 fputs($imapConnection, "1 logout");
33
f8f9bed9 34 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
036a8a9d 35 echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
36 echo _("Return");
37 echo "</A>";
f8f9bed9 38 echo "</BODY></HTML>";
be69e508 39?>