]> git.donarmstrong.com Git - roundcube.git/blob - plugins/markasjunk/markasjunk.php
Imported Upstream version 0.3.1
[roundcube.git] / plugins / markasjunk / markasjunk.php
1 <?php
2
3 /**
4  * Mark as Junk
5  *
6  * Sample plugin that adds a new button to the mailbox toolbar
7  * to mark the selected messages as Junk and move them to the Junk folder
8  *
9  * @version 1.0
10  * @author Thomas Bruederli
11  */
12 class markasjunk extends rcube_plugin
13 {
14   public $task = 'mail';
15
16   function init()
17   {
18     $this->register_action('plugin.markasjunk', array($this, 'request_action'));
19     
20     $rcmail = rcmail::get_instance();
21     if ($rcmail->action == '' || $rcmail->action == 'show') {
22       $skin_path = $this->local_skin_path();
23       $this->include_script('markasjunk.js');
24       $this->add_texts('localization', true);
25       $this->add_button(array(
26         'command' => 'plugin.markasjunk',
27         'imagepas' => $skin_path.'/junk_pas.png',
28         'imageact' => $skin_path.'/junk_act.png',
29         'title' => 'markasjunk.buttontitle'), 'toolbar');
30     }
31   }
32
33   function request_action()
34   {
35     $this->add_texts('localization');
36
37     $GLOBALS['IMAP_FLAGS']['JUNK'] = 'Junk';
38     $GLOBALS['IMAP_FLAGS']['NONJUNK'] = 'NonJunk';
39     
40     $uids = get_input_value('_uid', RCUBE_INPUT_POST);
41     $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
42     
43     $rcmail = rcmail::get_instance();
44     $rcmail->imap->unset_flag($uids, 'NONJUNK');
45     $rcmail->imap->set_flag($uids, 'JUNK');
46     
47     if (($junk_mbox = $rcmail->config->get('junk_mbox')) && $mbox != $junk_mbox) {
48       $rcmail->output->command('move_messages', $junk_mbox);
49     }
50     
51     $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation');
52     $rcmail->output->send();
53   }
54
55 }