Adding abuse reporting functionality to transformations
The Inline abuse report web part appears as a link with the Report abuse text. After clicking the link, a dialog appears, letting the site visitor send abuse report to the site administrators. Apart from using the In-line abuse report as a standard web part, you can also use it in transformations to have the Report abuse link displayed with dynamically loaded content.
The In-line abuse report web part is demonstrated on the sample Corporate site, under Examples -> Web parts -> Message boards -> Message board. The Report abuse link is included with each message on the board.
This is achieved using the In-line abuse report web part in the transformation used for displaying board messages. If you configure a Message board web part and edit the Message transformation (the community.transformations.MessageBoard transformation should be selected by default), you should see the same code as below.
<%@ Register Src="~/CMSModules/MessageBoards/Controls/MessageActions.ascx" TagName="MessageActions" TagPrefix="cms" %>
<%@ Register Src="~/CMSModules/AbuseReport/Controls/InlineAbuseReport.ascx" TagName="AbuseReport" TagPrefix="cms" %>
<div class="CommentDetail">
<asp:Panel ID="pnlRating" runat="server" CssClass="CommentRating" />
<table width="100%">
<tr>
<td class="CommentUserName" style="width: 100%">
<%# IfEmpty(Eval("MessageURL"), TrimSitePrefix(Eval("MessageUserName", true)), "<a href=\"" + Eval("MessageURL", true) + "\" target=\"_blank\"" + IfCompare(HTMLHelper.UseNoFollowForUsersLinks(CMS.SiteProvider.SiteContext.CurrentSiteName), true, "", " rel=\"nofollow\" ") + ">" + TrimSitePrefix(Eval("MessageUserName", true)) + "</a>") %>
</td>
</tr>
<tr>
<td class="CommentText">
<%# TextHelper.EnsureLineEndings(Convert.ToString(Eval("MessageText", true)), "<br />")%>
</td>
</tr>
<tr>
<td class="CommentDate">
<%# GetDateTime(Eval("MessageInserted")) %>
</td>
</tr>
<tr>
<td align="right" class="CommentAction">
<cms:MessageActions ID="messageActions" runat="server" />
</td>
</tr>
<tr>
<td align="right" class="CommentAction">
<cms:AbuseReport ID="ucInlineAbuseReport" runat="server" ReportObjectType="board.message" ReportObjectID='<%# Eval("MessageID") %>' ReportTitle='<%# "Message board abuse report: " + Eval("MessageText") %>' CMSPanel-SecurityAccess="AuthenticatedUsers" />
</td>
</tr>
</table>
</div>
<hr style="border: 1px solid #CCCCCC;"/>
At the beginning, you can find code to register the web part (which is actually a control) so that it can be used in transformation code. The web part code file is located at ~/CMSModules/AbuseReport/Controls/InlineAbuseReport.ascx.
<%@ Register Src="~/CMSModules/AbuseReport/Controls/InlineAbuseReport.ascx" TagName="AbuseReport" TagPrefix="cms" %>
The second important piece of code is the actual web part, identified by the tag name and prefix defined in the Register
tag.
<cms:AbuseReport ID="ucInlineAbuseReport" runat="server" ReportObjectType="board.message" ReportObjectID='<%# Eval("MessageID") %>' ReportTitle='<%# "Message board abuse report: " + Eval("MessageText") %>' CMSPanel-SecurityAccess="AuthenticatedUsers" />
The ReportObjectType="board.message"
and ReportObjectID='<%# Eval("MessageID") %>
parameters ensure that it will be possible to view details of a particular message (source of reported abuse) from the administration interface. These parameters pass the ID of the particular board message along with the report, so that the message can be identified and a link to it created. The ReportTitle='<%# "Message board abuse report: " + Eval("MessageText") %>
parameter defines the title of the report displayed in the administration interface. The last parameter - CMSPanel-SecurityAccess="AuthenticatedUsers"
- ensures that the link will be displayed only to authenticated users.
This way, you can use the web part in transformations of any document types you need. The only limitation is that the object details functionality is available only with board messages, forum posts and blog comments. Abuse reporting is still possible with other object types, but no object details are passed with the report and therefore can’t be displayed in the administration interface.