How to track files downloaded with filebrowser

Today I had a client that wanted to track the private files their users download. They used the filebrowser module as the user interface to browse the private directory. preview of filebrowserThere is no tracking system with this module. In addition, filebrowser handles files differently than the default Drupal system. Usually every time a file is downloaded the file_download() function is called.

Solution: Creating a custom module

Inside your custom module add the following lines:

/**
 *  Implements hook_download_manager_process()
 *  its part of the filebrowser module
 */
function MYMODULE_filebrowser_download_manager_process($delta = NULL, $file = NULL, $filename = NULL) {
  switch ($delta) {
    case 'private':
      watchdog('private downloaded', "private file download: $filename");
      break;
  }
}

Now, every time a file is downloaded, it is logged to watchdog.

Additional Tools and Resources

I like to install the views watchdog module. Then, I customize it by adding a user filter

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.