added patch to allow use of sendmail instead of connecting to SMTP port
[squirrelmail.git] / src / folders_rename_do.php
CommitLineData
be69e508 1<?
2 include("../config/config.php");
3 include("../functions/strings.php");
4 include("../functions/page_header.php");
5 include("../functions/imap.php");
6 include("../functions/mailbox.php");
7
d3cdb279 8 include("../src/load_prefs.php");
9
be69e508 10 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
d92b6f31 11 $dm = findMailboxDelimeter($imapConnection);
12
13 if (strpos($orig, $dm))
14 $old_dir = substr($orig, 0, strrpos($orig, $dm));
15 else
16 $old_dir = "";
17
18 if ($old_dir != "")
19 $newone = "$old_dir$dm$new_name";
20 else
21 $newone = "$new_name";
22
23 fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\n");
24 $data = imapReadData($imapConnection, ".", true, $a, $b);
25
26/* fputs ($imapConnection, ". RENAME \"$old_name\" \"$mailbox\"\n";
27
be69e508 28 selectMailbox($imapConnection, $orig, $numMessages);
d92b6f31 29 getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw);
be69e508 30
31 $mailbox = "$subfolder.$new_name";
32 $old_name = substr($orig, strrpos($orig, ".")+1, strlen($orig));
33 $old_parent = substr($orig, 0, strrpos($orig, "."));
34
35 for ($i = 0; $i < count($boxesUnformatted); $i++) {
36 if (substr($boxesUnformatted[$i], 0, strlen($orig)) == $orig) {
37 $after = substr($boxesUnformatted[$i], strlen($orig)+1, strlen($boxesUnformatted[$i]));
38 selectMailbox($imapConnection, $boxesUnformatted[$i], $numMessages);
39 if (strlen($after) > 0) {
40 createFolder($imapConnection, "$mailbox.$after");
41 if ($numMessages > 0)
42 $success = copyMessages($imapConnection, 1, $numMessages, "$mailbox.$after");
43 else
44 $success = true;
45
46 if ($success == true)
47 removeFolder($imapConnection, "$boxesUnformatted[$i]");
48 }
49 else {
50 createFolder($imapConnection, "$mailbox");
51 if ($numMessages > 0)
52 $success = copyMessages($imapConnection, 1, $numMessages, "$mailbox");
53 else
54 $success = true;
55
56 if ($success == true)
57 removeFolder($imapConnection, "$boxesUnformatted[$i]");
58 }
59 }
60 }
d92b6f31 61*/
be69e508 62 /** Log out this session **/
63 fputs($imapConnection, "1 logout");
64
f8f9bed9 65 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
be69e508 66 echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>Return</A>";
f8f9bed9 67 echo "</BODY></HTML>";
be69e508 68?>
69
70