home resources search newsjoinmembers: 6968
PHP Flash Java Ruby Windows Linux
Hiveminds's picture

Hiveminds | Wed, 2005-11-02 08:20  tags: ,

Alan Harder

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:

Hiveminds's picture
This article brought to you by the Hiveminds Magazine - Staff. Contact us if you want to post an article or announcement anonymously
Anonymous - posted on: Sat, 2005-11-05 13:44.

From http://drupal.org/node/32052 .

Hiveminds posted on: Sun, 2005-11-06 23:54.

My guess would be that this is an attempt to flame or comes out of ignorance. But all opensource code, even modified opensource code is still opensource and free to redistribute. If the author has any complaints about the redistribution or use of the code then they should not place into an opensource project or use GPLed code as a base for writing code. But in any case the post has been adjusted to include the authors full name.

Had you bothered to look you would have seen that the homepage link already points to the original Drupal posting. There is also a copy of the GPL license included with the file.

Hivemindz Magazine - Editor

Anonymous - posted on: Sun, 2005-11-27 22:34.

alan is author of patch and credited here. where's the stealing?

 
CMS Comparison Matrix

Newsletter

Get updates on Hiveminds services, articles and downloads by signing up for the newsletter.

Editor's choice

Some of the better articles, stories and tutorials found at Hiveminds.

Find more

Find more of Hiveminds articles, stories, tutorials and user comments by searching.




Picked links

Hand picked websites and articles from around the web that provide quality reading.