]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/mail/move_del.inc
Imported Upstream version 0.1~rc1~dfsg
[roundcube.git] / program / steps / mail / move_del.inc
1 <?php
2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/mail/move_del.inc                                       |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
9  | Licensed under the GNU GPL                                            |
10  |                                                                       |
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: move_del.inc 573 2007-05-18 11:29:25Z thomasb $
19
20 */
21
22 // move messages
23 if ($_action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox']))
24 {
25   $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
26   $target = get_input_value('_target_mbox', RCUBE_INPUT_POST);
27   $moved = $IMAP->move_message($uids, $target, get_input_value('_mbox', RCUBE_INPUT_POST));
28   
29   if (!$moved)
30   {
31     // send error message
32     $OUTPUT->command('list_mailbox');
33     $OUTPUT->show_message('errormoving', 'error');
34     $OUTPUT->send();
35     exit;
36   }
37 }
38
39 // delete messages 
40 else if ($_action=='delete' && !empty($_POST['_uid']))
41 {
42   $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
43   $del = $IMAP->delete_message($uids, get_input_value('_mbox', RCUBE_INPUT_POST));
44   
45   if (!$del)
46   {
47     // send error message
48     $OUTPUT->command('list_mailbox');
49     $OUTPUT->show_message('errordeleting', 'error');
50     $OUTPUT->send();
51     exit;
52   }
53 }
54   
55 // unknown action or missing query param
56 else
57   exit;
58
59 // refresh saved seach set after moving some messages
60 if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set)
61   $_SESSION['search'][$search_request] = $IMAP->refresh_search();
62
63
64 // update message count display
65 $msg_count = $IMAP->messagecount();
66 $pages = ceil($msg_count / $IMAP->page_size);
67 $OUTPUT->set_env('pagecount', $pages);
68 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
69
70
71 // update mailboxlist
72 $mbox = $IMAP->get_mailbox_name();
73 $OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
74
75 if ($_action=='moveto' && $target)
76   $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN'));
77
78 $OUTPUT->command('set_quota', $IMAP->get_quota());
79
80 // add new rows from next page (if any)
81 if ($_POST['_from']!='show' && $pages>1 && $IMAP->list_page < $pages)
82 {
83   $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
84   $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
85   
86   $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
87   $a_headers = array_slice($a_headers, -$count, $count);
88
89   rcmail_js_message_list($a_headers);
90 }
91
92
93 // send response
94 $OUTPUT->send();
95
96 ?>