Jump to content

Community

Developer Documentation

Supporting the report center in Content Items

By supporting reports in your application, users will be able to report content items to moderators, who will be able to deal with them in the central report center.

 

How to implement reporting

First, you need to implement the report interface in your content item model, like so:

implements \IPS\Content\ReportCenter

Next, add a static property to your content item model. This property is the name of a FontAwesome icon that will represent your content items when viewed in the report center:

public static $icon = 'string';

Finally, include the report link in your HTML. In this case, you should not call the canReport() method since it is resource intensive. Instead, check for assumptions such as checking the user's group can make reports, and isn't the author of the item. For example:

{{if !\IPS\Member::loggedIn()->group['gbw_no_report'] and $item->author()->member_id != \IPS\Member::loggedIn()->member_id }}
	<a href='{$item->url('report')}' data-ipsDialog data-ipsDialog-size='narrow' data-ipsDialog-title="{lang="report_post"}" data-ipsDialog-
flashMessage="{lang="node_error"}" title='{lang="report_post"}'><i class='icon-exclamation-sign'></i>&nbsp; {lang="report_post"}</a>
{{endif}}

 

Additional model methods available

boolean canReport( [ \IPS\Member $member ] )

Indicates whether the member is able to report the item. Considers whether their group(s) has permission to report content, if the user can view the content, and whether they have already reported the content.

  • $member (\IPS\Member, optional)
    The member whose permissions should be checked. By default, the currently-logged in member will be used.

 

\IPS\core\Reports\Report reportstring $reportContent )

Submits and returns a report about the item.

  • $reportContent (string, required)
    The content of the report.

  Report Document


×
×
  • Create New...