Someone asked today on CS Forums how to set the default blog Feedback Notification to "All Feedback" when a new blog is created. The default is "none," and there isn't an option to set that property when creating a new blog in Community Server. To me this belongs where it already is, in My Blog->Settings->Advanced Post Settings->Email Feedback->(none, All Feedback, or All Comments) and set by the blog owner.
But it was an interesting question and I couldn't let it go, so I spent tonight's Geek Session on figuring out how to best accomplish it. The most interesting source focus of the night to me was working with Extended Attributes. The function of the ExtendedAttributes Class, as the class summary
reads, is to "Provide a standard implementation for simple extended
data storage." Core CS objects like Weblog, Gallery, Forum and Files inherit from the CS.Components.Section class (
here's a sample Section object), and Section inherits from Components.ExtendedAttributes.
ExtendedAttributes are a serialized NameValueCollection and accessed with standard Gets, Sets, and other methods found in the ExtendedAttributes class. We can retrieve attributes specific to the Weblog class, for instance, by calling
section.GetExtendedAttribute("SomeAttributeName");
You'll find examples of serialized Extended Attributes in the PropertyNames and PropertyValues fields of the cs_Sections SQL table. Here's an example of Keys and Values:
data.Keys:
"SectionOwners:S:0:4:EnableAggBugs:S:4:4:IsCommunityAggregated:S:8:4:aboutTitle:S:12:17:"
data.Values:
"JackTrueTrueAbout Jack's Blog"Extended Attributes are a beautiful thing, really.
Back to the issue at hand, which is how to set the default blog Feedback Notification property to "All Feedback" when a new blog is created. This Weblog property is (you guessed it) accessible as an extended attribute in the Section object, but it isn't set when a blog is created, relying on the default "none" (or FeedbackNotificationType.None actually) when needed elsewhere to set the dropdown on the My Blogs->Advanced Post Settings form, for instance.
You may be wondering why I didn't set the WebLog.FeedbackNotificationType to "All Feedback" as the default and be done with it? Well, that wouldn't have been any fun at all, so don't ask me about it. What I did instead was really cool, created a CSModule to hook into the PreSectionUpdate Global Event, then set the FeedbackNotificationType extended attribute in section before it was passed to the CommonDataProvider, at which point the weblog was created and the feedbackNotificationType now added.
Here's the custom event method in the CSModule:
private void csa_PreSectionUpdate(Section section, CSEventArgs e)
{
if (section.ApplicationType == ApplicationType.Weblog)
section.SetExtendedAttribute("feedbackNotificationType", "1");
}This CSModule can be modified to update other WebLog (or Forum or Gallery or File) extended attributes on creation as well. CSModules and Extended Attributes. Mmmmmm-boy!
Available here:
DaveBurke.CS.SectionModule.zip.
[tags: Community Server, Extended Attributes]