- added a bunch of sqimap_logout's where none existed
[squirrelmail.git] / src / folders_rename_do.php
CommitLineData
59177427 1<?php
ef870322 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>";
2a32fc83 49 session_start();
50
d068c0ec 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");
be69e508 59
d3cdb279 60 include("../src/load_prefs.php");
61
813eba2f 62 $dm = sqimap_get_delimiter($imapConnection);
d92b6f31 63
64 if (strpos($orig, $dm))
65 $old_dir = substr($orig, 0, strrpos($orig, $dm));
66 else
67 $old_dir = "";
68
69 if ($old_dir != "")
70 $newone = "$old_dir$dm$new_name";
71 else
72 $newone = "$new_name";
73
d7092926 74 $orig = stripslashes($orig);
75 $newone = stripslashes($newone);
76
d92b6f31 77 fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\n");
813eba2f 78 $data = sqimap_read_data($imapConnection, ".", true, $a, $b);
d92b6f31 79
f16d469a 80 // Renaming a folder doesn't renames the folder but leaves you unsubscribed
81 // at least on Cyrus IMAP servers.
693ccbc9 82 if ($isfolder) {
83 $newone = $newone.$dm;
84 $orig = $orig.$dm;
85 }
86
87 sqimap_unsubscribe($imapConnection, $orig);
88 sqimap_subscribe($imapConnection, $newone);
d92b6f31 89
be69e508 90 /** Log out this session **/
693ccbc9 91 sqimap_logout($imapConnection);
1195c340 92 $location = get_location();
93 header ("Location: $location/folders.php?success=rename");
94 sqimap_logout($imapConnection);
95 /*
d7092926 96 displayPageHeader($color, "None");
97 echo "<BR><BR><BR><CENTER><B>";
98 echo _("Folder Renamed!");
99 echo "</B><BR><BR>";
100 echo _("The folder has been successfully renamed.");
9f2215a1 101 echo "<BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>";
d7092926 102 echo _("Click here");
103 echo "</A> ";
104 echo _("to continue.");
105 echo "</CENTER>";
106
107 echo "</BODY></HTML>";
1195c340 108 */
be69e508 109?>