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