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:
Next, you will need to add additional elements to your $databaseColumnMap property:
Required. Should contain the column name that holds a unix timestamp of when the comment was edited.
Required. Should contain the column name that holds a boolean indicating whether the edit message should show.
Required. Should contain the column name that holds the username of the member that made the edit.
Optional. Should contain the column name that holds the reason given for the edit.
Optional. Should contain the column name that holds the member ID that made the edit.
Additional model methods available
Returns a string of HTML that can be displayed in the comment to show the edit, for example "Edited <x> days ago by <user>".
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.