Added minimum GNU License
[squirrelmail.git] / src / folders_rename_do.php
1 <?php
2 /**
3 ** folders_rename_do.php
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** Does the actual renaming of files on the IMAP server.
9 ** Called from the folders.php
10 **/
11
12 session_start();
13
14 if (!isset($config_php))
15 include("../config/config.php");
16 if (!isset($strings_php))
17 include("../functions/strings.php");
18 if (!isset($page_header_php))
19 include("../functions/page_header.php");
20 if (!isset($imap_php))
21 include("../functions/imap.php");
22 if (!isset($display_messages_php))
23 include("../functions/display_messages.php");
24
25 include("../src/load_prefs.php");
26
27 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
28 $dm = sqimap_get_delimiter($imapConnection);
29
30 if ($method == "sub") {
31 $mailbox = trim($mailbox);
32 sqimap_subscribe ($imapConnection, $mailbox);
33 } else {
34 sqimap_unsubscribe ($imapConnection, $mailbox);
35 }
36
37 displayPageHeader($color, "None");
38 echo "<BR><BR><BR><CENTER><B>";
39 if ($method == "sub") {
40 echo _("Subscribed Successfully!");
41 echo "</B><BR><BR>";
42 echo _("You have been successfully subscribed.");
43 } else {
44 echo _("Unsubscribed Successfully!");
45 echo "</B><BR><BR>";
46 echo _("You have been successfully unsubscribed.");
47 }
48 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
49 session_start();
50
51 if (!isset($config_php))
52 include("../config/config.php");
53 if (!isset($strings_php))
54 include("../functions/strings.php");
55 if (!isset($page_header_php))
56 include("../functions/page_header.php");
57 if (!isset($imap_php))
58 include("../functions/imap.php");
59
60 include("../src/load_prefs.php");
61
62 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
63 $dm = sqimap_get_delimiter($imapConnection);
64
65 if (strpos($orig, $dm))
66 $old_dir = substr($orig, 0, strrpos($orig, $dm));
67 else
68 $old_dir = "";
69
70 if ($old_dir != "")
71 $newone = "$old_dir$dm$new_name";
72 else
73 $newone = "$new_name";
74
75 $orig = stripslashes($orig);
76 $newone = stripslashes($newone);
77
78 fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\n");
79 $data = sqimap_read_data($imapConnection, ".", true, $a, $b);
80
81 // Renaming a folder doesn't renames the folder but leaves you unsubscribed
82 // at least on Cyrus IMAP servers.
83 if ($isfolder) {
84 $newone = $newone.$dm;
85 $orig = $orig.$dm;
86 }
87
88 sqimap_unsubscribe($imapConnection, $orig);
89 sqimap_subscribe($imapConnection, $newone);
90
91 /** Log out this session **/
92 sqimap_logout($imapConnection);
93
94 displayPageHeader($color, "None");
95 echo "<BR><BR><BR><CENTER><B>";
96 echo _("Folder Renamed!");
97 echo "</B><BR><BR>";
98 echo _("The folder has been successfully renamed.");
99 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
100 echo _("Click here");
101 echo "</A> ";
102 echo _("to continue.");
103 echo "</CENTER>";
104
105 echo "</BODY></HTML>";
106 ?>