
Description I have updated upload.module and added a few hooks in comment.module to support attachments on comments. We'll use this on http://gallery.menalto.com/
for attachments on replies to forum topics. Attached zip contains
patches for Drupal 4.6.3 (works for 4.6.2 also) and for Drupal CVS (Note:untested! see notes below). Please review these changes and consider for inclusion in Drupal.
Comments on these changes:
- I accomplished most of the changes with hooks from comment.module
(module_invoke_all calls). I added 'form post', 'form param' and 'view'
hooks; insert/update/delete hooks were already present.
- upload.module has upload_comment to route these hooks to existing
functions in this module. Other changes to upload.module relate to
tracking comment attachments vs node attachments. Note: I applied my
changes to CVS to create that patch but did not test it; most changes
integrated fine, but I'm unsure if $node->vid will have the correct
value in upload_save when saving a comment attachment.
- To keep attachment loading in a single query, upload.module still
loads all attachments for the node being displayed, but splits comment
attachments off into $node->comment_files. comment.module's
comment_render then checks for
$node->comment_files[$comment->cid] before rendering the comment.
- The other change in comment.module accepts $_POST['fileop'] ==
t('Attach') as a preview action.. this seems a bit too specific;
perhaps if $_POST['edit'] exists but $_POST['op'] is not t('Post
comment') then it should assume preview. Then attach or any other added
form button would default to preview.
- The comment.module patch for Drupal 4.6.3 also has some changes to
allow comment_admin_edit to work with attachments; these changes aren't
needed in the CVS patch as admins now use the normal comment edit form.
- The 'view' hook in theme_comment needs to be added to various themes to enable display of comment attachments.
- To be more consistent with node forms, the 'form post' hook should
be after filter_form.. but I prefer attachment form above input format,
so that's where I put the hook.
- For 4.6.3 I added db indexes on both nid and cid; I see CVS now
has an index on vid which is good (we query on that for each node
view). The index on cid is not as important as we query on cid only for
editing or deleting comments.
- You can turn comment attachments on/off in settings for upload module.
File:
login or register to download Author:
This article brought to you by the
Hiveminds Magazine - Staff. Contact us if you want to post an article or announcement anonymously
|
|