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 require_once('../src/validate.php');
14 require_once('../functions/display_messages.php');
15 require_once('../functions/imap.php');
17 function putSelectedMessagesIntoString($msg) {
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.
25 while (($j < count($msg)) && ($msg[0])) {
27 if ($firstLoop != true)
28 $selectedMessages .= "&";
32 $selectedMessages .= "selMsg[$j]=$msg[$i]";
40 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
41 sqimap_mailbox_select($imapConnection, $mailbox);
43 // expunge-on-demand if user isn't using move_to_trash or auto_expunge
44 if(isset($expungeButton)) {
45 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
46 $location = get_location();
48 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
50 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
52 // undelete messages if user isn't using move_to_trash or auto_expunge
53 elseif(isset($undeleteButton)) {
54 if (is_array($msg) == 1) {
55 // Removes \Deleted flag from selected messages
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)) {
63 sqimap_messages_remove_flag ($imapConnection, $msg[$i], $msg[$i], "Deleted");
68 $location = get_location();
71 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
73 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
75 displayPageHeader($color, $mailbox);
76 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
79 // If the delete button was pressed, the moveButton variable will not be set.
80 elseif (!isset($moveButton)) {
81 if (is_array($msg) == 1) {
82 // Marks the selected messages as 'Deleted'
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)) {
89 if (isset($msg[$i])) {
90 if (isset($markRead)) {
91 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
92 } else if (isset($markUnread)) {
93 sqimap_messages_remove_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
95 sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
102 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
104 $location = get_location();
105 if (isset($where) && isset($what))
106 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
108 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
110 displayPageHeader($color, $mailbox);
111 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
113 } else { // Move messages
114 // lets check to see if they selected any messages
115 if (is_array($msg) == 1) {
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)) {
122 if (isset($msg[$i])) {
123 /** check if they would like to move it to the trash folder or not */
124 sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
125 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
130 if ($auto_expunge == true)
131 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
133 $location = get_location();
134 if (isset($where) && isset($what))
135 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
137 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
139 displayPageHeader($color, $mailbox);
140 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
144 // Log out this session
145 sqimap_logout($imapConnection);