Friday 16 December 2011

Hide View All Site Content, Recycle Bin, and Site Actions link in SharePoint website for non admin users

Hiding “View All Site Content” and “Recycle Bin“ link in a SharePoint website for non administrator users is very simple. You just need to do little modification in the master page used in that SharePoint website.

Go to “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL” and open “default.master” page.

1. To hide “View All Site Content” link, search for following in the master page:

<Sharepoint:SPSecurityTrimmedControl runat = "server" PermissionsString = "ViewFormPages" >
<div class = "ms-quicklaunchheader" >
<SharePoint:SPLinkButton id = "idNavLinkViewAll" runat = "server" NavigateUrl = "~site/_layouts/viewlsts.aspx" Text = "<%$Resources:wss,quiklnch_allcontent%>" AccessKey = <%$Resources:wss,quiklnch_allcontent_AK%>" />
</div>
</SharePoint:SPSecurityTrimmedControl>

Modify the value of PermissionsString property to “ManageWeb” which is by default set to “ViewFormPages”. Reset IIS and open the SharePoint website and check the “View All Site Content” link which will be now only visible to admin users.

2. To hide “Recycle Bin” link, search for following in the master page:

<SharePoint:SPLinkButton runat = "server" NavigateUrl = "~site/_layouts/recyclebin.aspx" id = "idNavLinkRecycleBin" ImageUrl = "/_layouts/images/recycbin.gif" Text = "<%$Resources:wss,StsDefault_RecycleBin%>" PermissionsString="DeleteListItems" />

Again modify the value of PermissionsString property to “ManageWeb” which is by default set to “DeleteListItems”. Reset IIS and open the SharePoint website and check the “Recycle Bin” link which will be now only visible to admin users.

3. To hide the “Site Actions” menu, search for following in the master page:

<SharePoint:SiteActions runat = "server" AccessKey = "<%$Resources:wss,tb_SiteActions_AK%>" id = "SiteActionsMenuMain" PrefixHtml = "&lt;div&gt;&lt;div&gt;" SuffixHtml = "&lt;/div&gt;&lt;/div&gt;" MenuNotVisibleHtml = "&amp;nbsp;" >
<CustomTemplate>
-------------------------
----Some code-----
-------------------------
</CustomTemplate>
</SharePoint:SiteActions>

Now enclose the above code within a “SharePoint:SPSecurityTrimmedControl” control and set the “PermissionsString” property of “SharePoint:SPSecurityTrimmedControl” to “ManageWeb”. The final code will look like as below:

<SharePoint:SPSecurityTrimmedControl ID = "spstcSiteActions" runat = "server" PermissionsString = "ManageWeb" >
-----------------------------------------------------------
---above code for SharePoint:SiteActions control---
-----------------------------------------------------------
</SharePoint:SPSecurityTrimmedControl>

Now reset IIS and open the SharePoint website and check the “Site Actions” menu which will be now only visible to admin users.

There are a lot of other possible values for “PermissionsString” property. Visit this MSDN page

No comments:

Post a Comment