Remove incorrect &amp usage
[squirrelmail.git] / src / move_messages.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * move_messages.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Enables message moving between folders on the IMAP server.
10 *
11 * $Id$
12 */
ef870322 13
35586184 14require_once('../src/validate.php');
15require_once('../functions/display_messages.php');
16require_once('../functions/imap.php');
d3cdb279 17
65c3ec94 18function putSelectedMessagesIntoString($msg) {
19 $j = 0;
20 $i = 0;
21 $firstLoop = true;
22
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])) {
27 if ($msg[$i]) {
5e9e90fd 28 if ($firstLoop != true) {
29 $selectedMessages .= "&amp;";
30 } else {
31 $firstLoop = false;
32 }
dd88d31f 33
34 $selectedMessages .= "selMsg[$j]=$msg[$i]";
65c3ec94 35
05207a68 36 $j++;
65c3ec94 37 }
38 $i++;
39 }
40}
41
42$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
43sqimap_mailbox_select($imapConnection, $mailbox);
44
45// expunge-on-demand if user isn't using move_to_trash or auto_expunge
46if(isset($expungeButton)) {
47 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
48 $location = get_location();
49 if ($where && $what) {
5e9e90fd 50 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&amp;what=".urlencode($what)."&amp;where=".urlencode($where));
65c3ec94 51 } else {
5e9e90fd 52 header ("Location: $location/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=". urlencode($mailbox));
65c3ec94 53 }
54
55} elseif(isset($undeleteButton)) {
56 // undelete messages if user isn't using move_to_trash or auto_expunge
57
58 if (is_array($msg) == 1) {
59 // Removes \Deleted flag from selected messages
60 $j = 0;
61 $i = 0;
62
63 // If they have selected nothing msg is size one still, but will be an infinite
64 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
65 while ($j < count($msg)) {
f9b3e5d9 66 if ($msg[$i]) {
65c3ec94 67 sqimap_messages_remove_flag ($imapConnection, $msg[$i], $msg[$i], "Deleted");
68 $j++;
f9b3e5d9 69 }
70 $i++;
65c3ec94 71 }
72 $location = get_location();
f9b3e5d9 73
65c3ec94 74 if ($where && $what)
5e9e90fd 75 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&amp;what=".urlencode($what)."&amp;where=".urlencode($where));
65c3ec94 76 else
5e9e90fd 77 header ("Location: $location/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=". urlencode($mailbox));
65c3ec94 78 } else {
79 displayPageHeader($color, $mailbox);
80 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
81 }
82} elseif (!isset($moveButton)) {
83 // If the delete button was pressed, the moveButton variable will not be set.
84 if (is_array($msg) == 1) {
85 // Marks the selected messages as 'Deleted'
86 $j = 0;
87 $i = 0;
88
89 // If they have selected nothing msg is size one still, but will be an infinite
90 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
91 while ($j < count($msg)) {
23fd3c8e 92 if (isset($msg[$i])) {
65c3ec94 93 if (isset($markRead)) {
94 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
95 } else if (isset($markUnread)) {
96 sqimap_messages_remove_flag($imapConnection, $msg[$i], $msg[$i], "Seen");
97 } else {
98 sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
99 }
100 $j++;
2d7d3c2a 101 }
dd88d31f 102 $i++;
65c3ec94 103 }
104 if ($auto_expunge) {
8cf653ad 105 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
65c3ec94 106 }
107 $location = get_location();
108 if (isset($where) && isset($what)) {
5e9e90fd 109 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&amp;what=".urlencode($what)."&amp;where=".urlencode($where));
65c3ec94 110 } else {
5e9e90fd 111 header ("Location: $location/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=". urlencode($mailbox));
65c3ec94 112 }
113 } else {
114 displayPageHeader($color, $mailbox);
115 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
116 }
117} else { // Move messages
118 // lets check to see if they selected any messages
119 if (is_array($msg) == 1) {
120 $j = 0;
121 $i = 0;
122
123 // If they have selected nothing msg is size one still, but will be an infinite
124 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
125 while ($j < count($msg)) {
23fd3c8e 126 if (isset($msg[$i])) {
65c3ec94 127 /** check if they would like to move it to the trash folder or not */
128 sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
129 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
130 $j++;
dd88d31f 131 }
132 $i++;
65c3ec94 133 }
134 if ($auto_expunge == true)
8cf653ad 135 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
de80e95e 136
65c3ec94 137 $location = get_location();
138 if (isset($where) && isset($what))
5e9e90fd 139 header ("Location: $location/search.php?mailbox=".urlencode($mailbox)."&amp;what=".urlencode($what)."&amp;where=".urlencode($where));
65c3ec94 140 else
5e9e90fd 141 header ("Location: $location/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=". urlencode($mailbox));
65c3ec94 142 } else {
143 displayPageHeader($color, $mailbox);
144 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
145 }
146}
147
148// Log out this session
149sqimap_logout($imapConnection);
b40316f9 150
2aa12d5e 151?>
6332704d 152</BODY></HTML>