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