Synopsis: This is a patch to enable "write-once, read-only" comments in the default comment.module for Drupal 5.8. It allows users to post a comment, preview it until they get it right, and then disallows them from deleting or editing that comment at a later time. The patch has not been tested on any other Drupal version than 5.8 release.

Reasoning: Recently the members of my website determined that they would prefer that forum comments be "read only" after they were posted. The idea is to increase the use of the Preview button, add accountability, and help maintain continuity on the forums. Their thinking is that when users are allowed to delete or edit their forum comments, it can impede the continuity of discussion, since it keeps angry users from disrupting the flow by deleting their comments or editing them in a way that changes the way a thread reads. So far it has been very helpful in reducing flames and trolls, since once it's been said, you can't take it back.

I've implemented this with a small change in comments.module by extending the comment availability options (disable, read-only, read-write), to include a "write-once, read-only" option. It was incredibly simple to implement by adding a fourth enum a la define('COMMENT_NODE_WRITE_ONCE', 3) and adding the necessary logic to several control structures. It appears to work flawlessly on my site. Thank you Drupal coders for making things easy. If you think this is something that might be useful to other community-oriented Drupal sites, I've included a patch (pulled from a CVS diff). If you have any questions or criticism, I will be monitoring this ticket.

Thank you,

Travis

Comments

Travis’s picture

StatusFileSize
new3.83 KB

Updated patch file.

Synopsis: I missed a spot. WORO comments now come with a reply link...

rickvug’s picture

Version: 5.8 » 7.x-dev
Status: Active » Needs work

Travis,

This is being marked for 7.x as no new features are being added to 5.x or 6.x. This use case may not be common enough for core. How about creating a separate module that does exactly this? I'm also marking "code needs work" as the patch needs to be against 7.x.

catch’s picture

Title: Enable Write-Once, Read-Only Comments » Edit own comments permission

This would be much better handled by a new permission "edit own comments".

Additionally I think it'd be good to put the 'can't edit your comment after someone's directly replied to it even if you're using flat comment display' logic into a variable somewhere rather than the current hard coded behaviour.

maartenvg’s picture

Assigned: Unassigned » maartenvg

I agree that a "edit own comments" permission (which is on by default) is a better solution than the one provided by #1. Because it uses the same UI as other parts of drupal (nodes, etc), and is therefore expected. I'm willing to create this permission, and even might create a module to back-port it to D5 and D6.

@#3: I agree that it'd be a good idea to make "can't edit after someone replies to you" optional, but that requires its own issue. If it hasn't already.

maartenvg’s picture

Status: Needs work » Needs review
StatusFileSize
new5.8 KB

I've created the patch. The real code are only 2 changes, just adding the 'edit own comment' permission, and checking for it when needed. This patch also adds the appropriate tests to comment.test and makes sure that the 'edit own comment' is on by default on a fresh install (via system.install).

Don't forget to run update.php. :)

Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

maartenvg’s picture

Status: Needs work » Needs review
StatusFileSize
new4.92 KB

Chasing head.

catch’s picture

I'm wondering whether we should enable this permission for users that already have the 'post comments' permission - since they'd actually lose the ability to edit their own comments with this upgrade path. If we don't, then a drupal_set_message() in the update to inform admins about the new permission (or a CHANGELOG.txt entry) seems sensible. Not sure which is best, but marking to needs work - should be easy enough to re-roll for any one of those three.

Otherwise everything looks good.

catch’s picture

Status: Needs review » Needs work
maartenvg’s picture

Status: Needs work » Needs review
StatusFileSize
new5.44 KB

I implemented the first, because that is the most user friendly and keeps the old behavior intact when upgrading. When upgrading it gets all roles with the "post comments" permission and adds the "edit own comments" permission for those roles.

Is hook_update_700N() run when a module is disabled (but not uninstalled)? If not, comment_update_7002() should become system_update_N().

catch’s picture

Status: Needs review » Needs work

The update will be run even if comment module is disabled. However, the update should use db_insert() I think.

maartenvg’s picture

Status: Needs work » Needs review
StatusFileSize
new5.48 KB

db_insert() ... check!

keith.smith’s picture

If you have to reroll, I posit that

+      'description' => t('Edit comment created by the user, as long as no one has replied directly to it.'),

is not very clear. It's rather ambiguous in regard to the user you're referring to.

Maybe something like: "Allow users to edit their own comments, as long as no one has replied to them." (or something similar)...

catch’s picture

Component: comment.module » usability

Or even "Allow users to edit their own comments until they are replied to" maybe? Moving this to usability queue for review on the strings.

maartenvg’s picture

Component: usability » comment.module

I tried to follow the 'standards' provided by the other modules. Those avoid the use of "Allow ...", and also use the user. For example in Delete Page content created by the user. an Edit Article content created by the user..

So I'm not sure whether/how the current form should change. Usability Team to the Rescue!

maartenvg’s picture

crosspost

keith.smith’s picture

Or "Allow users to edit their own comments (as long as no follow-up replies have been posted."

catch’s picture

Component: comment.module » usability

Maarten - good points - 'allow' and 'user' on the user permissions page are a bit redundant.

"Edit own comments until a reply has been posted" maybe?

keith.smith’s picture

Yeah, the "Edit own" formulation seems to be the way to go here. Catch's suggestion in #18 or some variation thereof would be fine with me.

maartenvg’s picture

Let's also place more focus on the "until a reply has been posted" part, because it has to be absolutely clear that it only goes for a direct/connected reply, and not for a reply to the node below the comment in question.

"Edit own comments (until the comment is directly replied to)."

Status: Needs review » Needs work

The last submitted patch failed testing.

SeanBannister’s picture

Component: usability » base system

Sub

akeane’s picture

StatusFileSize
new1.7 KB

From #12 - seems to work.

john franklin’s picture

StatusFileSize
new2.36 KB

The patch in #23 no longer applies cleanly. Here is an updated version.

Note the default behavior has changed since the patch in #23. A requirement for the comment to be published has been added since the #23 patch.

I don't think this patch should be included in Drupal core unless it is expanded to include more permissions. IMHO, the list should be "edit own comment", "edit any comment", and "edit comments with replies".

jacob.embree’s picture

Version: 7.x-dev » 6.x-dev
Component: base system » config.module
Assigned: maartenvg » Unassigned
Status: Needs work » Closed (outdated)

"Edit own comments" exists in Drupal 7 and Drupal 8.
Marking "Closed (outdated)" for Drupal 6 because Drupal 6 has reached end of life.