Tuesday, March 07, 2006

Checks to see user has access for creating the alert programatically...

See you @ PDC ?05!

So I know that doesn't have anything to do with your post, but I found out that your MyAlerts webpart suffers the same issues as the What's New webpart (re: http://weblogs.asp.net/jan/archive/2004/04/26/120508.aspx ) if the current user doesn't have access to some WSS lists and clicks on the "Add All" link.

Here is the updated code (assuming you're using the same UserCanViewListItems method):

private void addAll_Click(object sender, EventArgs e)
{
SPWeb web = SPControl.GetContextWeb(Context);
web.Site.CatchAccessDeniedException = false;

foreach(SPList list in web.Lists)
{
if(UserCanViewListItems(list))
{
if(sender == addAllDaily)
web.CurrentUser.Alerts.Add(list,SPEventType.All, SPAlertFrequency.Daily);
else if(sender == addAllImmediate)
web.CurrentUser.Alerts.Add(list,SPEventType.All, SPAlertFrequency.Immediate);
}
}

0 Comments:

Post a Comment

<< Home