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