I've received a few emails asking for more details on how to share a blog in Community Server. This was something I had to account for in the Multi-date Calendar Blog, and so the Queensryche Calendar Blog Series continues with "Sharing a Blog, Track 1."
The main thing we need to handle when sharing a blog is preventing users from editing other authors' posts and from making global changes to the blog. We'll start with isolating users from other authors' posts and begin on the post page (and elsewhere) where the [Edit Post] and [Edit Tags] links are displayed. We'll look at the [Edit Post] link, which we want to display to the post's author or to Site Blog Administrators only. We do this by adding a new WeblogPostLinkTo CalendarPostEditor item in the CS.Blogs.WeblogPostData control.
case WeblogPostLinkTo.CalendarPostEditor:
if (csContext.Context.Request.IsAuthenticated &&
post.AuthorID == csContext.User.UserID || csContext.User.IsBlogAdministrator)
{
link = new HyperLink();
link.NavigateUrl = BlogUrls.Instance().CalendarPostEditor(weblog.SectionID, post.PostID);
}
else
this.AutomatedVisible = false;
break;
Our post.aspx HTML would be
<CSBlog:WeblogPostData LinkTo="CalendarPostEditor" ResourceName="Weblog_Link_EditPost"
runat="server" />
So we're displaying the [Edit Post] link for the post author and site BlogAdmins only and linking to our custom Calendar Post Editor with the multi-date display support. (A screenshot of the multi-date display panel is shown on the series introduction post.)
Now we're on our custom Post Editor in the Control Panel. We'll deal with menu tab management to prevent users from making global changes later. For now we'll conclude with isolating users from other authors' posts by handling the "Display All Posts" list shown below. We want to display only the posts of the current user in the "All Posts" grid. To achieve that we add a UserID property to the query passed to GetBlogThreads() in our custom PostListControl.ascx.cs control when binding the grid.
// DBVT Modified
if (!context.User.IsBlogAdministrator || !context.User.IsAdministrator)
query.UserID = context.User.UserID;
The Calendar Blog doesn't support comments, or this logic would have been used for that grid as well. There are other aspects to address in sharing a blog and different requirements, but the issues mentioned in this post are the primary ones that would need to be addressed. I'll talk about managing the display of Control Panel menu items next time.
For a price I'd do anything
Except pull the trigger
For that I need a pretty good cause
Then I heard of Dr. X
The man with the cure
Just watch the television
You'll see there's something going on
[Queensryche]