Author Topic: Spam Buttons  (Read 9750 times)

Offline g1zmo

  • Newbie
  • *
  • Posts: 1
Spam Buttons
« on: October 09, 2008, 04:00:24 PM »
I'd like to second this request

A feature like Squirrelmail's Spam Buttons plugin, which adds "Spam" and "Not Spam" buttons/icons/whatever to the page, with an admin-configurable action taken when the button is clicked.

For example, I use it to simply move the current or marked message(s) to the user's Junk folder, where a nightly cron job will run sa-learn on the user's Junk folder and then empty it.

Offline fms

  • Jr. Member
  • **
  • Posts: 13
MoveToSpam button
« Reply #1 on: June 24, 2009, 09:10:40 AM »
I think a button to move messages to SPAM folder would be pretty good ;-)

This new button acts like "del button" that moves msg to "trash Folder".
It instantly moves the message to "Junk folder".

Howto RoundCube add "movetospam" button:
==========================================================

###1) COPY  folder skin/default to skin/movespambutton
- we will not mess with default skin
- all "changes" below are marked as // START CHANGE and //END CHANGE


###2) EDIT /index.php
...
// map task/action to a certain include file
$action_map = array(
'mail' => array(
'preview' => 'show.inc',
'print'   => 'show.inc',
'moveto'  => 'move_del.inc',
'delete'  => 'move_del.inc',
// START CHANGE
   'movetospam' => 'move_del.inc',
// END CHANGE
'send'    => 'sendmail.inc',
'expunge' => 'folders.inc',
'purge'   => 'folders.inc',
'remove-attachment'  => 'attachments.inc',
'display-attachment' => 'attachments.inc',
'upload' => 'attachments.inc',
),
...

###3) EDIT /skins/movespambutton/templates/mail.html

...

// START CHANGE
   
// END CHANGE

...

###4) EDIT /skins/movespambutton/templates/message/message.html

...

// START CHANGE
   
// END CHANGE

...

###5) EDIT /skins/movespambutton/mail.css

...
#messagetoolbar select.mboxlist
{
  position: absolute;
// START CHANGE
  left: 415px;
// END CHANGE
  top: 8px;
}

###6) EDIT /program/steps/mail/move_del.in

...
// move messages
if ($RCMAIL->action=='moveto' && !empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) {
    $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
    $target = get_input_value('_target_mbox', RCUBE_INPUT_POST);
    $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);

    // flag messages as read before moving them
    if ($CONFIG['read_when_deleted'] && $target == $CONFIG['trash_mbox'])
   $IMAP->set_flag($uids, 'SEEN');

    $moved = $IMAP->move_message($uids, $target, $mbox);
 
    if (!$moved) {
        // send error message
        $OUTPUT->command('list_mailbox');
        $OUTPUT->show_message('errormoving', 'error');
        $OUTPUT->send();
        exit;
    }

    if (!$CONFIG['flag_for_deletion'])
        $addrows = true;
}
//START CHANGE
// move to junk
else if ($RCMAIL->action=='movetospam' && !empty($_POST['_uid']) ) {
    $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
    // set target=Junk
    $target = $CONFIG['junk_mbox'];

    $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
   
    $moved = $IMAP->move_message($uids, $target, $mbox);
 
    if (!$moved) {
        // send error message
        $OUTPUT->command('list_mailbox');
        $OUTPUT->show_message('errormoving', 'error');
        $OUTPUT->send();
        exit;
    }

    if (!$CONFIG['flag_for_deletion'])
        $addrows = true;
}
//END CHANGE

// delete messages
else if ($RCMAIL->action=='delete' && !empty($_POST['_uid'])) {
    $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
    $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
    $del = $IMAP->delete_message($uids, $mbox);
...


###7) EDIT /program/js/app.js

find: "moveto"
replace-with: "moveto","movetospam"

find: case "moveto","movetospam":
replace-with: case "moveto":

find: this.command("moveto","movetospam",_62[this.env.last_folder_target].id);
replace-with: this.command("moveto",_62[this.env.last_folder_target].id);

find: this._with_selected_messages("moveto","movetospam",_a8,_a9,(this.env.flag_for_deletion?false:true));
replace-with: this._with_selected_messages("moveto",_a8,_a9,(this.env.flag_for_deletion?false:true));

-----------------------------
...
break;
case "delete":
if(this.task=="mail"){
this.delete_messages();
}else{
if(this.task=="addressbook"){
this.delete_contacts();
}else{
if(this.task=="settings"){
this.delete_identity();
}
}
}
break;
// START CHANGE
   case "movetospam":
   if(this.task=="mail"){   
   this.move_messages('Junk');
   }
   break;
// END CHANGE
case "move":
case "moveto":
if(this.task=="mail"){   
this.move_messages(_40);
}else{
if(this.task=="addressbook"&&this.drag_active){
this.copy_contact(null,_40);
}
}
break;
case "mark":
...
-----------------------------
...
switch(_20b.__action){
case "delete":
if(this.task=="addressbook"){
var uid=this.contact_list.get_selection();
this.enable_command("compose",(uid&&this.contact_list.rows[uid]));
this.enable_command("delete","EDIT",(uid&&this.contact_list.rows[uid]&&this.env.address_sources&&!this.env.address_sources[this.env.source].readonly));
this.enable_command("export",(this.contact_list&&this.contact_list.rowcount>0));
}
// START CHANGE
   case "moveto":
   case "movetospam":
// END CHANGE
if(this.env.action=="show"){
this.command("list");
}else{
if(this.message_list){
this.message_list.init();
}
}
break;
case "purge":
...

###8) EDIT /program/localization/enUS

add this line:
$labels['movemessagetospam'] = 'Move message to SPAM/JUNK';


###9) ON FOLDER: /skins/movespambutton/images/buttons

cp delete_act.png spam_act.png
cp delete_pas.png spam_pas.png
cp delete_sel.png spam_sel.png

USE AN IMAGE EDITOR ON:
spam_act.png, spam_pas.png and spam_sel.png

* here, we used the original "delete_xxx.png" as simbol to "move to spam"
* and  we created a new "delete_xxx.png" with a "red X" simbol to represent "delete action"

==========================================================
Francisco

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,868
Spam Buttons
« Reply #2 on: June 25, 2009, 03:08:02 AM »
There is also a markasjunk plugin in the SVN which works with 0.3b and SVN trunk
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and moreā€¦

Offline corbosman

  • Sr. Member
  • ****
  • Posts: 260
Spam Buttons
« Reply #3 on: June 26, 2009, 08:02:42 AM »
Ive made most of the functionality of a report as spam plugin (bit of an overlap with markasjunk), but what would be cool is if there was a supported way to replace a button depending on which folder you're in (or depending whatever you want). I have hacked this right now, but it's a bit ugly.  This is a necessity for a report as spam/report as not spam button set.

Offline jeffski

  • Newbie
  • *
  • Posts: 2
Spam Buttons
« Reply #4 on: May 22, 2010, 04:16:39 AM »
Will try and get one off these spam plug-ins working, looks a bit complicated though. Would be great if a mark as spam button came as standard that moved the selected messages to the junk folder.

gameover

  • Guest
Spam Buttons
« Reply #5 on: March 30, 2011, 10:46:36 AM »
try with markasjunk plugin,it may be useful............
« Last Edit: March 31, 2011, 06:19:44 AM by gameover »