Converted all files in functions/ to use SM_PATH. This will break all
[squirrelmail.git] / src / folders_rename_do.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * folders_rename_do.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 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$
13 */
14
1c52ba77 15global $delimiter, $base_uri;
35586184 16
86725763 17/* Path for SquirrelMail required files. */
18define('SM_PATH','../');
19
20/* SquirrelMail required files. */
21require_once(SM_PATH . 'src/validate.php');
22require_once(SM_PATH . 'functions/imap.php');
5bdd7223 23
c6ee68f5 24$new_name = trim($new_name);
25
1c52ba77 26if ($old_name <> $new_name) {
5bdd7223 27
1c52ba77 28 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
ef870322 29
1c52ba77 30 if (strpos($orig, $delimiter)) {
31 $old_dir = substr($orig, 0, strrpos($orig, $delimiter));
32 } else {
33 $old_dir = '';
34 }
d92b6f31 35
1c52ba77 36 if ($old_dir != '') {
37 $newone = $old_dir . $delimiter . $new_name;
38 } else {
39 $newone = $new_name;
40 }
d92b6f31 41
1c52ba77 42 // Renaming a folder doesn't renames the folder but leaves you unsubscribed
43 // at least on Cyrus IMAP servers.
44 if (isset($isfolder)) {
45 $newone = $newone.$delimiter;
46 $orig = $orig.$delimiter;
47 }
48 sqimap_mailbox_rename( $imapConnection, $orig, $newone );
d92b6f31 49
1c52ba77 50 // Log out this session
51 sqimap_logout($imapConnection);
d92b6f31 52
1c52ba77 53}
54header ('Location: ' . $base_uri . 'src/folders.php');
525b7ae6 55?>