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
9 * @version @package_version@
10 * @author Thomas Bruederli
12 class markasjunk extends rcube_plugin
14 public $task = 'mail';
18 $rcmail = rcmail::get_instance();
20 $this->register_action('plugin.markasjunk', array($this, 'request_action'));
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',
32 'title' => 'markasjunk.buttontitle'), 'toolbar');
36 function request_action()
38 $this->add_texts('localization');
40 $GLOBALS['IMAP_FLAGS']['JUNK'] = 'Junk';
41 $GLOBALS['IMAP_FLAGS']['NONJUNK'] = 'NonJunk';
43 $uids = get_input_value('_uid', RCUBE_INPUT_POST);
44 $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
46 $rcmail = rcmail::get_instance();
47 $rcmail->imap->unset_flag($uids, 'NONJUNK');
48 $rcmail->imap->set_flag($uids, 'JUNK');
50 if (($junk_mbox = $rcmail->config->get('junk_mbox')) && $mbox != $junk_mbox) {
51 $rcmail->output->command('move_messages', $junk_mbox);
54 $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation');
55 $rcmail->output->send();