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 |
|
05da15
|
59 |
$rcmail = rcmail::get_instance(); |
AM |
60 |
$storage = $rcmail->get_storage(); |
|
61 |
|
7fce8f
|
62 |
foreach (rcmail::get_uids() as $mbox => $uids) { |
TB |
63 |
$storage->unset_flag($uids, 'NONJUNK', $mbox); |
|
64 |
$storage->set_flag($uids, 'JUNK', $mbox); |
|
65 |
} |
05da15
|
66 |
|
7fce8f
|
67 |
if (($junk_mbox = $rcmail->config->get('junk_mbox'))) { |
48e9c1
|
68 |
$rcmail->output->command('move_messages', $junk_mbox); |
T |
69 |
} |
05da15
|
70 |
|
48e9c1
|
71 |
$rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation'); |
T |
72 |
$rcmail->output->send(); |
|
73 |
} |
|
74 |
|
|
75 |
} |