]> git.donarmstrong.com Git - roundcube.git/blob - plugins/markasjunk/markasjunk.php
Imported Upstream version 0.3
[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     $GLOBALS['IMAP_FLAGS']['JUNK'] = 'Junk';
20     
21     $rcmail = rcmail::get_instance();
22     if ($rcmail->action == '' || $rcmail->action == 'show') {
23       $this->include_script('markasjunk.js');
24       $this->add_texts('localization', true);
25       $this->add_button(array('command' => 'plugin.markasjunk', 'imagepas' => 'junk_pas.png', 'imageact' => 'junk_act.png'), 'toolbar');
26     }
27   }
28
29   function request_action()
30   {
31     $this->add_texts('localization');
32     
33     $uids = get_input_value('_uid', RCUBE_INPUT_POST);
34     $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
35     
36     $rcmail = rcmail::get_instance();
37     $rcmail->imap->set_flag($uids, 'JUNK');
38     
39     if (($junk_mbox = $rcmail->config->get('junk_mbox')) && $mbox != $junk_mbox) {
40       $rcmail->output->command('move_messages', $junk_mbox);
41     }
42     
43     $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation');
44     $rcmail->output->send();
45   }
46
47 }