Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

mark.inc 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------+
  4. | program/steps/mail/mark.inc |
  5. | |
  6. | This file is part of the Roundcube Webmail client |
  7. | Copyright (C) 2005-2014, The Roundcube Dev Team |
  8. | |
  9. | Licensed under the GNU General Public License version 3 or |
  10. | any later version with exceptions for skins & plugins. |
  11. | See the README file for a full license statement. |
  12. | |
  13. | PURPOSE: |
  14. | Mark the submitted messages with the specified flag |
  15. | |
  16. +-----------------------------------------------------------------------+
  17. | Author: Thomas Bruederli <roundcube@gmail.com> |
  18. +-----------------------------------------------------------------------+
  19. */
  20. // only process ajax requests
  21. if (!$OUTPUT->ajax_call) {
  22. return;
  23. }
  24. $threading = (bool) $RCMAIL->storage->get_threading();
  25. $skip_deleted = (bool) $RCMAIL->config->get('skip_deleted');
  26. $read_deleted = (bool) $RCMAIL->config->get('read_when_deleted');
  27. $a_flags_map = array(
  28. 'undelete' => 'UNDELETED',
  29. 'delete' => 'DELETED',
  30. 'read' => 'SEEN',
  31. 'unread' => 'UNSEEN',
  32. 'flagged' => 'FLAGGED',
  33. 'unflagged' => 'UNFLAGGED',
  34. );
  35. $_uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
  36. $flag = rcube_utils::get_input_value('_flag', rcube_utils::INPUT_POST);
  37. $folders = rcube_utils::get_input_value('_folders', rcube_utils::INPUT_POST);
  38. $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
  39. if ($_uids && $flag) {
  40. $flag = $a_flags_map[$flag] ?: strtoupper($flag);
  41. if ($flag == 'DELETED' && $skip_deleted && $_POST['_from'] != 'show') {
  42. // count messages before changing anything
  43. $old_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
  44. $old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize());
  45. }
  46. if ($folders == 'all') {
  47. $mboxes = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail');
  48. $input = array_combine($mboxes, array_fill(0, count($mboxes), '*'));
  49. }
  50. else if ($folders == 'sub') {
  51. $delim = $RCMAIL->storage->get_hierarchy_delimiter();
  52. $mboxes = $RCMAIL->storage->list_folders_subscribed($mbox . $delim, '*', 'mail');
  53. array_unshift($mboxes, $mbox);
  54. $input = array_combine($mboxes, array_fill(0, count($mboxes), '*'));
  55. }
  56. else if ($folders == 'cur') {
  57. $input = array($mbox => '*');
  58. }
  59. else {
  60. $input = rcmail::get_uids(null, null, $dummy, rcube_utils::INPUT_POST);
  61. }
  62. foreach ($input as $mbox => $uids) {
  63. $marked += (int)$RCMAIL->storage->set_flag($uids, $flag, $mbox);
  64. $count += count($uids);
  65. }
  66. if (!$marked) {
  67. // send error message
  68. if ($_POST['_from'] != 'show') {
  69. $OUTPUT->command('list_mailbox');
  70. }
  71. $RCMAIL->display_server_error('errormarking');
  72. $OUTPUT->send();
  73. exit;
  74. }
  75. else if (empty($_POST['_quiet'])) {
  76. $OUTPUT->show_message('messagemarked', 'confirmation');
  77. }
  78. if ($flag == 'DELETED' && $read_deleted && !empty($_POST['_ruid'])) {
  79. if ($ruids = rcube_utils::get_input_value('_ruid', rcube_utils::INPUT_POST)) {
  80. foreach (rcmail::get_uids($ruids) as $mbox => $uids) {
  81. $read += (int)$RCMAIL->storage->set_flag($uids, 'SEEN', $mbox);
  82. }
  83. }
  84. if ($read && !$skip_deleted) {
  85. $OUTPUT->command('flag_deleted_as_read', $ruids);
  86. }
  87. }
  88. if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$skip_deleted)) {
  89. foreach ($input as $mbox => $uids) {
  90. rcmail_send_unread_count($mbox);
  91. }
  92. $OUTPUT->set_env('last_flag', $flag);
  93. }
  94. else if ($flag == 'DELETED' && $skip_deleted) {
  95. if ($_POST['_from'] == 'show') {
  96. if ($next = rcube_utils::get_input_value('_next_uid', rcube_utils::INPUT_GPC))
  97. $OUTPUT->command('show_message', $next);
  98. else
  99. $OUTPUT->command('command', 'list');
  100. }
  101. else {
  102. $search_request = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC);
  103. // refresh saved search set after moving some messages
  104. if ($search_request && $RCMAIL->storage->get_search_set()) {
  105. $_SESSION['search'] = $RCMAIL->storage->refresh_search();
  106. }
  107. $msg_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
  108. $page_size = $RCMAIL->storage->get_pagesize();
  109. $page = $RCMAIL->storage->get_page();
  110. $pages = ceil($msg_count / $page_size);
  111. $nextpage_count = $old_count - $page_size * $page;
  112. $remaining = $msg_count - $page_size * ($page - 1);
  113. // jump back one page (user removed the whole last page)
  114. if ($page > 1 && $remaining == 0) {
  115. $page -= 1;
  116. $RCMAIL->storage->set_page($page);
  117. $_SESSION['page'] = $page;
  118. $jump_back = true;
  119. }
  120. // update message count display
  121. $OUTPUT->set_env('messagecount', $msg_count);
  122. $OUTPUT->set_env('current_page', $page);
  123. $OUTPUT->set_env('pagecount', $pages);
  124. // update mailboxlist
  125. $mbox = $RCMAIL->storage->get_folder();
  126. $unseen_count = $msg_count ? $RCMAIL->storage->count($mbox, 'UNSEEN') : 0;
  127. $old_unseen = rcmail_get_unseen_count($mbox);
  128. if ($old_unseen != $unseen_count) {
  129. $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
  130. rcmail_set_unseen_count($mbox, $unseen_count);
  131. }
  132. $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count), $mbox);
  133. if ($threading) {
  134. $count = rcube_utils::get_input_value('_count', rcube_utils::INPUT_POST);
  135. }
  136. // add new rows from next page (if any)
  137. if ($old_count && $_uids != '*' && ($jump_back || $nextpage_count > 0)) {
  138. // #5862: Don't add more rows than it was on the next page
  139. $count = $jump_back ? null : min($nextpage_count, $count);
  140. $a_headers = $RCMAIL->storage->list_messages($mbox, null,
  141. rcmail_sort_column(), rcmail_sort_order(), $count);
  142. rcmail_js_message_list($a_headers, false);
  143. }
  144. }
  145. }
  146. }
  147. else {
  148. $OUTPUT->show_message('internalerror', 'error');
  149. }
  150. $OUTPUT->send();