Update mailto support
[squirrelmail.git] / src / folders_rename_do.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * folders_rename_do.php
5 *
76911253 6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
1c52ba77 9 * Does the actual renaming of files on the IMAP server.
35586184 10 * Called from the folders.php
11 *
12 * $Id$
8f6f9ba5 13 * @package squirrelmail
35586184 14 */
15
8f6f9ba5 16/** Path for SquirrelMail required files. */
86725763 17define('SM_PATH','../');
18
19/* SquirrelMail required files. */
08185f2a 20require_once(SM_PATH . 'include/validate.php');
8650e9e1 21require_once(SM_PATH . 'functions/global.php');
86725763 22require_once(SM_PATH . 'functions/imap.php');
b7f83b61 23require_once(SM_PATH . 'functions/display_messages.php');
5bdd7223 24
a32985a5 25/* globals */
1e12d1ff 26sqgetGlobalVar('key', $key, SQ_COOKIE);
27sqgetGlobalVar('username', $username, SQ_SESSION);
28sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
29sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION);
30sqgetGlobalVar('orig', $orig, SQ_POST);
31sqgetGlobalVar('old_name', $old_name, SQ_POST);
32sqgetGlobalVar('new_name', $new_name, SQ_POST);
a32985a5 33/* end globals */
08185f2a 34
c6ee68f5 35$new_name = trim($new_name);
36
b7f83b61 37if (substr_count($new_name, '"') || substr_count($new_name, "\\") ||
38 substr_count($new_name, $delimiter) || ($new_name == '')) {
39 displayPageHeader($color, 'None');
40
41 plain_error_message(_("Illegal folder name. Please select a different name.").
42 '<BR><A HREF="../src/folders.php">'._("Click here to go back").'</A>.', $color);
43
44 exit;
45}
46
e429f014 47$orig = imap_utf7_encode_local($orig);
48$old_name = imap_utf7_encode_local($old_name);
49$new_name = imap_utf7_encode_local($new_name);
50
1c52ba77 51if ($old_name <> $new_name) {
5bdd7223 52
1c52ba77 53 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
ef870322 54
1c52ba77 55 if (strpos($orig, $delimiter)) {
56 $old_dir = substr($orig, 0, strrpos($orig, $delimiter));
57 } else {
58 $old_dir = '';
59 }
d92b6f31 60
1c52ba77 61 if ($old_dir != '') {
62 $newone = $old_dir . $delimiter . $new_name;
63 } else {
64 $newone = $new_name;
65 }
d92b6f31 66
b7f83b61 67 // Renaming a folder doesn't rename the folder but leaves you unsubscribed
1c52ba77 68 // at least on Cyrus IMAP servers.
69 if (isset($isfolder)) {
70 $newone = $newone.$delimiter;
71 $orig = $orig.$delimiter;
72 }
73 sqimap_mailbox_rename( $imapConnection, $orig, $newone );
d92b6f31 74
1c52ba77 75 // Log out this session
76 sqimap_logout($imapConnection);
d92b6f31 77
1c52ba77 78}
b7f83b61 79
80header ('Location: ' . get_location() . '/folders.php?success=rename');
81
525b7ae6 82?>