Microsoft has introduced several new features of Community Sites, along with reporting of offensive content in SharePoint 2013. If users of community sites come across any incorrect / inappropriate content (discussion post), they can report that discussion post to moderators for evaluation. Accordingly, moderators can review such content and take the corrective action by either modifying the content or deleting it. For enabling this feature, we need to update the community settings. The steps for enabling this feature are, as follows –
- Visit Community site.
- Click on Community settings option from Community tools section.
- Mark Enable reporting of offensive content checkbox and click on OK button.
- Once we enable this setting, Report to moderator option will start showing in discussion posts.
-
Now, we need to enable this option using code. Enabling this option using code is not a straight forward solution. We need to use reflection for achieving it. Following is the code snippet for the same.
- SPSecurity.RunWithElevatedPrivileges(() =>
- {
- using (SPSite site = new SPSite("<<CommunityWebUrl>>"))
- {
- using (SPWeb web = site.OpenWeb())
- {
- web.AllowUnsafeUpdates = true;
- web.AllProperties["vti_CommunityEnableReportAbuse"] = "true";
- web.Update();
-
- Assembly sharePointAssembly = typeof(Microsoft.SharePoint.Portal.SitePage).Assembly;
- Type functionalityEnablersType = sharePointAssembly.GetType("Microsoft.SharePoint.Portal.FunctionalityEnablers");
- MethodInfo methodInfo = functionalityEnablersType.GetMethod("EnableDisableAbuseReports");
- methodInfo.Invoke(null, new object[] { web, true });
- web.AllowUnsafeUpdates = false;
- }
- }
- });