I'd like for admins to be able to edit the author of a comment (and maybe timestamp). This is current possible with nodes, but impossible with comments.

CommentFileSizeAuthor
#5 more_editable_comments.patch1.86 KBMorbus Iff
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Hmmm. Over a year and still no patch ... This is a pretty easy enhancement for a developer just starting with Drupal. See comment_form() in modules/comment.module

Junyor’s picture

Assigned: Unassigned » Junyor

This is a bit harder than it might initially look. The actual change is in comment_admin_edit(), which calls comment_save(). Unfortunately, comment_save() doesn't allow you to save the author and timestamp fields. I can add that to comment_save(), but then we have to do some validation on the input, i.e. check that timestamp is in the right format and that author exists.

I need to do some of these changes for my MT importer anyway. I'm leaning toward creating a comment_validate() function to validate input before calling comment_save() (which I'd change so it's able to handle all of the comment fields). This would take some work away from other functions (comment_post(), for instance) and make the comment module work a bit more like the the node module.

Comments?

moshe weitzman’s picture

I like that plan. comment_save() should then return the $cid just like node_save() returns a $nid.

After committing this change, a few contrib modules will need updating since they rely on comment_post() to return nothing or an error.

Junyor’s picture

Since I'm new to Drupal and PHP, I'm going to work against the HEAD branch, especially since we're so far along in the 4.4.0 release process. It might take me a while to do this, too. That should leave the contrib module changes until the next release.

Morbus Iff’s picture

I don't currently have the time to implement a full patch for this functionality (it has been added to my personal TODO list), so I've attached a patch that partially gets us there. The patch solves two problems (it helps implement the current request, but also implements required features for importer scripts): timestamps are now editable, as is the IP address of the commenter.

Morbus Iff’s picture

Setting status to 'patch' so this issue shows up in the patch queue [1].
[1] http://drupal.org/project/issues?projects=3060&states=8

Dries’s picture

Your patch makes it possible for people to fake their IP address / hostname as well as mess with their comment's time.

Morbus Iff’s picture

Bah, didn't even think about that :( The IP I could care less about, but something needs to be done about the timestamp... otherwise, there's no way any import script can use the comment_post API to import comments. Maybe import scripts should just use raw SQL for comments?

Junyor’s picture

Maybe doing something similar to what I suggested (i.e. a comment_validate function) is the only way around that?

moshe weitzman’s picture

You have to unset() the IP address and the uid if the author does not have 'administer comments' permission. See user_save() for an example.

Morbus Iff’s picture

weitzman: was that to me? I'm not sure that'd help out any sort of MT import at all (although, it's a decentish solution for generic usage). In my case, imports are being done as anonymous comments, so there never is a uid to check for administer permissions (and thus, passed timestamps and IP [w|sh]ould be ignored.

Junyor’s picture

Assigned: Junyor » Unassigned

I don't have time for this. :(

moshe weitzman’s picture

see http://drupal.org/node/18656 which has a patch pending ... maybe this will be resolved over 2 years later ....