Code Cleaning
[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
17require_once('../src/validate.php');
18require_once('../functions/imap.php');
5bdd7223 19
1c52ba77 20if ($old_name <> $new_name) {
5bdd7223 21
1c52ba77 22 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
ef870322 23
1c52ba77 24 if (strpos($orig, $delimiter)) {
25 $old_dir = substr($orig, 0, strrpos($orig, $delimiter));
26 } else {
27 $old_dir = '';
28 }
d92b6f31 29
1c52ba77 30 if ($old_dir != '') {
31 $newone = $old_dir . $delimiter . $new_name;
32 } else {
33 $newone = $new_name;
34 }
d92b6f31 35
1c52ba77 36 // Renaming a folder doesn't renames the folder but leaves you unsubscribed
37 // at least on Cyrus IMAP servers.
38 if (isset($isfolder)) {
39 $newone = $newone.$delimiter;
40 $orig = $orig.$delimiter;
41 }
42 sqimap_mailbox_rename( $imapConnection, $orig, $newone );
d92b6f31 43
1c52ba77 44 // Log out this session
45 sqimap_logout($imapConnection);
d92b6f31 46
1c52ba77 47}
48header ('Location: ' . $base_uri . 'src/folders.php');
525b7ae6 49?>