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
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | d6-comment-edit-own-permissions.patch | 2.36 KB | john franklin |
| #23 | d6_edit_own_comments.patch | 1.7 KB | akeane |
| #12 | 290246_edit_own_comments_permission.patch | 5.48 KB | maartenvg |
| #10 | 290246_edit_own_comments_permission.patch | 5.44 KB | maartenvg |
| #7 | 290246_edit_own_comments_permission.patch | 4.92 KB | maartenvg |
Comments
Comment #1
Travis commentedUpdated patch file.
Synopsis: I missed a spot. WORO comments now come with a reply link...
Comment #2
rickvug commentedTravis,
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.
Comment #3
catchThis 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.
Comment #4
maartenvg commentedI 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.
Comment #5
maartenvg commentedI'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. :)
Comment #6
Anonymous (not verified) commentedThe last submitted patch failed testing.
Comment #7
maartenvg commentedChasing head.
Comment #8
catchI'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.
Comment #9
catchComment #10
maartenvg commentedI 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().
Comment #11
catchThe update will be run even if comment module is disabled. However, the update should use db_insert() I think.
Comment #12
maartenvg commenteddb_insert() ... check!
Comment #13
keith.smith commentedIf you have to reroll, I posit that
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)...
Comment #14
catchOr even "Allow users to edit their own comments until they are replied to" maybe? Moving this to usability queue for review on the strings.
Comment #15
maartenvg commentedI 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!
Comment #16
maartenvg commentedcrosspost
Comment #17
keith.smith commentedOr "Allow users to edit their own comments (as long as no follow-up replies have been posted."
Comment #18
catchMaarten - good points - 'allow' and 'user' on the user permissions page are a bit redundant.
"Edit own comments until a reply has been posted" maybe?
Comment #19
keith.smith commentedYeah, 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.
Comment #20
maartenvg commentedLet'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)."
Comment #22
SeanBannister commentedSub
Comment #23
akeane commentedFrom #12 - seems to work.
Comment #24
john franklin commentedThe 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".
Comment #25
jacob.embree commented"Edit own comments" exists in Drupal 7 and Drupal 8.
Marking "Closed (outdated)" for Drupal 6 because Drupal 6 has reached end of life.