Closed (fixed)
Project:
Download Count
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
25 Oct 2007 at 22:56 UTC
Updated:
3 Sep 2008 at 11:59 UTC
Jump to comment: Most recent file
Comments
Comment #1
cscsteve commentedAs neither Attachment nor Filemanager use the user information (attachment calls a function to check permissions, but never directly looks at the user data), neither are probably the place to add this information.
I think the best place for it would be in the module that already is supposed to do this function, download_count. I'm sure the maintainer of that module would appreciate it if you made the module work transparently with both the standard Drupal uploads module as well as Filemanager.
If you need any hooks for notification added into Filemanager, please let me know, or provide the patch with the new hook.
Good luck,
- Steve
Comment #2
jwade commentedIt appears that the download_count module relies on the file_download() hook. [http://api.drupal.org/api/function/file_download/5].
I have two remaining issues:
1.) How to modify download_count (and or filemanager) to use a similar hook to log downloads in the database?
2.) How to list either/or requirements in download_count.info?
It does not appear too difficult to modify download_count to work with filemanager INSTEAD of the core Upload module, but I do not know if it is even possible to get it to work with EITHER of the two modules.
Most of my PHP experience involves procedural programming. Groking object-oriented PHP and the Drupal API is a bit of a stretch for me. Any advice or pointers to the relevant docs is greatly appreciated.
Regards,
~ j.Wade
Comment #3
cscsteve commentedfilemanager has a hook that is similar: hook_filemanager_download().
I don't know download_count's code, but likely:
1. Move the code currently in download_count_file_download to a new function like _download_count_fd(). Make download_count_file_download call this new function.
2. Create a new fn for the filemanager_download() hook and have it call the new common function.
The above assumes the same code will work for both uploads and filemanager. This might not be the case. I see a DB query in there. Assuming they need to be different, then keep the code in file_download, copy that code and create the filemanager_download() and modify the code to make it work. Other functions might need modifications also, I don't know.
You can test for filemanager or upload modules using the module_exists() function.
I don't know if this can easily be added to download_count, or if you need to fork the project to create a filemanager version.
the .info file doesn't support or clauses on the required modules AFAIK. Not sure what to do here, so the above suggestion might need to happen.
I'm moving this over to the download_count project as this seems more related there than to Attachment. Also, I'm guessing the maintainers there should be able to help you with that code better.
- Steve
Comment #4
jwade commentedHere is my first crack at the forked version of the download_count module. The goal is to get it to count downloads of files attached via the filemanager/attachment combination of modules.
There is still quite a but of work to do. I know that some of the descriptions still refer to the Upload module. The good news is that things look okay for the most part … nothing is broken. The bad news is that it isn't logging downloads to the database, neither via watchdog, nor direct sql insert/update queries (which is the whole goal of this project!).
The download_count module consists of 3 files: .info, .install, and .module.
download_count.info:
download_count.install
download_count.module:
Comment #5
jwade commentedI now have a working version of this module, and I have decided to call it "download_count_fm". (download_count, of course, comes from the original module; the appended fm is for filemanager.)
I will apply for drupal CVS access so I can add this to the available modules, but for now, I have attached a gzipped tar-ball of the module files.
All comments are welcome. Enjoy!
~ j.Wade
Comment #6
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #7
soundsational commentedI get an error msg after installing this module when i view the download count page. Error msg:
user warning: Unknown column 'fd.uid' in 'field list' query: SELECT f.filename, fd.uid, fd.count, fd.timestamp FROM file_downloads fd JOIN file f ON f.fid = fd.fid ORDER BY count DESC in /Applications/MAMP/htdocs/drupal5/includes/database.mysqli.inc on line 151.
I'm running Drupal 5.5 using PHP 5.2 and mySQL 5
filemanager-5.x-1.x-dev
dowload_count-5.x-1.x-dev
attachment-5.x-1.x-dev
thanks,
Comment #8
igbonine commentedSubsribing
Comment #9
kulvik commentedGood work. I'm going to test this later today. Exactly what I was looking for :)