summaryrefslogtreecommitdiff
path: root/plugins/markasjunk
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/markasjunk')
-rw-r--r--plugins/markasjunk/junk_act.pngbin0 -> 1995 bytes
-rw-r--r--plugins/markasjunk/junk_pas.pngbin0 -> 1988 bytes
-rw-r--r--plugins/markasjunk/localization/en_US.inc7
-rw-r--r--plugins/markasjunk/markasjunk.js28
-rw-r--r--plugins/markasjunk/markasjunk.php47
5 files changed, 82 insertions, 0 deletions
diff --git a/plugins/markasjunk/junk_act.png b/plugins/markasjunk/junk_act.png
new file mode 100644
index 000000000..b5a84f604
--- /dev/null
+++ b/plugins/markasjunk/junk_act.png
Binary files differ
diff --git a/plugins/markasjunk/junk_pas.png b/plugins/markasjunk/junk_pas.png
new file mode 100644
index 000000000..b88a561a4
--- /dev/null
+++ b/plugins/markasjunk/junk_pas.png
Binary files 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 @@
+<?php
+
+$labels = array();
+$labels['buttontitle'] = 'Mark as Junk';
+$labels['reportedasjunk'] = 'Successfully reported as Junk';
+
+?> \ 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 @@
+<?php
+
+/**
+ * Mark as Junk
+ *
+ * Sample plugin that adds a new button to the mailbox toolbar
+ * to mark the selected messages as Junk and move them to the Junk folder
+ *
+ * @version 1.0
+ * @author Thomas Bruederli
+ */
+class markasjunk extends rcube_plugin
+{
+ public $task = 'mail';
+
+ function init()
+ {
+ $this->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