You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

copy.inc 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------+
  4. | program/steps/mail/copy.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. | Copy the submitted messages to a specific mailbox |
  15. | |
  16. +-----------------------------------------------------------------------+
  17. | Author: Aleksander Machniak <alec@alec.pl> |
  18. +-----------------------------------------------------------------------+
  19. */
  20. // only process ajax requests
  21. if (!$OUTPUT->ajax_call) {
  22. return;
  23. }
  24. // copy messages
  25. if (!empty($_POST['_uid']) && strlen($_POST['_target_mbox'])) {
  26. $target = rcube_utils::get_input_value('_target_mbox', rcube_utils::INPUT_POST, true);
  27. $sources = array();
  28. foreach (rcmail::get_uids(null, null, $multifolder) as $mbox => $uids) {
  29. if ($mbox === $target) {
  30. $copied++;
  31. }
  32. else {
  33. $copied += (int)$RCMAIL->storage->copy_message($uids, $target, $mbox);
  34. $sources[] = $mbox;
  35. }
  36. }
  37. if (!$copied) {
  38. // send error message
  39. $RCMAIL->display_server_error('errorcopying');
  40. $OUTPUT->send();
  41. exit;
  42. }
  43. else {
  44. $OUTPUT->show_message('messagecopied', 'confirmation');
  45. }
  46. rcmail_send_unread_count($target, true);
  47. $OUTPUT->command('set_quota', $RCMAIL->quota_content(null, $multifolder ? $sources[0] : 'INBOX'));
  48. }
  49. // unknown action or missing query param
  50. else {
  51. $OUTPUT->show_message('internalerror', 'error');
  52. }
  53. // send response
  54. $OUTPUT->send();