Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#5 | more_editable_comments.patch | 1.86 KB | Morbus Iff |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedHmmm. 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
Comment #2
Junyor CreditAttribution: Junyor commentedThis 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?
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedI 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.
Comment #4
Junyor CreditAttribution: Junyor commentedSince 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.
Comment #5
Morbus IffI 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.
Comment #6
Morbus IffSetting status to 'patch' so this issue shows up in the patch queue [1].
[1] http://drupal.org/project/issues?projects=3060&states=8
Comment #7
Dries CreditAttribution: Dries commentedYour patch makes it possible for people to fake their IP address / hostname as well as mess with their comment's time.
Comment #8
Morbus IffBah, 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?
Comment #9
Junyor CreditAttribution: Junyor commentedMaybe doing something similar to what I suggested (i.e. a comment_validate function) is the only way around that?
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedYou have to unset() the IP address and the uid if the author does not have 'administer comments' permission. See user_save() for an example.
Comment #11
Morbus Iffweitzman: 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.
Comment #12
Junyor CreditAttribution: Junyor commentedI don't have time for this. :(
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedsee http://drupal.org/node/18656 which has a patch pending ... maybe this will be resolved over 2 years later ....