I am trying to adapt the download_count module to work with filemanager, and I can't seem to get filemanager to invoke my download_count_filemanager_download() function.

You can see a fairly recent version of my code at: http://drupal.org/node/186695#comment-623732

In using watchdog() in various places within the function filemanager_transfer(), I have determined that my download_count module appears in the array output by the module_list() function, but does not appear within the foreach() loop.

I can't figure out why this is happening! Can anyone help me out here?

Thanks,
~ j.Wade

Comments

cscsteve’s picture

Looking at the filemanager code, it looks like the hook is only called if the file area is marked private. And, only the first module to return anything gets to do anything... Thus, when attachment responds, the function quits and your hook never gets called.

If all the files you're concerned about are private, then you could adjust your module weight to ensure your hook gets called before attachment. Make sure that your hook does not return anything, or you'll break the attachment module.

If not, it looks like we've got to come up with a new stragey to support these kind of things. Something similar to the nodeapi hooks maybe, where we pass the action and data in that can be acted upon?

jwade’s picture

I ended up solving this by modifying the weight value of the Attachment module so that my module is parsed before Attachment. The Attachment module was returning a value that ended the loop that parses the module hooks. My module appeared further down in the modules list, so it wasn't being parsed. I added a command to my install script that changes the weight of the Attachment module, and now it is working.

One other side-note on this: I have applied for CVS access and it has been granted, but I have not yet had time to post my "download_count_fm" module. If anyone is interested in checking it out and helping me find and/or fix bugs, contact me through my personal contact form to let me know. It would help motivate me to get the code posted sooner.

~ j.Wade

jwade’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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