6 * Copyright (c) 1999-2002 The SquirrelMail Project 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 /*****************************************************************/
15 /*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
16 /*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
17 /*** + Base level indent should begin at left margin, as ***/
18 /*** the require_once below looks. ***/
19 /*** + All identation should consist of four space blocks ***/
20 /*** + Tab characters are evil. ***/
21 /*** + all comments should use "slash-star ... star-slash" ***/
22 /*** style -- no pound characters, no slash-slash style ***/
23 /*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
24 /*** ALWAYS USE { AND } CHARACTERS!!! ***/
25 /*** + Please use ' instead of ", when possible. Note " ***/
26 /*** should always be used in _( ) function calls. ***/
27 /*** Thank you for your help making the SM code more readable. ***/
28 /*****************************************************************/
30 require_once('../src/validate.php');
31 require_once('../functions/display_messages.php');
32 require_once('../functions/imap.php');
34 function putSelectedMessagesIntoString($msg) {
39 // If they have selected nothing msg is size one still, but will
40 // be an infinite loop because we never increment j. so check to
41 // see if msg[0] is set or not to fix this.
42 while (($j < count($msg)) && ($msg[0])) {
44 if ($firstLoop != true)
45 $selectedMessages .= "&";
49 $selectedMessages .= "selMsg[$j]=$msg[$i]";
57 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
58 sqimap_mailbox_select($imapConnection, $mailbox);
60 // expunge-on-demand if user isn't using move_to_trash or auto_expunge
61 if(isset($expungeButton)) {
62 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
63 $location = get_location();
65 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
67 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
69 // undelete messages if user isn't using move_to_trash or auto_expunge
70 elseif(isset($undeleteButton)) {
71 if (is_array($msg) == 1) {
72 // Removes \Deleted flag from selected messages
76 // If they have selected nothing msg is size one still, but will be an infinite
77 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
78 while ($j < count($msg)) {
80 sqimap_messages_remove_flag ($imapConnection, $msg[$i], $msg[$i], "Deleted");
85 $location = get_location();
88 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
90 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
92 displayPageHeader($color, $mailbox);
93 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
96 // If the delete button was pressed, the moveButton variable will not be set.
97 elseif (!isset($moveButton)) {
98 if (is_array($msg) == 1) {
99 // Marks the selected messages as 'Deleted'
103 // If they have selected nothing msg is size one still, but will be an infinite
104 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
105 while ($j < count($msg)) {
106 if (isset($msg[$i])) {
107 if (isset($markRead)) {
108 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
109 } else if (isset($markUnread)) {
110 sqimap_messages_remove_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
112 sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
119 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
121 $location = get_location();
122 if (isset($where) && isset($what))
123 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
125 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
127 displayPageHeader($color, $mailbox);
128 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
130 } else { // Move messages
131 // lets check to see if they selected any messages
132 if (is_array($msg) == 1) {
136 // If they have selected nothing msg is size one still, but will be an infinite
137 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
138 while ($j < count($msg)) {
139 if (isset($msg[$i])) {
140 /** check if they would like to move it to the trash folder or not */
141 sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
142 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
147 if ($auto_expunge == true)
148 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
150 $location = get_location();
151 if (isset($where) && isset($what))
152 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&what=".urlencode($what)."&where=".urlencode($where));
154 header ("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=". urlencode($mailbox));
156 displayPageHeader($color, $mailbox);
157 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
161 // Log out this session
162 sqimap_logout($imapConnection);