From cc97ea0559af1a92a54dbcdf738ee4d95e67d3ff Mon Sep 17 00:00:00 2001 From: thomascube Date: Sun, 19 Apr 2009 17:44:29 +0000 Subject: Merged branch devel-api (from r2208 to r2387) back into trunk (omitting some sample plugins) --- plugins/markasjunk/junk_act.png | Bin 0 -> 1995 bytes plugins/markasjunk/junk_pas.png | Bin 0 -> 1988 bytes plugins/markasjunk/localization/en_US.inc | 7 +++++ plugins/markasjunk/markasjunk.js | 28 ++++++++++++++++++ plugins/markasjunk/markasjunk.php | 47 ++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 plugins/markasjunk/junk_act.png create mode 100644 plugins/markasjunk/junk_pas.png create mode 100644 plugins/markasjunk/localization/en_US.inc create mode 100644 plugins/markasjunk/markasjunk.js create mode 100644 plugins/markasjunk/markasjunk.php (limited to 'plugins/markasjunk') diff --git a/plugins/markasjunk/junk_act.png b/plugins/markasjunk/junk_act.png new file mode 100644 index 000000000..b5a84f604 Binary files /dev/null and b/plugins/markasjunk/junk_act.png differ diff --git a/plugins/markasjunk/junk_pas.png b/plugins/markasjunk/junk_pas.png new file mode 100644 index 000000000..b88a561a4 Binary files /dev/null and b/plugins/markasjunk/junk_pas.png differ diff --git a/plugins/markasjunk/localization/en_US.inc b/plugins/markasjunk/localization/en_US.inc new file mode 100644 index 000000000..6f63e161a --- /dev/null +++ b/plugins/markasjunk/localization/en_US.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/plugins/markasjunk/markasjunk.js b/plugins/markasjunk/markasjunk.js new file mode 100644 index 000000000..8b02d7438 --- /dev/null +++ b/plugins/markasjunk/markasjunk.js @@ -0,0 +1,28 @@ +/* Mark-as-Junk plugin script */ + +function rcmail_markasjunk(prop) +{ + if (!rcmail.env.uid && (!rcmail.message_list || !rcmail.message_list.get_selection().length)) + return; + + var uids = rcmail.env.uid ? rcmail.env.uid : rcmail.message_list.get_selection().join(','); + + rcmail.set_busy(true, 'loading'); + rcmail.http_post('plugin.markasjunk', '_uid='+uids+'&_mbox='+urlencode(rcmail.env.mailbox), true); +} + +// callback for app-onload event +if (window.rcmail) { + rcmail.addEventListener('init', function(evt) { + + // register command (directly enable in message view mode) + rcmail.register_command('plugin.markasjunk', rcmail_markasjunk, rcmail.env.uid); + + // add event-listener to message list + if (rcmail.message_list) + rcmail.message_list.addEventListener('select', function(list){ + rcmail.enable_command('plugin.markasjunk', list.get_selection().length > 0); + }); + }) +} + diff --git a/plugins/markasjunk/markasjunk.php b/plugins/markasjunk/markasjunk.php new file mode 100644 index 000000000..959111d84 --- /dev/null +++ b/plugins/markasjunk/markasjunk.php @@ -0,0 +1,47 @@ +register_action('plugin.markasjunk', array($this, 'request_action')); + $GLOBALS['IMAP_FLAGS']['JUNK'] = 'Junk'; + + $rcmail = rcmail::get_instance(); + if ($rcmail->action == '' || $rcmail->action == 'show') { + $this->include_script('markasjunk.js'); + $this->add_texts('localization', true); + $this->add_button(array('command' => 'plugin.markasjunk', 'imagepas' => 'junk_pas.png', 'imageact' => 'junk_act.png'), 'toolbar'); + } + } + + function request_action() + { + $this->add_texts('localization'); + + $uids = get_input_value('_uid', RCUBE_INPUT_POST); + $mbox = get_input_value('_mbox', RCUBE_INPUT_POST); + + $rcmail = rcmail::get_instance(); + $rcmail->imap->set_flag($uids, 'JUNK'); + + if (($junk_mbox = $rcmail->config->get('junk_mbox')) && $mbox != $junk_mbox) { + $rcmail->output->command('move_messages', $junk_mbox); + } + + $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation'); + $rcmail->output->send(); + } + +} \ No newline at end of file -- cgit v1.2.3