Thursday, June 15, 2006

What's new webpart

Jan the man made the "What's new webpart" for WSS sites (it's a standard feature in SPS but due to an obscure and unknown reason not in WSS) more than two years ago (also Mike Fitzmaurice did the same) and I used this for a project I'm involved in right now. The architecture that we used is a WSS site with a lot of subsites (actually a portal without the need of SPS) and the requirement was that on a high level, the users could see an overview of the last modified items. Here is where Jan's webpart comes into view ;) Now I modified the code so that subsites are also shown in the summary.

private ArrayList GetSubwebs(SPWeb web) { System.Collections.Hashtable listFieldsHashTable = GetListFieldHashTable(); System.Collections.Hashtable excludeListsHashTable = GetExcludeListsHashTable(); System.Collections.ArrayList items = new System.Collections.ArrayList(); web.Lists.IncludeRootFolder = true; foreach(SPList list in web.Lists) { if(list.Permissions.DoesUserHavePermissions(SPRights.ViewListItems)) { if(!excludeListsHashTable.ContainsKey(list.Title)) { SPQuery query = new SPQuery(); query.Query = ""; query.RowLimit = (uint)this.ItemsToDisplay; foreach(SPListItem listItem in list.GetItems(query)) { items.Add(listItem); } } } } foreach (SPWeb subweb in web.Webs) { items.AddRange(GetSubwebs(subweb)); } return items; }
It all worked fine until testing with a group of readers. These readers were getting access denied errors. First thing I did was using the impersonation trick I learned a couple of weeks ago but that didn't do the job. Second thing I did was testing with a contributor group, that went fine. Thirdly was to check what the key difference was between these two groups (except for the most obvious reason that contributors can add stuff ;). Well the key difference was the ability to 'browse directories' So you might wonder (I know I do).. why can't readers browse directories. And what are directories in sharepoint anyway? :) Are directory's actually subsites?

1 comment:

infopath signatures said...

Thanks for these instructions ! I really appreciated the read and shall be dropping by from time to time now.