6 ** Copyright (c) 1999-2001 The SquirrelMail development team
7 ** Licensed under the GNU GPL. For full terms see the file COPYING.
9 ** Enables message moving between folders on the IMAP server.
14 require_once('../src/validate.php');
15 require_once('../functions/display_messages.php');
16 require_once('../functions/imap.php');
18 function putSelectedMessagesIntoString($msg) {
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])) {
28 if ($firstLoop != true)
29 $selectedMessages .= "&";
33 $selectedMessages .= "selMsg[$j]=$msg[$i]";
41 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
42 sqimap_mailbox_select($imapConnection, $mailbox);
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();
49 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
51 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
53 // undelete messages if user isn't using move_to_trash or auto_expunge
54 elseif(isset($undeleteButton)) {
55 if (is_array($msg) == 1) {
56 // Removes \Deleted flag from selected messages
60 // If they have selected nothing msg is size one still, but will be an infinite
61 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
62 while ($j < count($msg)) {
64 sqimap_messages_remove_flag ($imapConnection, $msg[$i], $msg[$i], "Deleted");
69 $location = get_location();
72 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
74 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
76 displayPageHeader($color, $mailbox);
77 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
80 // If the delete button was pressed, the moveButton variable will not be set.
81 elseif (!isset($moveButton)) {
82 if (is_array($msg) == 1) {
83 // Marks the selected messages as 'Deleted'
87 // If they have selected nothing msg is size one still, but will be an infinite
88 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
89 while ($j < count($msg)) {
90 if (isset($msg[$i])) {
91 if (isset($markRead)) {
92 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
93 } else if (isset($markUnread)) {
94 sqimap_messages_remove_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
96 sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
103 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
105 $location = get_location();
106 if (isset($where) && isset($what))
107 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
109 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
111 displayPageHeader($color, $mailbox);
112 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
114 } else { // Move messages
115 // lets check to see if they selected any messages
116 if (is_array($msg) == 1) {
120 // If they have selected nothing msg is size one still, but will be an infinite
121 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
122 while ($j < count($msg)) {
123 if (isset($msg[$i])) {
124 /** check if they would like to move it to the trash folder or not */
125 sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
126 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
131 if ($auto_expunge == true)
132 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
134 $location = get_location();
135 if (isset($where) && isset($what))
136 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
138 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
140 displayPageHeader($color, $mailbox);
141 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
145 // Log out this session
146 sqimap_logout($imapConnection);