fixed renaming problems
[squirrelmail.git] / src / folders_rename_do.php
1 <?
2 if (!isset($config_php))
3 include("../config/config.php");
4 if (!isset($strings_php))
5 include("../functions/strings.php");
6 if (!isset($page_header_php))
7 include("../functions/page_header.php");
8 if (!isset($imap_php))
9 include("../functions/imap.php");
10
11 include("../src/load_prefs.php");
12
13 $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
14 $dm = sqimap_get_delimiter($imapConnection);
15
16 if (strpos($orig, $dm))
17 $old_dir = substr($orig, 0, strrpos($orig, $dm));
18 else
19 $old_dir = "";
20
21 if ($old_dir != "")
22 $newone = "$old_dir$dm$new_name";
23 else
24 $newone = "$new_name";
25
26 fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\n");
27 $data = sqimap_read_data($imapConnection, ".", true, $a, $b);
28
29 // Renaming a folder doesn't renames the folder but leaves you unsubscribed
30 // at least on Cyrus IMAP servers.
31 if ($isfolder) {
32 $newone = $newone.$dm;
33 $orig = $orig.$dm;
34 }
35
36 sqimap_unsubscribe($imapConnection, $orig);
37 sqimap_subscribe($imapConnection, $newone);
38
39 /** Log out this session **/
40 sqimap_logout($imapConnection);
41
42 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
43 echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
44 echo _("Return");
45 echo "</A>";
46 echo "</BODY></HTML>";
47 ?>