Confluence 空间附件下载/页面导出权限控制

概述

两种思路:

  1. 通过修改html代码,控制相关控件的显示,来实现权限控制;
  2. 通过修改velocity 文件来调整控件显示;

自定义HTML隐藏附件下载和页面导出按钮

在confluence上面的工具栏,点击【设置】-【General Configuration】-【Custom HTML】-"At end of the BODY"添加的代码如下:

<script type="text/javascript">
    $(document).ready(function(){
    $('body').bind("DOMNodeInserted",function(e){
        if(AJS.params.spaceKey=="**")    // **表示空间标识
        {
            if(AJS.params.canRemovePage==false)   //当用户没有删除页面的权限时
            {
                $('.cp-control-panel-download').hide();  //隐藏可以预览的附件(word或pdf)下载按钮
                $('.cp-button').hide();                  //隐藏不能预览的附件(压缩文件或者其他不支持预览的)下载按钮
                $(".filename").attr("disabled",true).css("pointer-events","none"); //把文件列表模式下的附件设置为灰色
          $('head').append('<style> @media print{html, body{display:none} } </style> ');//禁用页面打印 
          $('body').attr('oncontextmenu','self.event.returnValue=false');  //禁用右键菜单
          $('body').attr('onselectstart','return false');    //禁用选中文字
            }
        }
  })    
    AJS.toInit(function(){
        if(AJS.params.spaceKey=="**")
        {
            if(AJS.params.canRemovePage==false)
            {
                AJS.$('#action-export-word-link').hide(); //隐藏导出为word按钮
                AJS.$('#action-export-pdf-link').hide();  //隐藏导出为pdf按钮
                AJS.$('#view-attachments-link').hide();   //隐藏附件按钮
              $('head').append('<style> @media print{html, body{display:none} } </style> ');//禁用页面打印 
          $('body').attr('oncontextmenu','self.event.returnValue=false');  //禁用右键菜单
          $('body').attr('onselectstart','return false');    //禁用选中文字
            }
        }
    });})
</script>

Hide the download button on the preview page

Space Tools–Look and feel–Layout–Content Layouts—Page Layout

<style type="text/css">
     .cp-control-panel-download {
        display:none !important;
    }
       .cp-waiting-message-download {
        display:none !important;
    }
      a.download-all-link {
        display: none !important;
     }
      a#download-all-link {
        display: none !important;
     }
 </style>

Hide attachment button

Space Tools–Look and feel–Layout–Content Layouts—Main Layout

#if ($userAccessor.hasMembership('confluence-administrators', $helper.action.remoteUser.name))
#else
    <script type="text/javascript">
    AJS.toInit(function(){
        AJS.$('#view-attachments-link').hide();
        AJS.$('#view-in-hierarchy-link').hide();
        AJS.$('#content-metadata-attachments').hide();
    });
</script>
#end

#if ($userAccessor.hasMembership('confluence-administrators', $helper.action.remoteUser.name))
#else
    <script type="text/javascript">
    AJS.toInit(function(){
AJS.$('#space-tools-menu-trigger').hide();
    });
</script>
#end

disable right mouse click

Space Tools–Look and feel–Layout–Content Layouts—Page Layout

<script type="application/javascript">
 content_dom = document.getElementsByClassName("confluence-embedded-file");
 for (var i = 0; i < content_dom.length; i++) {
content_dom[i].oncontextmenu = function () {
return false;
 }
}
a_dom = document.querySelectorAll('a[data-linked-resource-type="attachment"]')
for (var i = 0; i < a_dom.length; i++) {
a_dom[i].oncontextmenu = function () {
return false;
 }
}
</script>

print out a blank page

Space Tools–Look and feel–Layout–Content Layouts—Page Layout

 <style type="text/css" media="print">
     body { visibility: hidden; display: none }
 </style>

Disable attachments for a whole Space

修改 listattachmentsforspace.vm文件,参考Disable attachments for a whole Space

Disable attachments for a specific page

修改 attachments-table.vm文件,参考Disable attachments for a specific page

更多参考

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值