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