commit | author | age
|
48e9c1
|
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 @package_version@ |
|
10 |
* @license GNU GPLv3+ |
|
11 |
* @author Thomas Bruederli |
|
12 |
*/ |
|
13 |
class markasjunk extends rcube_plugin |
|
14 |
{ |
|
15 |
public $task = 'mail'; |
|
16 |
|
|
17 |
function init() |
|
18 |
{ |
|
19 |
$rcmail = rcmail::get_instance(); |
|
20 |
|
|
21 |
$this->register_action('plugin.markasjunk', array($this, 'request_action')); |
05da15
|
22 |
$this->add_hook('storage_init', array($this, 'storage_init')); |
48e9c1
|
23 |
|
T |
24 |
if ($rcmail->action == '' || $rcmail->action == 'show') { |
|
25 |
$skin_path = $this->local_skin_path(); |
|
26 |
$this->include_script('markasjunk.js'); |
|
27 |
if (is_file($this->home . "/$skin_path/markasjunk.css")) |
|
28 |
$this->include_stylesheet("$skin_path/markasjunk.css"); |
|
29 |
$this->add_texts('localization', true); |
|
30 |
|
|
31 |
$this->add_button(array( |
|
32 |
'type' => 'link', |
|
33 |
'label' => 'buttontext', |
|
34 |
'command' => 'plugin.markasjunk', |
|
35 |
'class' => 'button buttonPas junk disabled', |
|
36 |
'classact' => 'button junk', |
|
37 |
'title' => 'buttontitle', |
|
38 |
'domain' => 'markasjunk'), 'toolbar'); |
|
39 |
} |
|
40 |
} |
|
41 |
|
05da15
|
42 |
function storage_init($args) |
AM |
43 |
{ |
|
44 |
$flags = array( |
|
45 |
'JUNK' => 'Junk', |
|
46 |
'NONJUNK' => 'NonJunk', |
|
47 |
); |
|
48 |
|
|
49 |
// register message flags |
|
50 |
$args['message_flags'] = array_merge((array)$args['message_flags'], $flags); |
|
51 |
|
|
52 |
return $args; |
|
53 |
} |
|
54 |
|
48e9c1
|
55 |
function request_action() |
T |
56 |
{ |
|
57 |
$this->add_texts('localization'); |
|
58 |
|
61be82
|
59 |
$uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST); |
AM |
60 |
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST); |
05da15
|
61 |
|
AM |
62 |
$rcmail = rcmail::get_instance(); |
|
63 |
$storage = $rcmail->get_storage(); |
|
64 |
|
|
65 |
$storage->unset_flag($uids, 'NONJUNK'); |
|
66 |
$storage->set_flag($uids, 'JUNK'); |
|
67 |
|
48e9c1
|
68 |
if (($junk_mbox = $rcmail->config->get('junk_mbox')) && $mbox != $junk_mbox) { |
T |
69 |
$rcmail->output->command('move_messages', $junk_mbox); |
|
70 |
} |
05da15
|
71 |
|
48e9c1
|
72 |
$rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation'); |
T |
73 |
$rcmail->output->send(); |
|
74 |
} |
|
75 |
|
|
76 |
} |