From 58e913ce1b34f4bb0cd1fef765231d16adb2564a Mon Sep 17 00:00:00 2001 From: Giam Teck Choon Date: Thu, 12 Sep 2024 15:54:49 +0800 Subject: [PATCH 1/3] Remove plugins/markasjunk/markasjunk.min.js Signed-off-by: Giam Teck Choon --- plugins/markasjunk/markasjunk.min.js | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 plugins/markasjunk/markasjunk.min.js diff --git a/plugins/markasjunk/markasjunk.min.js b/plugins/markasjunk/markasjunk.min.js deleted file mode 100644 index 08cff4b..0000000 --- a/plugins/markasjunk/markasjunk.min.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Mark-as-Junk plugin script - * - * @licstart The following is the entire license notice for the - * JavaScript code in this file. - * - * Copyright (c) The Roundcube Dev Team - * Copyright (C) Philip Weir - * - * The JavaScript code in this page is free software: you can redistribute it - * and/or modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * @licend The above is the entire license notice - * for the JavaScript code in this file. - */ -rcube_webmail.prototype.markasjunk_mark=function(a){var n,e=this.env.uid?[this.env.uid]:this.message_list.get_selection();e&&(n=this.set_busy(!0,"loading"),this.http_post("plugin.markasjunk."+(a?"junk":"not_junk"),this.selection_post_data({_uid:e}),n))},rcube_webmail.prototype.markasjunk_move=function(a,n){var e=this.env.uid;this.message_list&&1==n.length&&!this.message_list.in_selection(n[0])&&(this.env.uid=n[0]),a?this.move_messages(a):1==this.env.markasjunk_permanently_remove?this.permanently_remove_messages():this.delete_messages(),this.env.uid=e},rcube_webmail.prototype.markasjunk_toggle_button=function(){var m=$("a.junk"),s=$("a.notjunk"),t={spam:!0,ham:!0};this.env.markasjunk_spam_only?t.ham=!1:!this.is_multifolder_listing()&&this.env.markasjunk_spam_mailbox&&(this.env.mailbox!=this.env.markasjunk_spam_mailbox?t.ham=!1:t.spam=!1),$.each(m,function(a){var n=m.eq(a),e=s.eq(a),a=m.eq(a).index(),i=(0e.index()&&e.insertAfter(n))})},rcube_webmail.prototype.markasjunk_is_spam_mbox=function(){return!this.is_multifolder_listing()&&this.env.mailbox==this.env.markasjunk_spam_mailbox},window.rcmail&&(rcmail.addEventListener("init",function(){rcmail.register_command("plugin.markasjunk.junk",function(){rcmail.markasjunk_mark(!0)},!rcmail.markasjunk_is_spam_mbox()&&rcmail.env.uid),rcmail.register_command("plugin.markasjunk.not_junk",function(){rcmail.markasjunk_mark(!1)},rcmail.env.uid),rcmail.message_list&&rcmail.message_list.addEventListener("select",function(a){rcmail.enable_command("plugin.markasjunk.junk",!rcmail.markasjunk_is_spam_mbox()&&0 Date: Tue, 22 Aug 2023 21:29:01 +0800 Subject: [PATCH 2/3] Add IsSpam and NotSpam support Signed-off-by: Giam Teck Choon --- plugins/markasjunk/markasjunk.js | 9 ++++++--- plugins/markasjunk/markasjunk.php | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/markasjunk/markasjunk.js b/plugins/markasjunk/markasjunk.js index 91ac19f..1ea15dc 100644 --- a/plugins/markasjunk/markasjunk.js +++ b/plugins/markasjunk/markasjunk.js @@ -49,8 +49,8 @@ rcube_webmail.prototype.markasjunk_toggle_button = function() { if (this.env.markasjunk_spam_only) { disp.ham = false; } - else if (!this.is_multifolder_listing() && this.env.markasjunk_spam_mailbox) { - if (this.env.mailbox != this.env.markasjunk_spam_mailbox) + else if (!this.is_multifolder_listing() && (this.env.markasjunk_spam_mailbox || this.env.markasjunk_isspam_mailbox)) { + if (this.env.mailbox != this.env.markasjunk_spam_mailbox && this.env.mailbox != this.env.markasjunk_isspam_mailbox) disp.ham = false; else disp.spam = false; @@ -89,7 +89,7 @@ rcube_webmail.prototype.markasjunk_toggle_button = function() { } rcube_webmail.prototype.markasjunk_is_spam_mbox = function() { - return !this.is_multifolder_listing() && this.env.mailbox == this.env.markasjunk_spam_mailbox; + return !this.is_multifolder_listing() && (this.env.mailbox == this.env.markasjunk_spam_mailbox || this.env.mailbox == this.env.markasjunk_isspam_mailbox); } if (window.rcmail) { @@ -125,6 +125,9 @@ if (window.rcmail) { // check if destination mbox equals junk box (and we're not already in the junk box) if (rcmail.env.markasjunk_move_spam && mbox == rcmail.env.markasjunk_spam_mailbox && mbox != rcmail.env.mailbox) is_spam = true; + // check if destination mbox equals junk box (and we're not already in the isjunk box) + else if (rcmail.env.markasjunk_move_spam && mbox && mbox == rcmail.env.markasjunk_isspam_mailbox && mbox != rcmail.env.mailbox) + is_spam = true; // or if destination mbox equals ham box and we are in the junk box else if (rcmail.env.markasjunk_move_ham && mbox == rcmail.env.markasjunk_ham_mailbox && rcmail.env.mailbox == rcmail.env.markasjunk_spam_mailbox) is_spam = false; diff --git a/plugins/markasjunk/markasjunk.php b/plugins/markasjunk/markasjunk.php index 8cb939e..48f9d5d 100644 --- a/plugins/markasjunk/markasjunk.php +++ b/plugins/markasjunk/markasjunk.php @@ -63,8 +63,9 @@ class markasjunk extends rcube_plugin return; } - $this->ham_mbox = $this->rcube->config->get('markasjunk_ham_mbox', 'INBOX'); + $this->ham_mbox = $this->rcube->config->get('markasjunk_ham_mbox', $this->rcube->config->get('isham_mbox') ? $this->rcube->config->get('isham_mbox') : 'INBOX'); $this->spam_mbox = $this->rcube->config->get('markasjunk_spam_mbox', $this->rcube->config->get('junk_mbox')); + $this->isspam_mbox = $this->rcube->config->get('markasjunk_isspam_mbox', $this->rcube->config->get('isjunk_mbox') ? $this->rcube->config->get('isjunk_mbox') : $this->rcube->config->get('junk_mbox')); $toolbar = $this->rcube->config->get('markasjunk_toolbar', true); $this->_init_flags(); @@ -123,6 +124,7 @@ class markasjunk extends rcube_plugin // add markasjunk folder settings to the env for JS $this->rcube->output->set_env('markasjunk_ham_mailbox', $this->ham_mbox); $this->rcube->output->set_env('markasjunk_spam_mailbox', $this->spam_mbox); + $this->rcube->output->set_env('markasjunk_isspam_mailbox', $this->isspam_mbox); $this->rcube->output->set_env('markasjunk_move_spam', $this->rcube->config->get('markasjunk_move_spam', false)); $this->rcube->output->set_env('markasjunk_move_ham', $this->rcube->config->get('markasjunk_move_ham', false)); $this->rcube->output->set_env('markasjunk_permanently_remove', $this->rcube->config->get('markasjunk_permanently_remove', false)); @@ -141,7 +143,7 @@ class markasjunk extends rcube_plugin $uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST); $mbox_name = rcube_utils::get_input_string('_mbox', rcube_utils::INPUT_POST); $messageset = rcmail::get_uids($uids, $mbox_name, $multifolder); - $dest_mbox = $is_spam ? $this->spam_mbox : $this->ham_mbox; + $dest_mbox = $is_spam ? ($this->isspam_mbox ? $this->isspam_mbox : $this->spam_mbox) : $this->ham_mbox; // special case when select all is used, uid is '*', and not in multi folder mode and we are using a driver // rcmail::get_uids does not handle this -- 2.43.0 From f1aa273263b10d01f19ae1e2d91045eff48763f7 Mon Sep 17 00:00:00 2001 From: Giam Teck Choon Date: Thu, 12 Sep 2024 15:54:50 +0800 Subject: [PATCH 3/3] uglifyjs plugins/markasjunk/markasjunk.js -o plugins/markasjunk/markasjunk.min.js Signed-off-by: Giam Teck Choon --- plugins/markasjunk/markasjunk.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 plugins/markasjunk/markasjunk.min.js diff --git a/plugins/markasjunk/markasjunk.min.js b/plugins/markasjunk/markasjunk.min.js new file mode 100644 index 0000000..9d82ca3 --- /dev/null +++ b/plugins/markasjunk/markasjunk.min.js @@ -0,0 +1 @@ +rcube_webmail.prototype.markasjunk_mark=function(is_spam){var uids=this.env.uid?[this.env.uid]:this.message_list.get_selection();if(!uids)return;var lock=this.set_busy(true,"loading");this.http_post("plugin.markasjunk."+(is_spam?"junk":"not_junk"),this.selection_post_data({_uid:uids}),lock)};rcube_webmail.prototype.markasjunk_move=function(mbox,uids){var prev_uid=this.env.uid;if(this.message_list&&uids.length==1&&!this.message_list.in_selection(uids[0]))this.env.uid=uids[0];if(mbox)this.move_messages(mbox);else if(this.env.markasjunk_permanently_remove==true)this.permanently_remove_messages();else this.delete_messages();this.env.uid=prev_uid};rcube_webmail.prototype.markasjunk_toggle_button=function(){var spamobj=$("a.junk"),hamobj=$("a.notjunk"),disp={spam:true,ham:true};if(this.env.markasjunk_spam_only){disp.ham=false}else if(!this.is_multifolder_listing()&&(this.env.markasjunk_spam_mailbox||this.env.markasjunk_isspam_mailbox)){if(this.env.mailbox!=this.env.markasjunk_spam_mailbox&&this.env.mailbox!=this.env.markasjunk_isspam_mailbox)disp.ham=false;else disp.spam=false}$.each(spamobj,function(i){var cur_spamobj=spamobj.eq(i),cur_hamobj=hamobj.eq(i),cur_index=spamobj.eq(i).index();if(cur_spamobj.parent("li").length>0){cur_spamobj=cur_spamobj.parent();cur_hamobj=cur_hamobj.parent()}var evt_rtn=rcmail.triggerEvent("markasjunk-update",{objs:{spamobj:cur_spamobj,hamobj:cur_hamobj},disp:disp});if(evt_rtn&&evt_rtn.abort)return;disp=evt_rtn?evt_rtn.disp:disp;disp.spam?cur_spamobj.show():cur_spamobj.hide();disp.ham?cur_hamobj.show():cur_hamobj.hide();if(disp.spam&&!disp.ham){if(cur_indexcur_hamobj.index()){cur_hamobj.insertAfter(cur_spamobj)}})};rcube_webmail.prototype.markasjunk_is_spam_mbox=function(){return!this.is_multifolder_listing()&&(this.env.mailbox==this.env.markasjunk_spam_mailbox||this.env.mailbox==this.env.markasjunk_isspam_mailbox)};if(window.rcmail){rcmail.addEventListener("init",function(){rcmail.register_command("plugin.markasjunk.junk",function(){rcmail.markasjunk_mark(true)},!rcmail.markasjunk_is_spam_mbox()&&rcmail.env.uid);rcmail.register_command("plugin.markasjunk.not_junk",function(){rcmail.markasjunk_mark(false)},rcmail.env.uid);if(rcmail.message_list){rcmail.message_list.addEventListener("select",function(list){rcmail.enable_command("plugin.markasjunk.junk",!rcmail.markasjunk_is_spam_mbox()&&list.get_selection(false).length>0);rcmail.enable_command("plugin.markasjunk.not_junk",list.get_selection(false).length>0)})}rcmail.markasjunk_toggle_button()});rcmail.addEventListener("listupdate",function(){rcmail.markasjunk_toggle_button()});rcmail.addEventListener("beforemove",function(mbox){if(mbox&&typeof mbox==="object"){mbox=mbox.id}if(!mbox){return}var is_spam=null;if(rcmail.env.markasjunk_move_spam&&mbox==rcmail.env.markasjunk_spam_mailbox&&mbox!=rcmail.env.mailbox)is_spam=true;else if(rcmail.env.markasjunk_move_spam&&mbox&&mbox==rcmail.env.markasjunk_isspam_mailbox&&mbox!=rcmail.env.mailbox)is_spam=true;else if(rcmail.env.markasjunk_move_ham&&mbox==rcmail.env.markasjunk_ham_mailbox&&rcmail.env.mailbox==rcmail.env.markasjunk_spam_mailbox)is_spam=false;if(is_spam!==null){rcmail.markasjunk_mark(is_spam);return false}})} \ No newline at end of file -- 2.43.0