0

我正在寻找一种快速方法来禁用 Roundcube 菜单栏中的所有按钮,仅针对一个特定文件夹:

在此处输入图像描述

我正在使用 PHP 脚本将电子邮件保存到 imap 服务器上的特定“Mails Groupés”文件夹中。这导致邮件通过 Roundcube 可见(这是我想要保留的功能),但也能够转发、发送......我绝对不希望这样,所以我想禁用顶部栏按钮,作为临时解决方案。

我确信使用 Roundcube 插件可以实现这一点,但是我还没有对 Roundcube 插件开发有太多了解,在我仍在寻找答案时,我真的很感激一些帮助。

4

1 回答 1

2

好的,所以我设法找到了答案。

使用为 Roundcube 构建插件的指南[roundcubeRoot]/plugin/no_forward_for_groupes,我在文件夹中设置了一个“no_forward_for_groupes”插件。我[roundcubeRoot]/config/config.inc.php通过 wrtiting 在文件中激活了它

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

与任何其他插件一样。

在对[roundcubeRoot]/program/js/app.js文件(Roundcube 的核心 JS)进行了一些阅读和研究之后,我找到了我需要操作的对象和要监听的事件。最终代码就在后面。如您所见,我禁用了许多其他命令,以及拖放。所以基本上我有一个只读文件夹,你不能从中取出任何邮件。我知道这是一个特定的用例,但我希望有一天它会帮助一些人!

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
}
于 2014-10-12T10:03:43.057 回答