Thursday, April 29, 2010

How to hide Site Actions and View All Site Content

Overview
Many of you would probably be in the situation when you realise the "Site Actions" and "View All Site Contents" appears to any users. No matter how you move the users around, they can still see them. Further to my previous post, the below is the detailed steps to help you in modifying the master pages.

Assumptions
I assume you already know where to find the master page, and to open it using SharePoint designer. Otherwise, read this before going any further.

SPSecurityTrimmedControl
This SharePoint control controls when a component is being display. Wrap this tag around the components that are to be show or hide depending on user permission. Its property PermissionsString is where permission is being specified. A summary of the permission values:
List Permissions
  • ManageLists
  • CancelCheckout
  • AddListItems
  • EditListItems
  • DeleteListItems
  • ViewListItems
  • ApproveItems
  • OpenItems
  • ViewVersions
  • DeleteVersions
  • CreateAlerts
  • ViewFormPages
Site Permissions
  • ManagePermissions
  • ViewUsageData
  • ManageSubwebs
  • ManageWeb
  • AddAndCustomizePages
  • ApplyThemeAndBorder
  • ApplyStyleSheets
  • CreateGroups
  • BrowseDirectories
  • CreateSSCSite
  • ViewPages
  • EnumeratePermissions
  • BrowseUserInfo
  • ManageAlerts
  • UseRemoteAPIs
  • UseClientIntegration
  • Open
  • EditMyUserInfo
Personal Permissions
  • ManagePersonalViews
  • AddDelPrivateWebParts
  • UpdatePersonalWebParts

For multiple permissions, separate the permissions with a comma (,). For example:
<...PermissionsString="ManagedSubwebs,ManageLists"...>
For more details, go here.


Hiding Site Actions button

  1. After opened the default master page, search for the tag SharePoint:SiteActions.
  2. If not already exists, insert the line before the SharePoint:SiteActions tag:
    <Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="ManageSubwebs">
  3. Insert the closing tag SharePoint:SPSecurityTrimmedControl after the closing tag of SharePoint:SiteActions
  4. Change the permission string using the available permissions listed above.


Hide View All Site Content link

  1. After opened the default master page, search for "~site/_layouts/viewlsts.aspx". Normally the SharePoint:SPSecurityTrimmedControl tag is already exists before the line.
  2. If not already exists, insert the line before the DIV:
    <Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="ManageSubwebs">
    <div class="ms-quicklaunchheader"><SharePoint:SPLinkButton... NavigateUrl="~site/_layouts/viewlsts.aspx" ...>

  3. Insert the closing tag SharePoint:SPSecurityTrimmedControl after the corresponding closing DIV tag.
  4. Change the permission string using the available permissions listed above.


Acknowledgments
This article is being inspired by the following posts:

Wednesday, August 19, 2009

How to: Hide the Site Actions Menu in SharePoint

Customizing Site Action menu permission can be achieved by wrapping the SharePoint:SPSecurityTrimmedControl WebControl around the PublishingSiteAction:SiteActionMenu control in your master page.

Detailed reference:
http://www.codeproject.com/KB/sharepoint/SecurityTrim_SharePoint.aspx

Wednesday, August 12, 2009

SharePoint XSLT data view : issues rendering special characters (e.g. &, >, ") and line breaks

I have had problem with my custom display form, where displaying the content of a multiple line text box field does not render the special characters (such as &, >, ") and line breaks properly. After Googling for a couple of hours, there were no solution to my problem. Many suggested using "disable-output-escaping" to fix the special character issue, and some suggested using select="ddwrt:AutoNewLine(string(@Description))" to fix the line breaks issue. They cannot co-exist in the "xsl:value-of" tag because the AutoNewLine function will overwrite the special characters with their HTML encoding (see here).

Finally, I have worked out a solution to resolve both issues. Adding the following template (function) to your display form ASPX and calling it when display a multiple line text field. It replaces the new line character (\n or &#xa;) with a <br>.

Add this function to your DispForm.aspx file:
<xsl:template name="formatMultiLineText">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="contains($text, '&#xa;')">
<xsl:value-of select="substring-before($text, '&#xa;')" disable-output-escaping="yes"/>
<br/>
<xsl:call-template name="formatMultiLineText">
<xsl:with-param name="text" select="substring-after($text,'&#xa;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" disable-output-escaping="yes"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Where your multiple line text is displaying, replace this:
<xsl:value-of select="@Description">

with this:
<xsl:call-template name="formatMultiLineText">
<xsl:with-param name="text" select="@Description">
</xsl:call-template>
Although it might be a bit of work to replace all the multi-line text fields with the template call, it will finally give you some peace of mind. I'd be happy to know if you have any better ideas to overcome all these hassles. :)

Wednesday, August 5, 2009

SP People Picker Error: "The control is not available because you do not have the correct permissions."

When setting one of the "People or Group" field to choose from a SharePoint Group, the above message appeared instead of the expected people picker field. However, it works fine when logged in with an site collection admin account.



After some research on the web, I found the issue was originated from the user group setting. Go to your user group, select Settings -> Group Settings. Then under Group Settings -> Who can view the membership of the group?, select Everyone (see below). Go back to your list form and you should see the people picker instead of the error message.


Friday, July 31, 2009

How Do I: Use the SPDiag Tool to Analyze my SharePoint Farm?

22 minutes, 38 seconds
The SharePoint Diagnostic (SPDiag) tool offers both static and trend analysis and reporting as well as real-time details to assist in analysis, planning, and problem avoidance and resolution. In this video Hilton Giesenow takes us through downloading, installing and configuring the tool, and shows how to use some of its features.

Monday, July 27, 2009

Highlighting the left menu of the current SharePoint page

I have discovered that it is in fact quite simple and effective:
function highlightCurrentMenu() {
var As = document.getElementsByTagName("A");

for (var i=0; i<As.length; i++) {
if (As[i].className == "zz2_QuickLaunchMenu_1 ms-navitem zz2_QuickLaunchMenu_5") {
if (As[i].href == document.location) {
As[i].style.fontWeight = "bold";
As[i].parentNode.style.backgroundColor = "#dddddd";
break;
}
}
}
}