I propose we add a feature that allows users to edit their own posts for up to an hour after posting. This would allow users to correct typos but would prevent them from editing previous comments if they produced heated debates. The old typophile was like that and I thought it was nice.

Comments

profix898’s picture

Maybe this is not a bad idea! But I think you should also prevent users
from altering their comments when any subsequent comment has
already been posted. And for typos 1 hour limit seems a bit too long,
better 15-30 min.

dan_aka_jack’s picture

Yes, good idea: prevent users editing their posts once that post has been replied to.

And I agree - 1 hour is a bit long. I agree that 15 minutes would probably be better.

Thanks for your reply!

dan_aka_jack’s picture

Status: Active » Needs review
StatusFileSize
new2.04 KB

Here's a patch...

The patch does several things: firstly, it makes two new permissions: "edit own comments" and "edit all comments". Then it adds a setting in admin/comments/configure called "Comment edit duration".

Here's how I've setup the patch on my site (ukfilm.org):

1) apply the patch
2) go to admin/access permissons and give "authenticated users" the "edit own comments" permission. I've got a group called "moderators" who I've given "edit all comments" permission.
3) By default, users can edit their comments for ever. If you want to set a time-limit then go to admin/comments/configure and set a timelimit in the "Comment edit duration" box. Easy!

Thanks,
Jack

dmitrig01’s picture

Version: x.y.z » 6.x-dev
Status: Needs review » Closed (duplicate)

this got in already

cog.rusty’s picture

Status: Closed (duplicate) » Active

I don't think so. I don't see anything about "own comments" in admin/user/access or anywhere else.

Editing and deleting own comments are much requested features where Drupal falls short of the "competition".

cog.rusty’s picture

Status: Active » Needs review
cog.rusty’s picture

Status: Needs review » Active

Oops. The code was old.

Rob T’s picture

I did this in my 5.5 install. It seems to be working fine.

1kenthomas’s picture

Assigned: Unassigned » 1kenthomas

This thread is a little old a but I propose an additional addition: comments revisions. Since the status of the above is unclear (http://drupal.org/node/228112) assigning to myself for the time being.

cog.rusty’s picture

Regarding comment revisions, you may want to check this module if you haven't already.

http://drupal.org/project/comment_revisions

1kenthomas’s picture

Thanks (I had searched for every module starting with "comments*".) Though my point was more "everything is a node," I'll take a look at the code.

maulwuff’s picture

Here is a patch for 5.7
It is based on the one from #3

I added
#mod start and
#mod end for each mod, to make future updates easier. :)
it also contains the original parts commented out.


--- Desktop/drupal-5.7/modules/comment/comment.module 
+++ htdocs/drupal/modules/comment/comment.module 
@@ -212,7 +212,10 @@
  * Implementation of hook_perm().
  */
 function comment_perm() {
-  return array('access comments', 'post comments', 'administer comments', 'post comments without approval');
+#mod start
+  #return array('access comments', 'post comments', 'administer comments', 'post comments without approval');
+   return array('access comments', 'post comments', 'administer comments', 'post comments without approval', 'edit own comments', 'edit all comments');
+#mod end
 }
 
 /**
@@ -560,6 +563,17 @@
     '#options' => array(t('Display on separate page'), t('Display below post or comments')),
   );
 
+#mod start
+  $form['posting_settings']['comment_edit_duration'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Comment edit duration (seconds)'),
+    '#description' => t('Enter the length of time for which users with \'edit own comments\' permission should be able to edit their own comments.  Enter 0 if you would like to allow users to edit comments for ever.'),
+    '#default_value' => variable_get('comment_edit_duration', 0),
+    '#size' => 10,
+    '#maxlength' => 10,
+  );
+#mod end
+
   return system_settings_form($form);
 }
 
@@ -575,8 +589,19 @@
   global $user;
 
   if ($op == 'edit') {
-    return ($user->uid && $user->uid == $comment->uid && comment_num_replies($comment->cid) == 0) || user_access('administer comments');
-  }
+#mod start
+    #return ($user->uid && $user->uid == $comment->uid && comment_num_replies($comment->cid) == 0) || user_access('administer comments');
+	if      ($user->uid && $user->uid == $comment->uid && comment_num_replies($comment->cid) == 0 && user_access('edit own comments') || user_access('administer comments') ) {
+      if (variable_get('comment_edit_duration', 0) == 0 || user_access('administer comments') ) {
+        return TRUE;
+      } else {
+        return (($comment->timestamp + variable_get('comment_edit_duration', 0)) > time());
+      }
+    } else {
+      return (user_access('edit all comments'));
+    }
+#mod end
+   }
 }
 

maulwuff’s picture

doubleklicked :-/

maulwuff’s picture

The patch from #3 and #12 locked out the admin from editing comments after the countdown has finished. Improved version on #12

aharown07’s picture

OK, pretty new to Drupal and definitely not strong in PHP.... so this code should work in 5.x? And can I paste it whole in comment.module or just the parts between "+mod start" and "+mod end"?
I'll be sure to back up before I try this, too.

aharown07’s picture

StatusFileSize
new74.36 KB

OK, figured out that if you mannually apply a patch, you remove lines beginning with - and add lines beginning w/+.
Did that, but what happens is:
1. All comment module permissions disappear from Access Control (the Comment module doesn't show at all)
2. Users can't edit their comments at all

So something's clearly not quite right in my code. Maybe this is because I'm using 5.11? Or maybe I missed something else? Can anyone help me find the trouble? I'm attaching the hacked version of my comment.module.

Also, if somebody wants to made a working module out of this for 5.x, I'd sure be interested in that... maybe even willing to pay for it interested (hope this isn't the wrong place to say that).

maulwuff’s picture

this patch was for 5.7
I have not tried to apply it to the 5.12er version.
applying patches manually is very hard. if your module disappears completely, you might have messed something up. see here also: http://drupal.org/node/60108

aharown07’s picture

Well the patch wasn't all that large... it looks way easier to put it in manually than to download and install all the stuff needed to apply it.
Anybody know if there were changes to comment.module between 5.7 and 5.11 (I'm actually still on 5.11)? Doesn't seem likely there would be much. Maybe I should just do it again from scratch and see if can find anything I missed.

cog.rusty’s picture

No, no changes to comment.module between 5.7 and 5.11 (see http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/comment/comment.mo...)

aharown07’s picture

StatusFileSize
new74.39 KB

Eureka!!

I hope it's OK to post the entire comment.module code here. Will do as attachment.
What happened was that in manually putting in the patch, I had accidentally removed function comment_perm{stuff here} Had the "stuff here" w/o the actual function.

Anyway, as fixed, it's working so far in 5.11. For folks who "can't patch" (like me) here's the whole thing. Just remove "txt" from the end.
"#mod" marks the altered areas.
Of course, when it comes time to upgrade, will have to rewrite in new comment.module... unless maybe somebody can tell me how to do this with overrides in template.php and/or comment.tpl.php?

csbhat’s picture

Version: 7.x-dev » 6.x-dev
Assigned: Unassigned » 1kenthomas
StatusFileSize
new74.94 KB

I've created a patch for drupal 6. This is my first very small contribution to Drupal community!

damien tournoud’s picture

Version: 6.x-dev » 7.x-dev
Assigned: 1kenthomas » Unassigned

Feature requests need to be filled against the latest development version (Drupal 7) at this time.

csbhat’s picture

Version: 6.x-dev » 6.12
Assigned: 1kenthomas » Unassigned
Category: feature » task
Status: Active » Needs review

Please disregard the file attached earlier. Use the file attached with this comment.

csbhat’s picture

StatusFileSize
new74.32 KB

Please disregard the file attached earlier. Use the file attached with this comment.

stevenpatz’s picture

Status: Needs review » Needs work
igorik’s picture

Please send a patch primary, not whole module.
If drupal developers will do any changes in comment.module in version 6.13, this module file will be useless.

Patch is always better.
Thanks for your work, will be great to have working patch (or list of changes at least) from you.

Igorik

aharown07’s picture

FYI, the Comment Edit module now includes time-limited editing.

igorik’s picture

Hi, Is somewhere special "Comment edit" module or you think these patches on this page?

I looked for that module but I found nothing with name "Comment edit"

Can you suggest url for it?

Thanks
Igor

aharown07’s picture

It's actually Coment Edited I guess. Seems to work well for us. We have a forum with about 700 active users.
Here's a link...
http://drupal.org/project/comment_edited

sopia’s picture

Version: 6.12 » 5.1

This worked for me in Drupal 5. Thanks maulwuff!

tr’s picture

Version: 5.1 » 8.x-dev
Category: task » feature

Feature requests need to go into Drupal 8.x first, then they can be backported if appropriate.

dixon_’s picture

Status: Needs work » Closed (won't fix)

This is an excellent usecase for a contrib module to implement. It adds complexity to code and UI that far from everyone needs. There are a wide range of modules that solved most of what's been discussed here. Comment edited is one of them.