]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/mail/mark.inc
Imported Upstream version 0.2~stable
[roundcube.git] / program / steps / mail / mark.inc
1 <?php
2 /*
3  +-----------------------------------------------------------------------+
4  | program/steps/mail/mark.inc                                           |
5  |                                                                       |
6  | This file is part of the RoundCube Webmail client                     |
7  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
8  | Licensed under the GNU GPL                                            |
9  |                                                                       |
10  | PURPOSE:                                                              |
11  |   Mark the submitted messages with the specified flag                 |
12  |                                                                       |
13  +-----------------------------------------------------------------------+
14  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
15  +-----------------------------------------------------------------------+
16
17  $Id: mark.inc 1962 2008-10-09 06:25:43Z alec $
18
19 */
20
21 $a_flags_map = array(
22   'undelete' => 'UNDELETED',
23   'delete' => 'DELETED',
24   'read' => 'SEEN',
25   'unread' => 'UNSEEN',
26   'flagged' => 'FLAGGED',
27   'unflagged' => 'UNFLAGGED');
28
29 if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_value('_flag', RCUBE_INPUT_POST)))
30 {
31   $flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag);
32   $marked = $IMAP->set_flag($uids, $flag);
33
34   if($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid']))
35     {
36     $uids = get_input_value('_ruid', RCUBE_INPUT_POST);
37     $read = $IMAP->set_flag($uids, 'SEEN');
38     
39     if ($read != -1)
40       $OUTPUT->command('flag_deleted_as_read', $uids);
41     }
42
43   if ($marked != -1 && ($flag == 'SEEN' || $flag == 'UNSEEN'))
44   {
45     $mbox_name = $IMAP->get_mailbox_name();
46     $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX'));
47   }
48
49   $OUTPUT->send();
50 }
51   
52 exit;
53 ?>