da8d6707b87e3dbeb267cafdb9206148d166ca76
[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 sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
50 $j++;
51 }
52 $i++;
53 }
54 messages_deleted_message($mailbox, $sort, $startMessage, $color);
55 } else {
56 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
57 }
58 } else { // Move messages
59 displayPageHeader($color, $mailbox);
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 */
70 $success = sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
71 if ($success == true)
72 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
73 $j++;
74 }
75 $i++;
76 }
77 if ($auto_expunge == true)
78 sqimap_mailbox_expunge($imapConnection, $mailbox, $numMessages);
79
80 messages_moved_message($mailbox, $sort, $startMessage, $color);
81 } else {
82 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
83 }
84 }
85
86 // Log out this session
87 sqimap_logout($imapConnection);
88
89 ?>
90 </BODY></HTML>