0
|
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 * @license GNU GPLv3+
|
|
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 $this->add_hook('storage_init', array($this, 'storage_init'));
|
|
22
|
|
23 if ($rcmail->action == '' || $rcmail->action == 'show') {
|
|
24 $skin_path = $this->local_skin_path();
|
|
25
|
|
26 $this->add_texts('localization', true);
|
|
27 $this->include_script('markasjunk.js');
|
|
28
|
|
29 if (is_file($this->home . "/$skin_path/markasjunk.css")) {
|
|
30 $this->include_stylesheet("$skin_path/markasjunk.css");
|
|
31 }
|
|
32
|
|
33 $this->add_button(array(
|
|
34 'type' => 'link',
|
|
35 'label' => 'buttontext',
|
|
36 'command' => 'plugin.markasjunk',
|
|
37 'class' => 'button buttonPas junk disabled',
|
|
38 'classact' => 'button junk',
|
|
39 'title' => 'buttontitle',
|
|
40 'domain' => 'markasjunk'
|
|
41 ),'toolbar');
|
|
42 }
|
|
43 }
|
|
44
|
|
45 function storage_init($args)
|
|
46 {
|
|
47 $flags = array(
|
|
48 'JUNK' => 'Junk',
|
|
49 'NONJUNK' => 'NonJunk',
|
|
50 );
|
|
51
|
|
52 // register message flags
|
|
53 $args['message_flags'] = array_merge((array)$args['message_flags'], $flags);
|
|
54
|
|
55 return $args;
|
|
56 }
|
|
57
|
|
58 function request_action()
|
|
59 {
|
|
60 $this->add_texts('localization');
|
|
61
|
|
62 $rcmail = rcmail::get_instance();
|
|
63 $storage = $rcmail->get_storage();
|
|
64
|
|
65 foreach (rcmail::get_uids() as $mbox => $uids) {
|
|
66 $storage->unset_flag($uids, 'NONJUNK', $mbox);
|
|
67 $storage->set_flag($uids, 'JUNK', $mbox);
|
|
68 }
|
|
69
|
|
70 if (($junk_mbox = $rcmail->config->get('junk_mbox'))) {
|
|
71 $rcmail->output->command('move_messages', $junk_mbox);
|
|
72 }
|
|
73
|
|
74 $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation');
|
|
75 $rcmail->output->send();
|
|
76 }
|
|
77 }
|