Adding abuse reporting functionality to transformations

The In-line abuse report web part appears as a link with the Report abuse text. After clicking the link, the system opens a dialog window from where the site visitor can send an abuse report to the site administrators. Besides using the In-line abuse report web part as a standard web part, you can use it also in transformations. This allows you 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 board -> Message board. The Report abuse link is included with each message on the board.

The In-line abuse report web part used in a message board transformation

This is achieved by registering the In-line abuse report web part in the transformation that displays the board messages. If you configure the Message board web part and edit its Message transformation property (the community.transformations.MessageBoard transformation is selected by default), you should see the following block of code.

In-line abuse report in a transformation



<%@ 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 a block of code to register the web part (which is a control) so that the system can use it in the transformation code. The location of the web part code file is ~/CMSModules/AbuseReport/Controls/InlineAbuseReport.ascx.




<%@ Register Src="~/CMSModules/AbuseReport/Controls/InlineAbuseReport.ascx" TagName="AbuseReport" TagPrefix="cms" %>


The second important block 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 is 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 is displayed only to authenticated users.

This way, you can use the web part in transformations of any page type. 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.