[drupal-devel] [feature] Hooks for comment enhancements
Cvbge
drupal-devel at drupal.org
Sat Aug 27 16:04:29 UTC 2005
Issue status update for
http://drupal.org/node/28255
Post a follow up:
http://drupal.org/project/comments/add/28255
Project: Drupal
Version: cvs
Component: comment.module
Category: feature requests
Priority: normal
Assigned to: Anonymous
Reported by: Eaton
Updated by: Cvbge
Status: patch (code needs review)
Ah, didn't pay attention to the fact that it's not changed in patch...
sorry about that. Happens sometimes to me ;)
Cvbge
Previous comments:
------------------------------------------------------------------------
Fri, 05 Aug 2005 05:24:26 +0000 : Eaton
Attachment: http://drupal.org/files/issues/comment.module_10.patch (2.05 KB)
I've been working on a couple modules that modify and enhance the
commenting system (file attachments in comments, and custom comment
validation for specific nodetypes). Another patch
(http://drupal.org/node/14708) would add limited form and validation
customizatoin, but this one adds nodeapi-style form_pre, form_post,
validate, and view hooks.
It's my first patch offered to the Drupal core, hope it's useful.
------------------------------------------------------------------------
Sat, 13 Aug 2005 13:54:26 +0000 : koorneef
When applied to CVS (2005-08-13):
(lucas at bsd1)/www/koorneef/test.koorneef.net/modules$ patch <
comment.module_10.patch
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: modules/comment.module
|===================================================================
|RCS file: /cvs/drupal/drupal/modules/comment.module,v
|retrieving revision 1.364
|diff -u -r1.364 comment.module
|--- modules/comment.module 1 Aug 2005 05:14:05 -0000 1.364
|+++ modules/comment.module 5 Aug 2005 05:19:14 -0000
--------------------------
Patching file comment.module using Plan A...
Hunk #1 failed at 434.
Hunk #2 failed at 1417.
Hunk #3 failed at 1427.
Hunk #4 failed at 1469.
Hunk #5 succeeded at 1699 with fuzz 2.
4 out of 5 hunks failed--saving rejects to comment.module.rej
done
I'll see if I can update the patch ...
------------------------------------------------------------------------
Sat, 13 Aug 2005 14:34:09 +0000 : koorneef
Attachment: http://drupal.org/files/issues/comment.module_11_0.patch (2.05 KB)
Found the problem: the patch file had DOS format line-endings. Corrected
in new version: 11.
Patch applies, but captcha is not appearing on comment form (it did
with the older patches, see http://drupal.org/node/14708). Have to
investigate further ....
------------------------------------------------------------------------
Sun, 14 Aug 2005 04:48:14 +0000 : Eaton
after some investigation it appears that captcha is expecting a general
'form' $op for the hook, rathre than the 'form_pre' and 'form_post' ops
that this patch supplies.
I added the pre and post operations to mirror the nodeapi form hooks,
I'm not sure that a third general 'form' op would be a good idea. Any
thoughts?
------------------------------------------------------------------------
Tue, 16 Aug 2005 18:14:25 +0000 : moshe weitzman
i think consistency with nodeapi is important, so no 'form' operation
... this patch looks simple and useful to me.
------------------------------------------------------------------------
Tue, 16 Aug 2005 18:24:43 +0000 : arnabdotorg
+1 for consistency; we can (I will) modify captcha to form_post once
this hits core.
------------------------------------------------------------------------
Wed, 17 Aug 2005 12:53:03 +0000 : Eaton
Attachment: http://drupal.org/files/issues/comment.module_14.patch (2.75 KB)
An updated version of the patch with some tweaks. First, the 'form_pre'
and 'form_post' operations have been changed to 'form pre' and 'form
post' to reflect the nodeapi naming conventions.
Second, a 'form param' hook has been added, mirroring nodapi's form
param hook. This allows modules that modify the comment form to
integrate file uploading and other niceties.
------------------------------------------------------------------------
Wed, 17 Aug 2005 12:57:30 +0000 : chx
In the beginning comments were supposed to be simple texts.. If you add
files, how do you display without 'load' and 'view' operations? If you
add 'load' and 'view', then why not create a 'comment' node type?
------------------------------------------------------------------------
Wed, 17 Aug 2005 15:01:22 +0000 : Eaton
Your point is a good one. I'd like to work on a comprehensive comment
node type rewrite, but this was a 'good enough' solution that helped
out existing modules like captcha and doesn't break existing
comment-based solutions.
the comment file-attachment stuff is just a possible use of some of the
hooks; right now it's impossible. in the future a much cleaner solution
would be nice. i've also used the validation hooks in implementing
debate.module and microfiction.module.
------------------------------------------------------------------------
Thu, 18 Aug 2005 14:51:32 +0000 : Eaton
I've checked in a proof of concept module called image_thread that
relies on this patch to provide image uploading in a node's comments.
I'm using it on a small site for photoshop image contests. That module
is rough, but it gives an example of how the new hooks might be used to
provide more complex enhancements.
http://cvs.drupal.org/viewcvs/drupal/contributions/modules/image_thread/
------------------------------------------------------------------------
Sun, 21 Aug 2005 14:46:10 +0000 : chx
Important notice: if this gets in, then project module can be overhauled
to use the comment system!
------------------------------------------------------------------------
Sat, 27 Aug 2005 00:46:42 +0000 : Eaton
Anyone willing to review this for 4.7 inclusion? I have high hopes...
------------------------------------------------------------------------
Sat, 27 Aug 2005 01:04:22 +0000 : nedjo
qualified +1: I have looked over but not applied this patch.
I like the added functionality. In general, it helps move us toward
parallelism between different object types--which is good. My feeling
is: unless there's a good reason *not* to expose a particular Drupal
object type (comment, term, vocabulary, user, for a start) to
nodeapi-like hooks, we should do so. If someone wants to do it with
nodes, likely there's a good use case with other object types. Case in
point: I'm continually frustrated with the inability to act on taxonomy
term views (my patch, http://drupal.org/node/10399, a year ago, went
nowhere, but maybe I should revive it).
Why not just use a node type? Because nodes are for different things
than comments--twisting them into comments is bad practice.
The potential to use this for project.module, as suggested, is an added
bonus.
------------------------------------------------------------------------
Sat, 27 Aug 2005 15:14:06 +0000 : Cvbge
A question about last patch: in db_query("UPDATE
{node_comment_statistics} SET comment_count = %d,
last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid
= %d WHERE nid = %d", 0, NULL, 0, 0, $nid); why do you use NULL for
last_comment_timestamp if it'd %d? It will be changed to '0', so if you
want to use reall sql NULL type you need to put it directly.
------------------------------------------------------------------------
Sat, 27 Aug 2005 15:59:00 +0000 : Eaton
Actually, that line isn't one of the added or changed lines, it was in
the CVS copy that I patched from. I can take a look to see if the CVS
version has changed dramatically since I created the patch -- I haven't
had a chance to update in a couple of days.
More information about the drupal-devel
mailing list