59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * move_messages.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Enables message moving between folders on the IMAP server. |
10 | * |
11 | * $Id$ |
12 | */ |
ef870322 |
13 | |
35586184 |
14 | require_once('../src/validate.php'); |
15 | require_once('../functions/display_messages.php'); |
16 | require_once('../functions/imap.php'); |
d3cdb279 |
17 | |
65c3ec94 |
18 | function putSelectedMessagesIntoString($msg) { |
19 | $j = 0; |
20 | $i = 0; |
21 | $firstLoop = true; |
22 | |
23 | // If they have selected nothing msg is size one still, but will |
24 | // be an infinite loop because we never increment j. so check to |
25 | // see if msg[0] is set or not to fix this. |
26 | while (($j < count($msg)) && ($msg[0])) { |
27 | if ($msg[$i]) { |
dd88d31f |
28 | if ($firstLoop != true) |
65c3ec94 |
29 | $selectedMessages .= "&"; |
dd88d31f |
30 | else |
65c3ec94 |
31 | $firstLoop = false; |
dd88d31f |
32 | |
33 | $selectedMessages .= "selMsg[$j]=$msg[$i]"; |
65c3ec94 |
34 | |
05207a68 |
35 | $j++; |
65c3ec94 |
36 | } |
37 | $i++; |
38 | } |
39 | } |
40 | |
41 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
42 | sqimap_mailbox_select($imapConnection, $mailbox); |
43 | |
44 | // expunge-on-demand if user isn't using move_to_trash or auto_expunge |
45 | if(isset($expungeButton)) { |
46 | sqimap_mailbox_expunge($imapConnection, $mailbox, true); |
47 | $location = get_location(); |
48 | if ($where && $what) { |
49 | header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where)); |
50 | } else { |
51 | header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox)); |
52 | } |
53 | |
54 | } elseif(isset($undeleteButton)) { |
55 | // undelete messages if user isn't using move_to_trash or auto_expunge |
56 | |
57 | if (is_array($msg) == 1) { |
58 | // Removes \Deleted flag from selected messages |
59 | $j = 0; |
60 | $i = 0; |
61 | |
62 | // If they have selected nothing msg is size one still, but will be an infinite |
63 | // loop because we never increment j. so check to see if msg[0] is set or not to fix this. |
64 | while ($j < count($msg)) { |
f9b3e5d9 |
65 | if ($msg[$i]) { |
65c3ec94 |
66 | sqimap_messages_remove_flag ($imapConnection, $msg[$i], $msg[$i], "Deleted"); |
67 | $j++; |
f9b3e5d9 |
68 | } |
69 | $i++; |
65c3ec94 |
70 | } |
71 | $location = get_location(); |
f9b3e5d9 |
72 | |
65c3ec94 |
73 | if ($where && $what) |
f9b3e5d9 |
74 | header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where)); |
65c3ec94 |
75 | else |
f9b3e5d9 |
76 | header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox)); |
65c3ec94 |
77 | } else { |
78 | displayPageHeader($color, $mailbox); |
79 | error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color); |
80 | } |
81 | } elseif (!isset($moveButton)) { |
82 | // If the delete button was pressed, the moveButton variable will not be set. |
83 | if (is_array($msg) == 1) { |
84 | // Marks the selected messages as 'Deleted' |
85 | $j = 0; |
86 | $i = 0; |
87 | |
88 | // If they have selected nothing msg is size one still, but will be an infinite |
89 | // loop because we never increment j. so check to see if msg[0] is set or not to fix this. |
90 | while ($j < count($msg)) { |
23fd3c8e |
91 | if (isset($msg[$i])) { |
65c3ec94 |
92 | if (isset($markRead)) { |
93 | sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Seen"); |
94 | } else if (isset($markUnread)) { |
95 | sqimap_messages_remove_flag($imapConnection, $msg[$i], $msg[$i], "Seen"); |
96 | } else { |
97 | sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox); |
98 | } |
99 | $j++; |
2d7d3c2a |
100 | } |
dd88d31f |
101 | $i++; |
65c3ec94 |
102 | } |
103 | if ($auto_expunge) { |
8cf653ad |
104 | sqimap_mailbox_expunge($imapConnection, $mailbox, true); |
65c3ec94 |
105 | } |
106 | $location = get_location(); |
107 | if (isset($where) && isset($what)) { |
1809bad8 |
108 | header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where)); |
65c3ec94 |
109 | } else { |
1809bad8 |
110 | header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox)); |
65c3ec94 |
111 | } |
112 | } else { |
113 | displayPageHeader($color, $mailbox); |
114 | error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color); |
115 | } |
116 | } else { // Move messages |
117 | // lets check to see if they selected any messages |
118 | if (is_array($msg) == 1) { |
119 | $j = 0; |
120 | $i = 0; |
121 | |
122 | // If they have selected nothing msg is size one still, but will be an infinite |
123 | // loop because we never increment j. so check to see if msg[0] is set or not to fix this. |
124 | while ($j < count($msg)) { |
23fd3c8e |
125 | if (isset($msg[$i])) { |
65c3ec94 |
126 | /** check if they would like to move it to the trash folder or not */ |
127 | sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox); |
128 | sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted"); |
129 | $j++; |
dd88d31f |
130 | } |
131 | $i++; |
65c3ec94 |
132 | } |
133 | if ($auto_expunge == true) |
8cf653ad |
134 | sqimap_mailbox_expunge($imapConnection, $mailbox, true); |
de80e95e |
135 | |
65c3ec94 |
136 | $location = get_location(); |
137 | if (isset($where) && isset($what)) |
1809bad8 |
138 | header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where)); |
65c3ec94 |
139 | else |
1809bad8 |
140 | header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox)); |
65c3ec94 |
141 | } else { |
142 | displayPageHeader($color, $mailbox); |
143 | error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color); |
144 | } |
145 | } |
146 | |
147 | // Log out this session |
148 | sqimap_logout($imapConnection); |
b40316f9 |
149 | |
2aa12d5e |
150 | ?> |
6332704d |
151 | </BODY></HTML> |