alecpl
2009-10-06 ffeab7fe7e0ccf1d458d6a863600359c38769950
commit | author | age
cc97ea 1 <?php
T 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') {
34aec7 23       $skin_path = 'skins/'.$rcmail->output->config['skin'];
cc97ea 24       $this->include_script('markasjunk.js');
T 25       $this->add_texts('localization', true);
34aec7 26       $this->add_button(array('command' => 'plugin.markasjunk',
A 27         'imagepas' => $skin_path.'/junk_pas.png',
28         'imageact' => $skin_path.'/junk_act.png',
29     'title' => 'markasjunk.buttontitle'), 'toolbar');
cc97ea 30     }
T 31   }
32
33   function request_action()
34   {
35     $this->add_texts('localization');
36     
37     $uids = get_input_value('_uid', RCUBE_INPUT_POST);
38     $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
39     
40     $rcmail = rcmail::get_instance();
41     $rcmail->imap->set_flag($uids, 'JUNK');
42     
43     if (($junk_mbox = $rcmail->config->get('junk_mbox')) && $mbox != $junk_mbox) {
44       $rcmail->output->command('move_messages', $junk_mbox);
45     }
46     
47     $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation');
48     $rcmail->output->send();
49   }
50
51 }