Added a constat to all files in functions/ to be able to chech whether the
[squirrelmail.git] / src / move_messages.php
1 <?
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");
12
13 include("../src/load_prefs.php");
14
15 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
16
17 function putSelectedMessagesIntoString($msg) {
18 $j = 0;
19 $i = 0;
20 $firstLoop = true;
21
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.
25 while (($j < count($msg)) && ($msg[0])) {
26 if ($msg[$i]) {
27 if ($firstLoop != true)
28 $selectedMessages .= "&";
29 else
30 $firstLoop = false;
31
32 $selectedMessages .= "selMsg[$j]=$msg[$i]";
33
34 $j++;
35 }
36 $i++;
37 }
38 }
39
40 $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
41 sqimap_mailbox_select($imapConnection, $mailbox);
42
43 // If the delete button was pressed, the moveButton variable will not be set.
44 if (!$moveButton) {
45 displayPageHeader($color, $mailbox);
46 if (is_array($msg) == 1) {
47 // Marks the selected messages ad 'Deleted'
48 $j = 0;
49 $i = 0;
50
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]) {
55 echo $msg[$i] . "<BR>";
56 sqimap_messages_delete($imapConnection, $msg[$i], $msg[$i], $mailbox);
57 $j++;
58 }
59 $i++;
60 }
61 messages_deleted_message($mailbox, $sort, $startMessage, $color);
62 } else {
63 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
64 }
65 } else { // Move messages
66 displayPageHeader($color, $mailbox);
67 // lets check to see if they selected any messages
68 if (is_array($msg) == 1) {
69 $j = 0;
70 $i = 0;
71
72 // If they have selected nothing msg is size one still, but will be an infinite
73 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
74 while ($j < count($msg)) {
75 if ($msg[$i]) {
76 echo $msg[$i] . "<BR>";
77 /** check if they would like to move it to the trash folder or not */
78 sqimap_messages_copy($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
79 sqimap_messages_flag($imapConnection, $msg[$i], $msg[$i], "Deleted");
80 $j++;
81 }
82 $i++;
83 }
84 if ($auto_expunge == true)
85 sqimap_mailbox_expunge($imapConnection, $mailbox, $numMessages);
86
87 messages_moved_message($mailbox, $sort, $startMessage, $color);
88 } else {
89 error_message(_("No messages were selected."), $mailbox, $sort, $startMessage, $color);
90 }
91 }
92
93 // Log out this session
94 sqimap_logout($imapConnection);
95
96 ?>
97 </BODY></HTML>