Jump to content

Developer Documentation

Implementing edit history for comments

Comments can use the built-in edit history functionality to log when the comment text is edited, as well as track versions of the comment.

 

Implementing edit history

First, your comment model will need to implement the edit history interface, like so:

implements \IPS\Content\EditHistory

Next, you will need to add additional elements to your $databaseColumnMap property:

  • edit_time
    Required. Should contain the column name that holds a unix timestamp of when the comment was edited.
  • edit_show
    Required. Should contain the column name that holds a boolean indicating whether the edit message should show.
  • edit_member_name
    Required. Should contain the column name that holds the username of the member that made the edit.
  • edit_reason
    Optional. Should contain the column name that holds the reason given for the edit.
  • edit_member_id
    Optional. Should contain the column name that holds the member ID that made the edit.

 

Additional model methods available

string editLine()

Returns a string of HTML that can be displayed in the comment to show the edit, for example "Edited <x> days ago by <user>".

 

\IPS\Db\Select editHistory( [ boolean $staff ] )

Returns an iterator query result that can be used to loop through each item in the edit history.

  • $staff (boolean, optional, default FALSE)
    Will return the full log, which includes edits not made by the author and private edits. Set to TRUE for moderators.

 

Changed behavior after implementation

  • When editing, the details of the edit will be logged and displayed on the comment. The exact behavior depends on the site’s configuration.

  Report Document


×
×
  • Create New...