Can anyone suggest a module for logging / tracking downloads of node attachments strictly through the Private Files subsystem?

I'm using CCK / FileField and Filefield_paths, and have Download method set to Private. As well as recording downloads from CCK fields, I'd like to also record dnlds from the core Upload module, and from FCKeditor, etc.

It seems that counters/loggers/trackers are generally written for a specific upload system. But I need to track who downloaded what, when, from which node, etc.

Download_count / Download_counter module does not record Fielfield hits because it's written to rely on entries in the upload table, which Filefield [now] doesn't use. (And although I don't get any records into table file_downloads, I do see entries in the main report log: "Failed to download path.../file" with most of the data I need: file, user, date, IP; but Node is also needed.)

I'm going to try to contribute to Download_counter in the short term, but ideally Drupal core could have an optional logger for the Private files facility so this task wouldn't be a concern for any/all 3rd party file management module coders.

Thanks

Comments

WorldFallz’s picture

This is probably not the sort of feature that will make it into core. download_counter is supposed to handle both upload and filefield files accessed through the 'private' file system setting so if it's not working, it would seem there's bug(s) that needs fixing. I would post to the module's issue queue or contribute to the module rather than waste time and effort working on a different solution.

mudd’s picture

This post was just intended to ask if there's another logger designed for admin purposes rather than public view of filename, time, and count. I and others have already posted to download_counter issues about Filefield. But since I also need more stats than DC provides, I'm not suggesting that the maintainer change the focus of that module (but I'll ask if they want such a dual function). So I'm fooling with DC to learn how this stuff works so I can hopefully contribute an admin logger module. :)

WorldFallz’s picture

ah ok... no afaik, download_counter is the only module along these lines. in spite of the existence of similar modules, drupal.org actually actively discourages similar modules in favor of collaboration on existing modules. imo the additional info you're looking to tracks make perfect sense as part of the download_counter module-- i would think the maintainer would be grateful for the contribution.

mudd’s picture

Roger that. I was a big Joomla user once, and it's module collection was packed with overlapping projects, so point well taken. Thanks for the guidance!

WorldFallz’s picture

yeah-- i came from joomla as well. There's definitely more community collaboration here.

chrisfromredfin’s picture

What about a separate module like "private_files_tracking" that uses hook_boot to check $_GET['q'] for 'system/files' and logs to its own table. A small admin interface could be written to display the tracking...

or perhaps this could just be leveraged in a patch to download_counter?

I need this kind of tracking for filefield downloads (swf tools mp3's).

.cw.

mudd’s picture

I don't quite know what you just said -- is that a better way to intercept downloads via Private files? I haven't fully absorbed the way DC works, so haven't located where it detects that a D/L is occurring.

As for "system/files" -- I don't think that should be in the link URL or see why it's hard coded and not configurable (seems to me it's just a string that tells core to invoke certain hooks such as node access, etc). I'd also really like to see another type of path token that affects the file's location on the internal filesystem tree but doesn't appear in the link url.

In the mean time, I got the $nid by using the referer:

  function download_count_file_download($filename) {
  global $base_url;
  ...
  $refer = referer_uri();
  $alias_path = str_replace($base_url . '/',"",$refer);
  $norm_path = drupal_get_normal_path($alias_path);
  $nid = substr(strrchr($norm_path, "/"), 1);

and simplified the query to use only the {files} table (since I'm using filefield):

  $result = db_query("SELECT filepath FROM files WHERE filepath = '%s'", $filepath);
  if ($file = db_fetch_object($result)) {

So far this just populates the {file_downloads} table; more to be done to fix the view.

chrisfromredfin’s picture

meh, I think I'm just confused about what you wanted. I look at your original post and I see "I can't use download_counter because it doesn't work with FileFields." I thought that's the problem you were trying to solve? Regardless, it's the problem *I'm* trying to solve. So does download_count get me where I need to go? :)

.cw.

mudd’s picture

See a discussion about Download_counter and Filefield here: #461654: Download_count no longer works with CCK FileField. The problem is that DC is currently written to require the node id and assumes each file has an entry in in the uploads table, but somewhere along the line FF or CCK was changed to not use uploads.

I'm looking for an administrative tool to log any download via Private files. (we need to keep records, and far into the future be able to inform consumers, recall data, etc.)

Download_count already performs the logging (it calls watchdog and logs the D/L file, user, referrer, etc), so I've pinged the maintainer to see if they'd be open to adding an administrative feature to it. But strictly speaking, this isn't DC's current mission, so I posted here just to ask if there's another module for this administrative need. Since I'm a drupal newbie and still learning php and drupal coding style, I'm hesitant to submit a module just yet (As seen above it's also encouraged to contribute to an existing module rather than spin off a similar one.)