Hi,

here's the patch to add support for webfm for comments. The other patches that I sent in the last days are all just preparatory work ;-) I'm setting up a forum and need the possibility to attach files to every post, original and comment. The comment_upload module is not really working well for 6.x yet, and I also prefer to have the same mechanism (webfm) for nodes and comments...

Please note:
The patch changes the database. Since comments have their own id system independent from nodes, we need another colum "cid" (comment id) in webfm_attach table. Thus a row will look like <nid,fid,weight,cid> and cid is part of the primary key. "nid" is 0 for a comment entry and "cid" is 0 for a node entry.

When you apply the patch, you must run update.php to update the table and existing entries.

The patch depends on other patches: Before you apply the patch, you must also apply the preview patch (http://drupal.org/node/249786) and the "Remove file refs for a deleted node" patch (http://drupal.org/node/282328) because the comments patch relies on their functionality.

The patch is not very complicated, just some case distinctions whenever there is an explicit reference to a node object or the node edit form etc. More or less, we just need to implement the comment_hook as webfm_comment and extend most of the database functions by a "selector" argument telling if we want to handle a node or a comment.

Permissions for viewing attachments or accessing webfm are always inherited from the comments parent node. One could add a specific permission setting to allow or disallow webfm for comments, but at the moment I just consider the nodes setting.

Please test :-)

Comments

Anonymous’s picture

StatusFileSize
new15.29 KB

I missed that the comment module itself is already settings a $comment->preview flag, so I don't have to do that (and I couldn't do it that way anyway :-)). A little bit of superflous code removed.

Frank Steiner’s picture

Come on, folks, nobody interested in testing this? Nobody longing for webfm attachments in comments in a forum?

Frank Steiner’s picture

StatusFileSize
new15.27 KB

Adjusted for version for 2.10-rc2.

robmilne’s picture

I didn't want to complicate the first (second in my case since I tagged the wrong branch) RC with db schema changes.

I've applied this patch to one of my test servers and indeed it seems to be working - thanks again Frank. I'll test more before I commit to RC3.

robmilne’s picture

Version: 6.x-2.9-alpha2 » 6.x-2.10-rc2
Frank Steiner’s picture

Yes, I didn't mean to nag you with this :-) I just had to update this for my own installation anyway because we are already running a forum which relies on webfm.

nhck’s picture

Status: Needs review » Fixed

This must have gotten in a while ago. Reopen if you don't think you.

Frank Steiner, again thanks for helping and making webfm better.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.