svncommit
2006-06-29 a894ba5029a09fb9d0453b5cf9c944ce313f8a48
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                     |
8  | Copyright (C) 2005, 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
22 $REMOTE_REQUEST = TRUE;
23
24 // move messages
25 if ($_action=='moveto' && $_GET['_uid'] && $_GET['_target_mbox'])
26   {
27   $count = sizeof(explode(',', $_GET['_uid']));  
28   $moved = $IMAP->move_message($_GET['_uid'], $_GET['_target_mbox'], $_GET['_mbox']);
29   
30   if (!$moved)
31     {
32     // send error message
09941e 33     $commands = "this.list_mailbox();\n";
T 34     $commands .= show_message('errormoving', 'error');
35     rcube_remote_response($commands);
4e17e6 36     exit;
T 37     }
38   }
39
40 // delete messages 
41 else if ($_action=='delete' && $_GET['_uid'])
42   {
43   $count = sizeof(explode(',', $_GET['_uid']));
44   $del = $IMAP->delete_message($_GET['_uid'], $_GET['_mbox']);
45   
46   if (!$del)
47     {
48     // send error message
09941e 49     $commands = "this.list_mailbox();\n";
T 50     $commands .= show_message('errordeleting', 'error');
51     rcube_remote_response($commands);
4e17e6 52     exit;
T 53     }
54   }
55   
56 // unknown action or missing query param
57 else
58   {
59   exit;
60   }
61
62
63 // update message count display
64 $pages = ceil($IMAP->messagecount()/$IMAP->page_size);
65 $commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
66 $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
67
7902df 68
4e17e6 69 // update mailboxlist
T 70 $mbox = $IMAP->get_mailbox_name();
71 $commands .= sprintf("this.set_unread_count('%s', %d);\n", $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
7902df 72
T 73 if ($_action=='moveto')
74   $commands .= sprintf("this.set_unread_count('%s', %d);\n", $_GET['_target_mbox'], $IMAP->messagecount($_GET['_target_mbox'], 'UNSEEN'));
4e17e6 75
58e360 76 $commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota()); 
4e17e6 77
T 78 // add new rows from next page (if any)
79 if ($_GET['_from']!='show' && $pages>1 && $IMAP->list_page < $pages)
80   {
4b0f65 81   $a_headers = $IMAP->list_headers($mbox, null, $_SESSION['sort_col'], $_SESSION['sort_order']);
4e17e6 82   $a_headers = array_slice($a_headers, -$count, $count);
T 83   $commands .= rcmail_js_message_list($a_headers);
84   }
85
86   
87 // send response
88 rcube_remote_response($commands);
89
90 exit;
a894ba 91 ?>