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 if (!isset($config_php))
14 include("../config/config.php");
15 if (!isset($strings_php))
16 include("../functions/strings.php");
17 if (!isset($page_header_php))
18 include("../functions/page_header.php");
19 if (!isset($display_messages_php))
20 include("../functions/display_messages.php");
21 if (!isset($imap_php))
22 include("../functions/imap.php");
24 include("../src/load_prefs.php");
26 function putSelectedMessagesIntoString($msg) {
31 // If they have selected nothing msg is size one still, but will
32 // be an infinite loop because we never increment j. so check to
33 // see if msg[0] is set or not to fix this.
34 while (($j < count($msg)) && ($msg[0])) {
36 if ($firstLoop != true)
37 $selectedMessages .= "&";
41 $selectedMessages .= "selMsg[$j]=$msg[$i]";
49 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
50 sqimap_mailbox_select($imapConnection, $mailbox);
52 // If the delete button was pressed, the moveButton variable will not be set.
54 if (is_array($msg) == 1) {
55 // Marks the selected messages ad 'Deleted'
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_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
69 sqimap_mailbox_expunge($imapConnection, $mailbox);
71 $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);
80 } else { // Move messages
81 // lets check to see if they selected any messages
82 if (is_array($msg) == 1) {
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)) {
90 /** check if they would like to move it to the trash folder or not */
91 sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
92 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
97 if ($auto_expunge == true)
98 sqimap_mailbox_expunge($imapConnection, $mailbox);
100 $location = get_location();
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);
111 // Log out this session
112 sqimap_logout($imapConnection);