]> git.donarmstrong.com Git - roundcube.git/blob - plugins/markasjunk/markasjunk.php
Imported Upstream version 0.5.2+dfsg
[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 @package_version@
10  * @author Thomas Bruederli
11  */
12 class markasjunk extends rcube_plugin
13 {
14   public $task = 'mail';
15
16   function init()
17   {
18     $rcmail = rcmail::get_instance();
19
20     $this->register_action('plugin.markasjunk', array($this, 'request_action'));
21       
22     if ($rcmail->action == '' || $rcmail->action == 'show') {
23       $skin_path = $this->local_skin_path();
24       $this->include_script('markasjunk.js');
25       $this->add_texts('localization', true);
26       $this->add_button(array(
27         'command' => 'plugin.markasjunk',
28         'imagepas' => $skin_path.'/junk_pas.png',
29         'imageact' => $skin_path.'/junk_act.png',
30         'width' => 32,
31         'height' => 32,
32         'title' => 'markasjunk.buttontitle'), 'toolbar');
33     }
34   }
35
36   function request_action()
37   {
38     $this->add_texts('localization');
39
40     $GLOBALS['IMAP_FLAGS']['JUNK'] = 'Junk';
41     $GLOBALS['IMAP_FLAGS']['NONJUNK'] = 'NonJunk';
42     
43     $uids = get_input_value('_uid', RCUBE_INPUT_POST);
44     $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
45     
46     $rcmail = rcmail::get_instance();
47     $rcmail->imap->unset_flag($uids, 'NONJUNK');
48     $rcmail->imap->set_flag($uids, 'JUNK');
49     
50     if (($junk_mbox = $rcmail->config->get('junk_mbox')) && $mbox != $junk_mbox) {
51       $rcmail->output->command('move_messages', $junk_mbox);
52     }
53     
54     $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation');
55     $rcmail->output->send();
56   }
57
58 }