Moved printing of HTML-header into page_header.php.
[squirrelmail.git] / src / move_messages.php
CommitLineData
59177427 1<?php
2a32fc83 2 session_start();
3
d068c0ec 4 if (!isset($config_php))
5 include("../config/config.php");
6 if (!isset($strings_php))
7 include("../functions/strings.php");
8 if (!isset($page_header_php))
9 include("../functions/page_header.php");
10 if (!isset($display_messages_php))
11 include("../functions/display_messages.php");
12 if (!isset($imap_php))
13 include("../functions/imap.php");
b40316f9 14
d3cdb279 15 include("../src/load_prefs.php");
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) {
dd88d31f 45 if (is_array($msg) == 1) {
46 // Marks the selected messages ad 'Deleted'
47 $j = 0;
48 $i = 0;
2d7d3c2a 49
dd88d31f 50 // If they have selected nothing msg is size one still, but will be an infinite
51 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
52 while ($j < count($msg)) {
53 if ($msg[$i]) {
813eba2f 54 sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
dd88d31f 55 $j++;
2d7d3c2a 56 }
dd88d31f 57 $i++;
2d7d3c2a 58 }
acaa9842 59 if ($auto_expunge) {
d2f34a3d 60 sqimap_mailbox_expunge($imapConnection, $mailbox);
acaa9842 61 }
5479d709 62 if ($auto_forward) {
9f2215a1 63 header ("Location: right_main.php");
5479d709 64 } else {
5479d709 65 displayPageHeader($color, $mailbox);
66 messages_deleted_message($mailbox, $sort, $startMessage, $color);
67 }
dd88d31f 68 } else {
5479d709 69 displayPageHeader($color, $mailbox);
a6668eb2 70 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
dd88d31f 71 }
72 } else { // Move messages
dd88d31f 73 // lets check to see if they selected any messages
74 if (is_array($msg) == 1) {
75 $j = 0;
76 $i = 0;
77
78 // If they have selected nothing msg is size one still, but will be an infinite
79 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
80 while ($j < count($msg)) {
81 if ($msg[$i]) {
82 /** check if they would like to move it to the trash folder or not */
8b673ac1 83 sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
84 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
dd88d31f 85 $j++;
86 }
87 $i++;
88 }
89 if ($auto_expunge == true)
d2f34a3d 90 sqimap_mailbox_expunge($imapConnection, $mailbox);
de80e95e 91
5479d709 92 if ($auto_forward) {
9f2215a1 93 header ("Location: right_main.php");
5479d709 94 } else {
5479d709 95 displayPageHeader($color, $mailbox);
96 messages_moved_message($mailbox, $sort, $startMessage, $color);
97 }
dd88d31f 98 } else {
5479d709 99 displayPageHeader($color, $mailbox);
a6668eb2 100 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
2d7d3c2a 101 }
b40316f9 102 }
103
b40316f9 104 // Log out this session
813eba2f 105 sqimap_logout($imapConnection);
b40316f9 106
2aa12d5e 107?>
aa32c5e4 108</BODY></HTML>