5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
8 ** Enables message moving between folders on the IMAP server.
13 include('../src/validate.php');
14 include("../functions/page_header.php");
15 include("../functions/display_messages.php");
16 include("../functions/imap.php");
17 include("../src/load_prefs.php");
19 function putSelectedMessagesIntoString($msg) {
24 // If they have selected nothing msg is size one still, but will
25 // be an infinite loop because we never increment j. so check to
26 // see if msg[0] is set or not to fix this.
27 while (($j < count($msg)) && ($msg[0])) {
29 if ($firstLoop != true)
30 $selectedMessages .= "&";
34 $selectedMessages .= "selMsg[$j]=$msg[$i]";
42 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
43 sqimap_mailbox_select($imapConnection, $mailbox);
45 // expunge-on-demand if user isn't using move_to_trash or auto_expunge
46 if(isset($expungeButton)) {
47 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
48 $location = get_location();
50 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
52 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
54 // undelete messages if user isn't using move_to_trash or auto_expunge
55 elseif(isset($undeleteButton)) {
56 if (is_array($msg) == 1) {
57 // Removes \Deleted flag from selected messages
61 // If they have selected nothing msg is size one still, but will be an infinite
62 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
63 while ($j < count($msg)) {
65 sqimap_messages_remove_flag ($imapConnection, $msg[$i], $msg[$i], "Deleted");
70 $location = get_location();
73 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
75 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
77 displayPageHeader($color, $mailbox);
78 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
81 // If the delete button was pressed, the moveButton variable will not be set.
82 elseif (!isset($moveButton)) {
83 if (is_array($msg) == 1) {
84 // Marks the selected messages as 'Deleted'
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)) {
91 if (isset($msg[$i])) {
92 sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
98 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
100 $location = get_location();
101 if (isset($where) && isset($what))
102 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
104 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
106 displayPageHeader($color, $mailbox);
107 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
109 } else { // Move messages
110 // lets check to see if they selected any messages
111 if (is_array($msg) == 1) {
115 // If they have selected nothing msg is size one still, but will be an infinite
116 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
117 while ($j < count($msg)) {
118 if (isset($msg[$i])) {
119 /** check if they would like to move it to the trash folder or not */
120 sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
121 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
126 if ($auto_expunge == true)
127 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
129 $location = get_location();
130 if (isset($where) && isset($what))
131 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
133 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
135 displayPageHeader($color, $mailbox);
136 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
140 // Log out this session
141 sqimap_logout($imapConnection);