updated changelog, todo
[squirrelmail.git] / src / move_messages.php
CommitLineData
b40316f9 1<?
d068c0ec 2 if (!isset($config_php))
3 include("../config/config.php");
4 if (!isset($strings_php))
5 include("../functions/strings.php");
6 if (!isset($page_header_php))
7 include("../functions/page_header.php");
8 if (!isset($display_messages_php))
9 include("../functions/display_messages.php");
10 if (!isset($imap_php))
11 include("../functions/imap.php");
b40316f9 12
d3cdb279 13 include("../src/load_prefs.php");
14
5479d709 15// echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
213b188d 16
dd88d31f 17 function putSelectedMessagesIntoString($msg) {
05207a68 18 $j = 0;
19 $i = 0;
dd88d31f 20 $firstLoop = true;
2d7d3c2a 21
d068c0ec 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.
2d7d3c2a 25 while (($j < count($msg)) && ($msg[0])) {
05207a68 26 if ($msg[$i]) {
dd88d31f 27 if ($firstLoop != true)
28 $selectedMessages .= "&";
29 else
30 $firstLoop = false;
31
32 $selectedMessages .= "selMsg[$j]=$msg[$i]";
33
05207a68 34 $j++;
b40316f9 35 }
05207a68 36 $i++;
b40316f9 37 }
dd88d31f 38 }
e2370222 39
e1469126 40 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
813eba2f 41 sqimap_mailbox_select($imapConnection, $mailbox);
dd88d31f 42
43 // If the delete button was pressed, the moveButton variable will not be set.
44 if (!$moveButton) {
5479d709 45 // displayPageHeader($color, $mailbox);
dd88d31f 46 if (is_array($msg) == 1) {
47 // Marks the selected messages ad 'Deleted'
48 $j = 0;
49 $i = 0;
2d7d3c2a 50
dd88d31f 51 // If they have selected nothing msg is size one still, but will be an infinite
52 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
53 while ($j < count($msg)) {
54 if ($msg[$i]) {
813eba2f 55 sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
dd88d31f 56 $j++;
2d7d3c2a 57 }
dd88d31f 58 $i++;
2d7d3c2a 59 }
d2f34a3d 60 if ($auto_expunge)
61 sqimap_mailbox_expunge($imapConnection, $mailbox);
5479d709 62
63 if ($auto_forward) {
64 header ("Location: right_main.php");
65 } else {
66 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
67 displayPageHeader($color, $mailbox);
68 messages_deleted_message($mailbox, $sort, $startMessage, $color);
69 }
dd88d31f 70 } else {
5479d709 71 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
72 displayPageHeader($color, $mailbox);
a6668eb2 73 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
dd88d31f 74 }
75 } else { // Move messages
5479d709 76// displayPageHeader($color, $mailbox);
dd88d31f 77 // lets check to see if they selected any messages
78 if (is_array($msg) == 1) {
79 $j = 0;
80 $i = 0;
81
82 // If they have selected nothing msg is size one still, but will be an infinite
83 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
84 while ($j < count($msg)) {
85 if ($msg[$i]) {
86 /** check if they would like to move it to the trash folder or not */
8b673ac1 87 sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
88 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
dd88d31f 89 $j++;
90 }
91 $i++;
92 }
93 if ($auto_expunge == true)
d2f34a3d 94 sqimap_mailbox_expunge($imapConnection, $mailbox);
de80e95e 95
5479d709 96 if ($auto_forward) {
97 header ("Location: right_main.php");
98 } else {
99 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
100 displayPageHeader($color, $mailbox);
101 messages_moved_message($mailbox, $sort, $startMessage, $color);
102 }
dd88d31f 103 } else {
5479d709 104 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
105 displayPageHeader($color, $mailbox);
a6668eb2 106 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
2d7d3c2a 107 }
b40316f9 108 }
109
b40316f9 110 // Log out this session
813eba2f 111 sqimap_logout($imapConnection);
b40316f9 112
2aa12d5e 113?>
aa32c5e4 114</BODY></HTML>