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