Thursday, June 28, 2007

Dependencies in Custom SharePoint Permissions

An event handler I have written applies item-level permissions to modified list items - specific users are granted custom permissions.

This was working fine until I enabled versioning on the list manipulated by the handler. After making that change I noticed that the specific users were now seeing the access denied page in SharePoint when attempting to view items with the managed permissions.

The code was assigning SPBasePermissions.EditListItems and SPBasePermissions.ViewListItems rights for the users. After experimenting in the Edit Permissions Level administrative page in the site settings, I noticed that checking certain boxes caused other boxes to be checked - there are clearly some dependencies behind the scenes that should be applied when assigning custom permissions.

The outcome of the experimenting was that with versioning enabled on the list, the view versions permissions was required. Edit rights on an item will be granted to a user by applying the following set of SPBasePermissions to the role definition:

SPBasePermissions.EditListItems SPBasePermissions.ViewListItems SPBasePermissions.OpenItems SPBasePermissions.ViewVersions SPBasePermissions.ViewPages SPBasePermissions.Open

Viewing rights are granted with the same set, minus the EditListItems member.

Wednesday, June 27, 2007

Tuesday, June 26, 2007

How to Display the "New" icon against a List Item

To show the standard SharePoint New standard icon SharePoint icon against new list items in a data view web part (or other XSLT web parts), use the following snippet:

<xsl:if test="ddwrt:IfNew(string(@Created))">
    <img src="/_layouts/1033/images/new.gif" alt="New" />

Comparing Dates in SharePoint XSL

Here's a way to peform a date comparison in the XSLT definition of a data view web part:

<xsl:if test="number(translate(substring-before(ddwrt:FormatDate(@Date_x0020_Raised ,1053 ,5), ' '), '-', ''))+2 < number(translate(substring-before(ddwrt:TodayIso(), 'T'), '-', ''))">
<img src="_layouts/images/ewr210s.gif" />

This compares the date in the "Date Raised" field with the current date, and if the "Date Raised" is more than 2 days ago then an image is displayed.

Monday, June 25, 2007

Handling Multivalue and Multiselect Field Values in SharePoint

Having written my own regular expression to parse the values from a multiselect lookup field, I then found a post from Mark Arend that offers regular expressions for all the various "decorated" field types in SharePoint (choices, lookup, Person or Group and Hyperlink fields). Very handy!

Thursday, June 14, 2007

Building an Accessible Internet Site with WCM: Setting Up the Solution

Latest project is to create an Internet site using MOSS that complies with accessibility web standards.

First step was a LOT of research. I found plenty of useful articles by Heather Solomon, Zac Smith, Cameron Moll and others, plus dashings of negative comments about quite how non-standard is the HTML pumped out by SharePoint. Sounds like a fair bit of work ahead!

During my travels around the web, I came across a nice idea from Phil Wicklund on managing SharePoint development across a team. The great thing about starting a new project is that it gives the opportunity to apply best practices, so I am combining Phil's approach of reproducing the 12 hive folder structure, but will be deploying via a feature rather than via Xcopy. The downside of this is that deployment during development is slower, but I prefer to always build the WSP file as this sorts out any deployment issues very early in the development cycle. Having a package deployable from the command-line is closer to allowing some form of continous integration, too.

Tuesday, June 12, 2007

MOSS Internet Sites

I was preparing a list of MOSS public-facing web sites, but no point - 'cause here's a comprehensive list by Na-Young Kwon