Closed (fixed)
Project:
Web File Manager
Version:
6.x-2.9-alpha2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 Jan 2009 at 22:22 UTC
Updated:
31 May 2010 at 21:06 UTC
Jump to comment: Most recent file
Comments
Comment #1
robmilne commentedLook inside the webfm_send_file function of the webfm.module file. This is where file permissions are checked against user permissions before transferring the file. All the information required for your table resides there. I have no time currently for drupal development but I will gladly review a patch.
Comment #2
jadowd commentedOkay, I will see if I can get something to you by tomorrow afternoon.
Regards
Comment #3
jadowd commentedOkay, here is my first pass at making a data table that will track a download by user. I modified two files, the .install and the .module file. In the former, I created an update section as well as the table definitions in the install section. In the .module file, I created a function that simply populates that table with a tracking row. I am willing to maintain this additional feature in the hopes of improving this great module. I did not update the .info module as I was pretty sure that I was not supposed to do that.
Go easy on me, this was my very first patch :)
Comment #4
jadowd commentedComment #5
beckyjohnson commentedEh, I have a question, specifically where were we supposed to see the change that this patch would make? I put the patch on and updated the module and everything works but I couldn't find where it was keeping track of user downloads.
Thanks,
Becky
Comment #6
jadowd commentedall I did at this point was to make the logging occur in the data base. I don't understand how views work well enough to expose the tables and columns in the views module yet, and I need this working well enough that I can collect and pull some raw data asap. It looked to me that someone was working on integrating webfm with views, as there are several files that indicated that to me, so I am hoping that piece will be forthcoming soon and I can integrate with that soon enough.
Is that helpful?
Comment #7
beckyjohnson commentedYeah it is, thanks. We're using Webfm in my office and my bosses really want a way to track who reads what in our webfm section..now, I'm working on trying to password protect the section so that only authorized users can look like it.
Becky
Comment #8
jadowd commentedjust use the permissions interface. I have it set up the same way.
Comment #9
robmilne commentedLooks good so far (I haven't tested the patch) though the new table name should be more specific wrt download - there are other possible statistics. I think you will also have to update the views file since it isn't being actively maintained.
You might want to add some admin controls like the option to flush the stats or even to present them within the module rather than just via views.
Comment #10
jadowd commentedOkay, I got carried away on some other business, but have come back to this. My question is this... If I have created an /admin/reports interface that reads table data from the table that I created, do I need to send in a second, partial patch, apart from the one that I sent you earlier, or do you want a completely new patch with all my changes in it.
I can do either. I have not added much by way of statistics, only the fields that I had there before. That is all that I need, but I would be willing to track and maintain issues with that feature, in effect, co-support this module, if you like.
Let me know what works best for you and I will do it.
Thanks,
Comment #11
profjk commentedsubscribing
Comment #12
robmilne commentedAll patches should be against the official latest release for proper line referencing. Please create a new patch from scratch.
As for co-support, it is a always a good idea to check how new releases impact your code changes. As (unoffical) maintainer I probably won't test contributed features as extensively or in the same way as the original developer.
Comment #13
jadowd commentedOkay, I have a patch ready for testing.
What it does:
An additional table has been added to the schema.
mysql> desc webfm_statistics;
+-------- -+---------------------+------+-----+----------------------------+--------------------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------------+------+-----+----------------------------+--------------------+
| sid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| uid | int(10) unsigned | NO | | NULL | |
| fid | int(11) | NO | | 0 | |
| dl_time | datetime | NO | | 0000-00-00 00:00:00 | |
+----------+---------------------+------+-----+----------------------------+---------------------+
4 rows in set (0.01 sec)
The report query calls left outer joins against 5 tables to get necessary data.
$query = "SELECT a.sid, a.uid, a.fid, a.dl_time, b.name, b.mail, c.fpath, d.nid, e.title
FROM webfm_statistics a
LEFT OUTER JOIN users b ON a.uid = b.uid
LEFT OUTER JOIN webfm_file c ON a.fid = c.fid
LEFT OUTER JOIN webfm_attach d ON a.fid = c.fid
LEFT OUTER JOIN node e ON d.nid = e.nid";
This gives the ability to build links to the user page, the node if the file is attached to one, and the user's email as well as display the physical file path on disk. All of this information was requested by my client. The purpose of the email was to easily contact a user after the user downloaded a file.
I have created a .csv export function that end users are able to pull, as well as a manual delete function that will clean data out of the table. If desired, I am thinking that automatic report saving (maybe sending via email) and report table cleaning functions that could be executed via cron (my current client )has not asked for that, but I can see how that may be desirable.
Please import these features into the core of the module for drupal 6. Let me know when this is done and I will be happy to port this feature into Drupal 7 as well.
Thanks!
Comment #14
robmilne commentedThanks for the patch submission. I'm unable to review it at this moment because of my own schedule. I'll do my best to get back to you next week some time.
Comment #15
mr.baileysHi jadowd,
Thanks for your work on this.
When your patch is ready for testing, feel free to change the status to "Patch (code needs review)" (CNR for friends). I've done a quick review of your patch since I'm evaluating Web File Manager at the moment, and here are some comments:
instead of:
becomes
should be
Based on these comments, I've set this patch to CNW
Comment #16
jadowd commentedAll excellent feedback. I will make the necessary changes and resubmit. Thank you so much for your helpful insight.
Regards,
Comment #17
jadowd commented1. Done
2. I didn't see any tabs in the file, but I did clean out some of my non-drupal conforming spacing. I hope I got it all...
3. optional: maybe at a later time
4. I expect to expand on this feature as time goes on, so I am thinking that a more generic name is appropriate at this time.
5. Done
6. Done
7. DONE
8. done
9. done
Thanks again... Do let me know if you see anything else.
Comment #18
robmilne commentedThe more I think about what you are doing the more I am inclined toward a plugin module ala cck. My intent is to create a 'modules' subdir of the WebFM module where plugins can be contributed and allow users a finer grained control of functionality. Separation into modules also permits contributors to more easily maintain their work.
This weekend I created a mp3 player module for the contextmenu (not released but viewable on the demo site) and I'll be making it an option that can be enabled inside admin/build/modules ala cck or views. I've recently ported webfm_images (Andre Molnar's module) to 6.x and I will be adding it as well.
Can you try your hand at transforming this into a separate module? I think it would be a cinch considering that you generally are not modifying existing functions but adding new ones. The only issue might be your small mod of webfm_send_file() which would argue for the addition of a 'module_invoke_all' hook...
module_invoke_all('webfm_send')...something I could use for other purposes like alternative file streaming.
Comment #19
jadowd commentedI have a slight error in my query... attached is the revised patch.
I don't know how to use the module_invoke_all hook, but I will look into it. My hope was to simply have a bit of feedback for who has downloaded each file. To me it seems better placed within the webfm module itself. I don't really know how the modules sub directory process works, so if you want me to do that, I will need you to tell me how to go about it.
Thanks,
Comment #20
jadowd commentedI have my module constructed, I simply need the changes that you would need to make in your module so that I can know when webfm_file_send function is called. Thanks,
Comment #21
robmilne commentedThanks Jeff. I'm going to commit webfm_images and webfm_mp3 tonight as well as the hook you'll need for your statistics module. This hook...
module_invoke_all('webfm_send', $f);...is placed inside the webfm_send_file() just before the file is sent out.
Inside your module (for the sake of this example I'm calling it webfm_statistics) you have access to the file object being downloaded inside your 'webfm_send' hook function...
webfm_statistics_webfm_send($file) {...Comment #22
jadowd commentedThanks Rob,
I have linked it up and it works as it did before. I have requested a CVS account, if it gets approved, I think we will be done here.
Comment #23
jadowd commentedI have released this project in development, pending feedback from a few users/testers. If you are interested in using it and can offer some feedback as to its applications, please let me know...
the module can be found here:
http://drupal.org/project/webfm_statistics
Thanks,
Comment #24
nhck commentedNice - added a link to the module to the front page. Thank you for doing this!