ae7155c4bcb526524734b4275d5457a41796810e
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 // expunge-on-demand if user isn't using move_to_trash or auto_expunge
54 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
55 $location = get_location();
57 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
59 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
61 // undelete messages if user isn't using move_to_trash or auto_expunge
62 elseif($undeleteButton) {
63 if (is_array($msg) == 1) {
64 // Removes \Deleted flag from selected messages
68 // If they have selected nothing msg is size one still, but will be an infinite
69 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
70 while ($j < count($msg)) {
72 sqimap_messages_remove_flag ($imapConnection, $msg[$i], $msg[$i], "Deleted");
77 $location = get_location();
80 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
82 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
84 displayPageHeader($color, $mailbox);
85 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
88 // If the delete button was pressed, the moveButton variable will not be set.
89 elseif (!$moveButton) {
90 if (is_array($msg) == 1) {
91 // Marks the selected messages ad 'Deleted'
95 // If they have selected nothing msg is size one still, but will be an infinite
96 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
97 while ($j < count($msg)) {
99 sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
105 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
107 $location = get_location();
109 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
111 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
113 displayPageHeader($color, $mailbox);
114 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
116 } else { // Move messages
117 // lets check to see if they selected any messages
118 if (is_array($msg) == 1) {
122 // If they have selected nothing msg is size one still, but will be an infinite
123 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
124 while ($j < count($msg)) {
126 /** check if they would like to move it to the trash folder or not */
127 sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
128 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
133 if ($auto_expunge == true)
134 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
136 $location = get_location();
138 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
140 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
142 displayPageHeader($color, $mailbox);
143 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
147 // Log out this session
148 sqimap_mailbox_close($imapConnection);
149 sqimap_logout($imapConnection);