I'm currently using webfm 6.x-2.16 and webfm_statistics 6.x-1.1 on a test server.

I noticed that downloads via webfm were not being recorded in the webfm statistics table. In fact it seemed at no point during the download that the hook webfm_statistics_webfm_send() was being invoked.

After a bit of fiddling I added the hook invocation
module_invoke_all('webfm_send', $file);
To the count download code lines in function webfm_file_download() in webfm.module.

This seems to work nicely but is it the right thing to do? I am happy to submit a patch file if required.

Thanks,
Rob.

Comments

nhck’s picture

The hook isn't really necessary anymore since webfm now actually uses hook_file_download (http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...)

So in webfm_statistics one could implement something like:

function webfm_statistics_file_download($filepath) {
  if (!_webfm_managed_by_webfm($filepath)) {
    //file is not within webfm tree
    return NULL;
  }
  
//file is managed by webfm.. do your counting works.


}
nhck’s picture

Project: Web File Manager » Web File Manager Statistics
Version: 6.x-2.16 » 6.x-9.x-dev

I am just gonna move this over so Jeff can have a look

scialo’s picture

Version: 6.x-9.x-dev » 6.x-1.1
Status: Active » Fixed

I solved by implementing the code below:

function webfm_statistics_file_download($filepath) {
  if (!_webfm_managed_by_webfm($filepath)) {
    //file is not within webfm tree
    return NULL;
  }

  $file = webfm_get_file_record(NULL, $filepath);

  //we need our user
  global $user;
  //simple query to record this down load
  $query = "INSERT INTO {webfm_statistics} (uid, fid, dl_time) VALUES (%d, %d, %d)";
  $result = db_query($query, $user->uid, $file->fid, time());


}

Status: Fixed » Closed (fixed)

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

francis55’s picture

I was having 0 rows of output in the Webfm statistics table, despite downloading files . I tried pasting the code above (in#3) into the webfm_statistics.module file , and it started working!
I'm using version 6.x-1.1.
Maybe the code could be added to the module?