No longer requires both body and subject. One of them is enough.
[squirrelmail.git] / src / folders_rename_do.php
1 <?php
2 session_start();
3
4 if (!isset($config_php))
5 include("../config/config.php");
6 if (!isset($strings_php))
7 include("../functions/strings.php");
8 if (!isset($page_header_php))
9 include("../functions/page_header.php");
10 if (!isset($imap_php))
11 include("../functions/imap.php");
12
13 include("../src/load_prefs.php");
14
15 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
16 $dm = sqimap_get_delimiter($imapConnection);
17
18 if (strpos($orig, $dm))
19 $old_dir = substr($orig, 0, strrpos($orig, $dm));
20 else
21 $old_dir = "";
22
23 if ($old_dir != "")
24 $newone = "$old_dir$dm$new_name";
25 else
26 $newone = "$new_name";
27
28 $orig = stripslashes($orig);
29 $newone = stripslashes($newone);
30
31 fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\n");
32 $data = sqimap_read_data($imapConnection, ".", true, $a, $b);
33
34 // Renaming a folder doesn't renames the folder but leaves you unsubscribed
35 // at least on Cyrus IMAP servers.
36 if ($isfolder) {
37 $newone = $newone.$dm;
38 $orig = $orig.$dm;
39 }
40
41 sqimap_unsubscribe($imapConnection, $orig);
42 sqimap_subscribe($imapConnection, $newone);
43
44 /** Log out this session **/
45 sqimap_logout($imapConnection);
46
47 displayPageHeader($color, "None");
48 echo "<BR><BR><BR><CENTER><B>";
49 echo _("Folder Renamed!");
50 echo "</B><BR><BR>";
51 echo _("The folder has been successfully renamed.");
52 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
53 echo _("Click here");
54 echo "</A> ";
55 echo _("to continue.");
56 echo "</CENTER>";
57
58 echo "</BODY></HTML>";
59 ?>