move_messages.php 4.3 KB

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