Jump to content

Developer Documentation

Supporting reputation for comments

How to implement reputation

First, your comment model must implement the reputation interface, like so:

implements \IPS\Content\Reputation

Next, you need to add a property to your model:

public static $reputationType = ‘string’;

This property identifies this kind of content from others within the reputation system. It can be anything you like, but the convention is to use the name of the column in your database that stores the ID. For example:

public static $reputationType = comment_id’;

 

Additional model methods available

boolean canGiveReputationinteger $type [, \IPS\Member $member ] )

Indicates whether the user can give reputation to the creator of the content item.

  • $type (integer, required)
    The type of reputation to be given. Either 1 or -1, where 1 is positive reputation and -1 is negative reputation.
  • $member (\IPS\Member, optional)
    The member whose permissions should be used when checking. By default, the currently-logged in member will be used.

 

void giveReputationinteger $type [, \IPS\Member $member ] )

Gives reputation to the creator of the content item. Throws a DomainException if the member does not have permission to give reputation to this item.

  • $type (integer, required)
    The type of reputation to be given. Either 1 or -1, where 1 is positive reputation and -1 is negative reputation.
  • $member (\IPS\Member, optional)
    The member whose permissions should be used when checking. By default, the currently-logged in member will be used.

 

integer repGiven( [ \IPS\Member $member ] )

Returns a value indicating whether (and what type of) reputation the member has given to the item. The return values are:

  • 1 - positive reputation has been given
  • -1 - negative reputation has been given
  • 0 - no reputation has been given

 

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

 

Changed behavior after implementation

  • Reputation buttons will automatically appear next to comments.

  Report Document


×
×
  • Create New...