I believe everything is compatable with all IMAP servers now
[squirrelmail.git] / src / move_messages.php
CommitLineData
b40316f9 1<?
2 include("../config/config.php");
3 include("../functions/mailbox.php");
4 include("../functions/strings.php");
5 include("../functions/page_header.php");
6 include("../functions/display_messages.php");
05207a68 7 include("../functions/imap.php");
b40316f9 8
f8f9bed9 9 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
213b188d 10
dd88d31f 11 function putSelectedMessagesIntoString($msg) {
05207a68 12 $j = 0;
13 $i = 0;
dd88d31f 14 $firstLoop = true;
2d7d3c2a 15
16 // If they have selected nothing msg is size one still, but will be an infinite
17 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
18 while (($j < count($msg)) && ($msg[0])) {
05207a68 19 if ($msg[$i]) {
dd88d31f 20 if ($firstLoop != true)
21 $selectedMessages .= "&";
22 else
23 $firstLoop = false;
24
25 $selectedMessages .= "selMsg[$j]=$msg[$i]";
26
05207a68 27 $j++;
b40316f9 28 }
05207a68 29 $i++;
b40316f9 30 }
dd88d31f 31 }
e2370222 32
dd88d31f 33 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
34
35 // switch to the mailbox, and get the number of messages in it.
36 selectMailbox($imapConnection, $mailbox, $numMessages, $imapServerAddress);
37
38 // If the delete button was pressed, the moveButton variable will not be set.
39 if (!$moveButton) {
f8f9bed9 40 displayPageHeader($color, $mailbox);
dd88d31f 41 if (is_array($msg) == 1) {
42 // Marks the selected messages ad 'Deleted'
43 $j = 0;
44 $i = 0;
2d7d3c2a 45
dd88d31f 46 // If they have selected nothing msg is size one still, but will be an infinite
47 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
48 while ($j < count($msg)) {
49 if ($msg[$i]) {
e2370222 50 echo "MSG: $msg[$i]<BR>";
de80e95e 51 deleteMessages($imapConnection, $msg[$i], $msg[$i], $numMessages, $trash_folder, $move_to_trash, $auto_expunge, $mailbox);
dd88d31f 52 $j++;
2d7d3c2a 53 }
dd88d31f 54 $i++;
2d7d3c2a 55 }
d92b6f31 56 messages_deleted_message($mailbox, $sort, $startMessage, $color);
dd88d31f 57 } else {
58 echo "<BR><BR><CENTER>No messages selected.</CENTER>";
59 }
60 } else { // Move messages
f8f9bed9 61 displayPageHeader($color, $mailbox);
dd88d31f 62 // lets check to see if they selected any messages
63 if (is_array($msg) == 1) {
64 $j = 0;
65 $i = 0;
66
67 // If they have selected nothing msg is size one still, but will be an infinite
68 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
69 while ($j < count($msg)) {
70 if ($msg[$i]) {
71 /** check if they would like to move it to the trash folder or not */
72 $success = copyMessages($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
73 if ($success == true)
74 setMessageFlag($imapConnection, $msg[$i], $msg[$i], "Deleted");
75 $j++;
76 }
77 $i++;
78 }
79 if ($auto_expunge == true)
80 expungeBox($imapConnection, $mailbox, $numMessages);
de80e95e 81
d92b6f31 82 messages_moved_message($mailbox, $sort, $startMessage, $color);
dd88d31f 83 } else {
d92b6f31 84 error_message("No messages were selected.", $mailbox, $sort, $startMessage, $color);
2d7d3c2a 85 }
b40316f9 86 }
87
b40316f9 88 // Log out this session
89 fputs($imapConnection, "1 logout");
90
2aa12d5e 91?>
aa32c5e4 92</BODY></HTML>