Hello,

I've read your API tutorial with interest. However, I want to know how to make it so that when the logged in user clicks on an attachment to download it, a number of points are deducted from that user's balance.

A workaround would be to place the download on a separate page to its node, and on that page have x number of points automatically deducted from the user's balance, as in your API tutorial example, but this is untidy and I would prefer my first scenario.

Also, I think the download method would have to be set as private, as with the public (HTTP) method, Drupal has no way of knowing that a file is being downloaded.

I would appreciate any help with this task.

Regards.

Comments

greggles’s picture

I think you should make the "external" page simply do the piont deduction and then redirect to the download file. This way you maintain the ease of "click a link, get the file" but still have a way to deduct the points.

Does that solve your problem?

B747’s picture

Yes, but how do I create this external page and have the original node link to it?

jredding’s picture

You could allows just create the page manually and the link to the page by hand as well as the link to the download by hand.

or

programmatically you could create a custom module that was something like
hook_menu to grab
/downloads

this page would call a custom function that would read arg(1). arg(1) would be the file id of the attachment to the node.
i.e. /download/520

This custom function would then grab the file and feed it to the client or does do a redirect to the file's path. It would also,of course, add/subtract points.

only thoughts. Good luck with the coding.

jredding’s picture

Project: User Points » User Points Contributed modules
Version: 5.x-3.x-dev » 5.x-2.x-dev
Component: Code: userpoints_basic » Miscellaneous
berdir’s picture

Status: Active » Closed (won't fix)

Sorry for pinging the participants.

Now that Drupal 7 is out, there is no support for Drupal 5 and the
corresponding modules anymore. Therefore, I'm closing all old issues
which are still open.

I suggest you upgrade to Drupal 6 or 7 and figure out if you're feature
is still needed or the bug still exists and open a new issue in that
case.