douyou7072 2014-10-11 14:21
浏览 28

用于禁用Roundcube中一个文件夹的“转发”按钮的插件

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.

  • 写回答

1条回答 默认 最新

  • dongye9991 2014-10-12 10:03
    关注

    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
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看