Question

I am not allow to modify the core.js so that's not my option. I am allow to add a content editor. I just need to remove the "Download a Copy" from submenu. (this is just for a particular library). The code removes the whole "Send to". Any suggesion?

<script language="javascript">
function AddSendSubMenu(m,ctx)
{
menuOption = CAMOpt("", L_DownloadACopy_Text, strAction, "");
menuOption.id = "ID_DownloadACopy";
}
</script>
Was it helpful?

Solution 3

This what I put it in my custom master page. I could not mess with core.js because there are many more site collection within the same web application.

<script type="text/javascript">

_spBodyOnLoadFunctionNames.push("resetAddSendSubMenu()");

function resetAddSendSubMenu() {
    AddSendSubMenu = function (m, ctx) {
        strDisplayText = L_Send_Text;
        var currentItemUrl = GetAttributeFromItemTable(itemTable, "Url", "ServerUrl");
        var currentItemEscapedFileUrl;
        var currentItenUnescapedUrl;
        var strExtension;
        if (currentItemFileUrl != null) {
            currentItenUnescapedUrl = unescapeProperly(currentItemFileUrl);
            currentItemEscapedFileUrl = escapeProperly(currentItenUnescapedUrl);
            strExtension = SzExtension(currentItenUnescapedUrl);
            if (strExtension != null && strExtension != "")
                strExtension = strExtension.toLowerCase();
        }
        var sm = CASubM(m, strDisplayText, "", "", 400);
        sm.id = "ID_Send";
        var menuOption;
        var serverFileRedirect = itemTable.getAttribute("SRed");
        if (currentItemProgId != "SharePoint.WebPartPage.Document" &&
        (serverFileRedirect == null || serverFileRedirect == "" || HasRights(0x0, 0x20)) && strExtension != "aspx") {
            if (typeof (ctx.SendToLocationName) != "undefined" &&
            ctx.SendToLocationName != null &&
            ctx.SendToLocationName != "" &&
            typeof (ctx.SendToLocationUrl) != "undefined" &&
            ctx.SendToLocationUrl != null &&
            ctx.SendToLocationUrl != "") {
                strAction = "STSNavigate('" + ctx.HttpRoot + "/_layouts/copy.aspx?" + "SourceUrl=" + currentItemEscapedFileUrl + "&Source=" + GetSource() + "&FldUrl=" + escapeProperly(ctx.SendToLocationUrl) + "')";
                menuOption = CAMOpt(sm,
                                ctx.SendToLocationName,
                                strAction,
                                "");
            }
            if (typeof (itemTable.getAttribute("HCD")) != "undefined" && itemTable.getAttribute("HCD") == "1") {
                strDisplayText = L_ExistingCopies_Text;
                strAction = "STSNavigate('" + ctx.HttpRoot + "/_layouts/updatecopies.aspx?" + "SourceUrl=" + currentItemEscapedFileUrl + "&Source=" + GetSource() + "')";
                strImagePath = ctx.imagesPath + "existingLocations.gif";
                menuOption = CAMOpt(sm, strDisplayText, strAction, strImagePath);
                menuOption.id = "ID_ExistingCopies";
            }
            strDisplayText = L_OtherLocation_Text;
            strAction = "STSNavigate('" + ctx.HttpRoot + "/_layouts/copy.aspx?" + "SourceUrl=" + currentItemEscapedFileUrl + "&Source=" + GetSource() + "')";
            strImagePath = ctx.imagesPath + "sendOtherLoc.gif";
            menuOption = CAMOpt(sm, strDisplayText, strAction, strImagePath);
            menuOption.id = "ID_OtherLocation";
            if (ctx.OfficialFileName != null && ctx.OfficialFileName != "") {
                strDisplayText = ctx.OfficialFileName;
                strAction = "STSNavigate('" + ctx.HttpRoot + "/_layouts/SendToOfficialFile.aspx?" + "SourceUrl=" + currentItemEscapedFileUrl + "&Source=" + GetSource() + "')";
                strImagePath = "";
                CAMOpt(sm, strDisplayText, strAction, strImagePath);
            }
            CAMSep(sm);
        }
        if (HasRights(0x10, 0x0)) {
            strDisplayText = L_SendToEmail_Text;
            var currentItemUrl = GetAttributeFromItemTable(itemTable, "Url", "ServerUrl");
            var httpRootWithSlash = ctx.HttpRoot.substr(0);
            if (httpRootWithSlash[httpRootWithSlash.length - 1] != '/')
                httpRootWithSlash += '/';
            var slashLoc = -1;
            var fileUrl = "";
            slashLoc = httpRootWithSlash.substring(8).indexOf('/') + 8;
            fileUrl = escapeProperly(httpRootWithSlash.substr(0, slashLoc)) + currentItemUrl;
            var serverFileRedir = itemTable.getAttribute("SRed");
            if ((serverFileRedir != null) &&
            (serverFileRedir != "") &&
            (serverFileRedir != "1")) {
                if (serverFileRedir.substring(0, 1) != "1") {
                    fileUrl = serverFileRedir;
                }
                else {
                    fileUrl = serverFileRedir.substring(1);
                }
            }
            strAction = "javascript:navigateMailToLink('mailto:?body=" + fileUrl + "')";
            strImagePath = ctx.imagesPath + "gmailnew.gif";
            menuOption = CAMOpt(sm, strDisplayText, strAction, strImagePath);
            menuOption.id = "ID_SendToEmail";
        }
        var serverFileRedirect = itemTable.getAttribute("SRed");
        if (currentItemFSObjType != 1 &&
        ctx.listBaseType == 1 &&
        (serverFileRedirect == null || serverFileRedirect == ""
           || HasRights(0x0, 0x20))) {
            if (ctx.listTemplate != 109 &&
            ctx.listTemplate != 119)
                AddWorkspaceMenuItem(sm, ctx);
            var strExt  = GetAttributeFromItemTable(itemTable, "Ext", "FileType"); 
            //alert("Extension: " + strExt);
            if (!(strExt == 'mp3' || strExt == 'wmv' || strExt=='wav' || strExt =='avi'))
                {
                    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";
                }
            }
        }

    }


</script>

OTHER TIPS

The proper way to achieve this is through a SharePoint solution with a feature which hides the action. You need to find the ID of the Download a Copy, then create a node for it within the elements.xml. You can target this to a specific list by it's name.

Instructions are here:

http://msdn.microsoft.com/en-us/library/ms473643%28v=office.12%29.aspx

http://msdn.microsoft.com/en-us/library/ms414790%28v=office.12%29.aspx

<script type="text/javascript">
function CAMOpt(p,wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc)
{
    if (wzText === L_DownloadACopy_Text) {
        return {};
    }
    var mo=CMOpt(wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc);
    if(!mo)return null;
    AChld(p,mo);
    return mo;
}
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top