]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/mail/folders.inc
Imported Upstream version 0.1
[roundcube.git] / program / steps / mail / folders.inc
1 <?php
2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/mail/folders.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  |   Implement folder operations line EXPUNGE and Clear                  |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17
18  $Id: folders.inc 1020 2008-02-05 22:56:29Z thomasb $
19 */
20
21 $mbox_name = $IMAP->get_mailbox_name();
22
23 // send EXPUNGE command
24 if ($_action=='expunge' && ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST)))
25 {
26   $success = $IMAP->expunge($mbox);
27
28   // reload message list if current mailbox  
29   if ($success && !empty($_REQUEST['_reload']))
30   {
31     $OUTPUT->command('message_list.clear');
32     $_action = 'list';
33     return;
34   }
35   else
36     $commands = "// expunged: $success\n";
37 }
38
39 // clear mailbox
40 else if ($_action=='purge' && ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST)))
41 {
42   // we should only be purging trash and junk
43   if($mbox == $CONFIG['trash_mbox'] || $mbox == $CONFIG['junk_mbox']) 
44   {
45     $success = $IMAP->clear_mailbox($mbox);
46   
47     if ($success && !empty($_REQUEST['_reload']))
48     {
49       $OUTPUT->set_env('messagecount', 0);
50       $OUTPUT->set_env('pagecount', 0);
51       $OUTPUT->command('message_list.clear');
52       $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text());
53       $OUTPUT->command('set_unread_count', $mbox_name, 0);
54     }
55     else
56       $commands = "// purged: $success";
57   }
58 }
59
60 $OUTPUT->send($commands);
61 ?>