0

I am looking for a quick way to disable all the buttons from the Roundcube menu bar for only one specific folder:

enter image description here

I'm saving, using a PHP script, emails into a specific "Mails Groupés" folder on the imap server. This results in the mails being visible through Roundcube (which is a feature I want to keep), but also able to be forward, sent... And I absolutely don't want that, so I'd like to disable the top bar buttons, as a temporary solution.

I'm sure this is possible to achieve using a Roundcube plugin, but I didn't get my head around Roundcube plugin development that much yet, I would really appreciate some help while I'm still looking for the answer.

halfer
  • 19,824
  • 17
  • 99
  • 186
Remy San
  • 525
  • 1
  • 4
  • 24

1 Answers1

2

Ok, so I managed to find an answer.

Using the guide to build plugins for Roundcube, I set up a "no_forward_for_groupes" plugin, in the [roundcubeRoot]/plugin/no_forward_for_groupes folder. I activated it in the [roundcubeRoot]/config/config.inc.php file by wrtiting

$config['plugins'] = array('no_forward_for_groupes');

as any other plugin.

After a bit of reading and research in the [roundcubeRoot]/program/js/app.js file (the core JS of Roundcube), I found the object I need to act with and the events to listen. The final code is just after. As you can see, I disabled a lot of other commands, as well as drag and drop. So basically I have a read-only folder, which you can't get any mails out of. I know it's kind of a specific use-case, but I hope it'll help some folks out there someday!

no_forward_for_groupes.php

<?php
/**
 * No Forward For Groups
 *
 * This plugin disables the Send / Forward menus from the Mails_Groupes folder
 *
 * @version 0.1
 * @author Remy Sanfeliu
 */
class no_forward_for_groupes extends rcube_plugin
{
  public $task = 'mail';

  function init(){
    $this->include_script('no_forward_for_groupes.js');
  }

}

no_forward_for_groupes.js

/**
 * No Forward For Groups
 *
 * This plugin disables the Send / Forward menus from the Mails_Groupes folder
 *
 * @version 0.1
 * @author Remy Sanfeliu
 */

window.rcmail.addEventListener('listupdate', function(folder, old) {

    if (folder.folder=="SENT.Mails_Groupes"){
        window.rcmail.message_list.addEventListener('select', select_msglist);
        window.rcmail.message_list.addEventListener('dragstart', do_nothing);
        window.rcmail.message_list.addEventListener('dragmove', do_nothing);
        window.rcmail.message_list.addEventListener('dragend', do_nothing);
    }else{
        window.rcmail.message_list.removeEventListener('select', select_msglist);
        window.rcmail.message_list.removeEventListener('dragstart', do_nothing);
        window.rcmail.message_list.removeEventListener('dragmove', do_nothing);
        window.rcmail.message_list.removeEventListener('dragend', do_nothing);
    }

});


function select_msglist(list){
    window.rcmail.enable_command(   'reply',
                                    'reply-all',
                                    'reply-list',
                                    'move',
                                    'copy',
                                    'delete',
                                    'mark',
                                    'edit',
                                    'forward',
                                    'forward-attachment',
                                    'forward-inline',

                                    false);
}

function do_nothing(){
    // DO NOTHING
}
Remy San
  • 525
  • 1
  • 4
  • 24