SharePoint 2007 (MOSS/WSS) - how to remove "Download a Copy" context menu from a Document Library

One of my friend and colleague asked me this question. I found it tricky and a good post for my blog. Here is what you have to do:

Go to your 12 hive\TEMPLATE\LAYOUTS\1033 folder. Open up the Core.js file. Find the function AddSendSubMenu. Go to the last 3 lines:

strAction = "STSNavigate(‘" + ctx.HttpRoot + "/_layouts/download.aspx?" + "SourceUrl=" + currentItemEscapedFileUrl + "&Source=" + GetSource() + "&FldUrl=" + escapeProperly(ctx.SendToLocationUrl) + "‘)"; ;
 menuOption = CAMOpt(sm, L_DownloadACopy_Text, strAction, "");
 menuOption.id = "ID_DownloadACopy";

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Now if you want to remove "Download a Copy" option from all the document libraries then comment all three lines.

If you want to remove it for some custom List Definition that you have created you may do like:

if(ctx.listTemplate !=10001)
{

strAction = "STSNavigate(‘" + ctx.HttpRoot + "/_layouts/download.aspx?" + "SourceUrl=" + currentItemEscapedFileUrl + "&Source=" + GetSource() + "&FldUrl=" + escapeProperly(ctx.SendToLocationUrl) + "‘)"; ;
 menuOption = CAMOpt(sm, L_DownloadACopy_Text, strAction, "");
 menuOption.id = "ID_DownloadACopy";
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Where 10001 was your custom list template id.

If you want to do it for a specific Document Library then you would do like this:

if(ctx.listName !="{28958B49-8C76-4987-815C-CF5A107FF522}")
{

strAction = "STSNavigate(‘" + ctx.HttpRoot + "/_layouts/download.aspx?" + "SourceUrl=" + currentItemEscapedFileUrl + "&Source=" + GetSource() + "&FldUrl=" + escapeProperly(ctx.SendToLocationUrl) + "‘)"; ;
 menuOption = CAMOpt(sm, L_DownloadACopy_Text, strAction, "");
 menuOption.id = "ID_DownloadACopy";
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

As you can see you have to pass the list GUID as listName.

时间: 2024-08-23 10:39:40

SharePoint 2007 (MOSS/WSS) - how to remove "Download a Copy" context menu from a Document Library的相关文章

SharePoint Designer定制MOSS/WSS表单页面

SharePoint Designer定制MOSS/WSS表单页面 分类: sharepoint 学习札记2011-12-20 15:07 825人阅读 评论(0) 收藏 举报 sharepointserverbordertableclassassembly 方法一.使用SharePoint Designer配合enderingTemplate文件来定制MOSS/WSS表单页面 以通知列表(DispForm.aspx)为例,系统默认的通知列表样式如下: 默认样式用于新闻发布的时候确实不符合中国人

Extending your SharePoint 2007 site with Microsoft ASP.NET AJAX 3.5

After ASP.NET 3.5 has been installed you need to modify the web.config file of your MOSS web site with a few Ajax specific entries. Typically, the web.config file is located in c:\inetpub\wwwroot\wss\virtualdirectories\80 1. Add the following <sectio

windows 7 打开sharepoint 2007上的office文档需要输入用户名和密码

在windows 7 的机器上直接打开sharepoint网站正常,但是打开sharepoint 2007上的office文档需要输入用户名和密码. 已加入域.域中xp系统正常. 问题主要是windows 7和vista系统本身导致的 按微软kb的方法修改注册表: After you apply this hotfix, you have to create a registry entry. To do this, follow these steps: Click Start, type r

sharepoint 2007 为导航添加链接不成功

sharepoint 2007 需要将某个文档的url添加到左侧的导航栏,实现快速访问. 在Site Navigation Settings 中设置的时候没有提示任何错误,点击确定的时候,在Navigation Editing and Sorting 中也看到设置成功,但在网站左侧的导航栏看不到设置的链接. 最后发现是要建立导航指向的url字符串过多(超过255),如下地址: http://2003r2-03/Shared%20Documents/Forms/AllItems.aspx?Root

sharepoint 2007 “文件为网络下载文件,请存储到硬盘之后再修改文件。”

当直接打开sharepoint 2007 上的excel文档后,使用使用ctrl+s保存的时候,就弹出对话框"文件为网络下载文件,请存储到硬盘之后再修改文件." 检查发现是sharepoint上安装了第三方加密工具trustview导致的. 解决办法:1.点击保存按钮保存 2.使用"迁出"后,打开文档 3.在excel中关闭trustview插件: excel options--add-ins--mamage下面选择com add-ins--然后点Go--取消选择:

SQL Server 2008 VS 2005 Reporting Services 整合SharePoint 2007 支持比较Part1

摘要:SQL Server 2008 VS 2005 Reporting Services 整合SharePoint 2007 支持比较Part1 最近遇到客户问SQL 2005 Reporting Services 整合SharePoint 模式中的数据驱动订阅.后来发现在2005跟本不支持.因此为了这个我又去做了2008 跟2005的比较后来才发现2008支持了.=_=有没有搞错呀...2005未何不支持勒.(看来我客户要失望了) Part 1.为目前支持部分比较表如下. 说明 2008 2

sharepoint 2007 更新

1.确定升级的类型,主要分为Service Pack(SP).累积更新 (CU).关键的按需提供 (COD) 修补程序.基础结构更新 (IU)四种,一般主要是升级前面两种补丁. 1)         Service Pack: SP的版本为sp1(12.0.6219.1000).sp2(12.0.0.6421.1000).sp3(12.0.6612.1000),可以直接升级最新的SP版本: 2)         累积更新 (CU):CU的版本非常多,详情见后面的链接,升级不能跨SP升级,例如,不

sharepoint 2007 无法自动跳转到default.aspx

环境:moss 2007 sp2 ,server 2003 r2 X64,一台管理中心,四台前端,一台search,一台其他开发功能server. 使用NLB访问正常,域名为http://www.test.com 如果将hosts 中的域名直接指定到管理中心的地址,直接通过管理中心的Web Application 访问时,如果使用http://www.test.com/default.aspx访问正常,使用http://www.test.com访问时,不断弹出输入用户名密码的对话框,并且输入无效

sharepoint 2007 升级到 sharepoint 2013

从moss 2007不能直接升级到moss2013,必须要先升级到moss2010,再升级到moss2013才可以. 一.需要将moss 2007打到sp2补丁(如果已经打过补丁,可以跳过此步骤) 如果还没有打sp1补丁,需要先打sp1补丁,然后再打sp2补丁.打完sp2后,sharepoint的版本号是12.0.0.6421,未打任何补丁之前的版本号是4518或者更小. 按照如下顺序打补丁.如果不想在生产环境上动刀,那么就搭一个虚拟机吧.moss2007环境的搭建可以参照这个:http://w