commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/mail/move_del.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
f11541
|
8 |
| Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
11 |
| PURPOSE: | |
|
12 |
| Move the submitted messages to a specific mailbox or delete them | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
c3ab87
|
22 |
// count messages before changing anything |
51e14a
|
23 |
$old_count = $IMAP->messagecount(); |
9a3567
|
24 |
$old_pages = ceil($old_count / $IMAP->page_size); |
51e14a
|
25 |
|
4e17e6
|
26 |
// move messages |
8d0758
|
27 |
if ($_action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) |
f11541
|
28 |
{ |
8d0758
|
29 |
$count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST)))); |
T |
30 |
$target = get_input_value('_target_mbox', RCUBE_INPUT_POST); |
|
31 |
$moved = $IMAP->move_message($uids, $target, get_input_value('_mbox', RCUBE_INPUT_POST)); |
4e17e6
|
32 |
|
T |
33 |
if (!$moved) |
f11541
|
34 |
{ |
4e17e6
|
35 |
// send error message |
f11541
|
36 |
$OUTPUT->command('list_mailbox'); |
T |
37 |
$OUTPUT->show_message('errormoving', 'error'); |
|
38 |
$OUTPUT->send(); |
4e17e6
|
39 |
exit; |
T |
40 |
} |
f11541
|
41 |
} |
4e17e6
|
42 |
|
T |
43 |
// delete messages |
8d0758
|
44 |
else if ($_action=='delete' && !empty($_POST['_uid'])) |
f11541
|
45 |
{ |
8d0758
|
46 |
$count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST)))); |
T |
47 |
$del = $IMAP->delete_message($uids, get_input_value('_mbox', RCUBE_INPUT_POST)); |
4e17e6
|
48 |
|
T |
49 |
if (!$del) |
f11541
|
50 |
{ |
4e17e6
|
51 |
// send error message |
f11541
|
52 |
$OUTPUT->command('list_mailbox'); |
T |
53 |
$OUTPUT->show_message('errordeleting', 'error'); |
|
54 |
$OUTPUT->send(); |
4e17e6
|
55 |
exit; |
T |
56 |
} |
f11541
|
57 |
} |
4e17e6
|
58 |
|
T |
59 |
// unknown action or missing query param |
|
60 |
else |
|
61 |
exit; |
|
62 |
|
110748
|
63 |
// refresh saved search set after moving some messages |
b3ce79
|
64 |
if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) |
04c618
|
65 |
$_SESSION['search'][$search_request] = $IMAP->refresh_search(); |
T |
66 |
|
4e17e6
|
67 |
|
9a3567
|
68 |
$msg_count = $IMAP->messagecount(); |
T |
69 |
$pages = ceil($msg_count / $IMAP->page_size); |
|
70 |
$nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page; |
|
71 |
$remaining = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1); |
c3ab87
|
72 |
|
T |
73 |
// jump back one page (user removed the whole last page) |
9a3567
|
74 |
if ($IMAP->list_page > 1 && $nextpage_count <= 0 && $remaining == 0) |
c3ab87
|
75 |
{ |
T |
76 |
$IMAP->set_page($IMAP->list_page-1); |
|
77 |
$_SESSION['page'] = $IMAP->list_page; |
|
78 |
$jump_back = true; |
|
79 |
} |
|
80 |
|
4e17e6
|
81 |
// update message count display |
f11541
|
82 |
$OUTPUT->set_env('pagecount', $pages); |
c3ab87
|
83 |
$OUTPUT->set_env('current_page', $IMAP->list_page); |
f11541
|
84 |
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count)); |
4e17e6
|
85 |
|
7902df
|
86 |
|
4e17e6
|
87 |
// update mailboxlist |
T |
88 |
$mbox = $IMAP->get_mailbox_name(); |
cf1f0f
|
89 |
$OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'), ($mbox == 'INBOX')); |
7902df
|
90 |
|
b3ce79
|
91 |
if ($_action=='moveto' && $target) |
f11541
|
92 |
$OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN')); |
4e17e6
|
93 |
|
f11541
|
94 |
$OUTPUT->command('set_quota', $IMAP->get_quota()); |
4e17e6
|
95 |
|
T |
96 |
// add new rows from next page (if any) |
9a3567
|
97 |
if ($_POST['_from']!='show' && ($jump_back || $nextpage_count > 0)) |
f11541
|
98 |
{ |
04c618
|
99 |
$sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col']; |
T |
100 |
$sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; |
|
101 |
|
|
102 |
$a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order); |
c3ab87
|
103 |
if (!$jump_back) |
T |
104 |
$a_headers = array_slice($a_headers, -$count, $count); |
04c618
|
105 |
|
f11541
|
106 |
rcmail_js_message_list($a_headers); |
T |
107 |
} |
4e17e6
|
108 |
|
04c618
|
109 |
|
4e17e6
|
110 |
// send response |
f11541
|
111 |
$OUTPUT->send(); |
4e17e6
|
112 |
|
a894ba
|
113 |
?> |