Add support for project_release

njkt - March 27, 2007 - 05:16
Project:download_count
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

As it is now, files downloaded from the project_release module aren't added to download_counter, is there any way to add it?

#1

njkt - March 29, 2007 - 03:10

I wrote a small patch for this actually...

the patch also includes a previous patch from this issue: http://drupal.org/node/119860

AttachmentSize
project_release.module_0.patch 1.81 KB

#2

njkt - March 29, 2007 - 03:11

The patch was 2 parts.. here's the download_counter.module patch

AttachmentSize
download_count.module.patch 1.66 KB

#3

njkt - March 29, 2007 - 03:57

That download_counter patch was corrupt.. i'm never doing patches on windows again... here's the new version

AttachmentSize
download_count.module_0.patch 1.81 KB

#4

Chill35 - March 29, 2007 - 20:36

This is a very useful patch but I won't be commiting it for now. Let's leave the issue open so that anyone who uses the project module can apply the patch. I think that dww may solve the issue on his end, in the project module :
http://drupal.org/node/119860.

It this patch was applied, download_count would need to be generalized... applied for all modules that implement the file_download function. What do you think ?

In the admin settings... some code such as this one could be used...

<?php
foreach (module_implements('file_download') as $module) {
?>

and the admin could configure this to a "t".

Thanks!

#5

njkt - March 29, 2007 - 23:18

funny thing is, I was just thinking about this in class...

I'll mess around with it a bit over the weekend and see what I come up with, if it works out well then I'll post a follow up and if not, no harm no foul heh.

#6

Chill35 - March 30, 2007 - 07:51

I probably read your mind. Because after that thought, I could not "see" more.

I don't have implants like the actress in Medium though!

#7

njkt - March 30, 2007 - 23:55

Here's what I added to download_count_admin_settings() to add the options at least

Is this what you were thinking?

<?php
  $form
['download count modules'] = array(
   
'#type' => 'fieldset',
   
'#title' => t('Download Count Modules'),
   
'#collapsible' => TRUE,
   
'#collapsed' => FALSE,
  );
 
  foreach (
module_implements('file_download') as $module) {
    if(
$module != 'download_count')
    {
       
$form['download count modules'][$module] = array(
           
'#type' => 'checkbox',
           
'#title' => t($module),
           
'#default_value' => variable_get($module, FALSE),
           
'#description' => t('Count downloads from this module'),
        );
    }
  }
?>

#8

njkt - March 31, 2007 - 00:07

and an update...

made it so it appends _download_count to the module name when it saves the variable

<?php
 
foreach (module_implements('file_download') as $module) {
    if(
$module != 'download_count')
    {
       
$tmpStr = $module . "_download_count";
       
$form['download count modules'][$tmpStr] = array(
           
'#type' => 'checkbox',
           
'#title' => t($module),
           
'#default_value' => variable_get($tmpStr, FALSE),
           
'#description' => t('Count downloads from this module'),
        );
    }
  }
?>

#9

Chill35 - April 3, 2007 - 00:19

I need more than the name of the module. I need the name of the database where the filename can be found.

So that I can do this check :

if (filename is in that module's database && we are doing bookkeeping for that module) then
-- increment a file counter in the table {file_downloads}

The name of the database won't always be the name of the module.

Maybe I just ought to increment a counter regardless... when the filename is NOT in {files}.

I won't know IF the file was successfully downloaded, that is, I won't know if the user actually has the right to download the file. See, as soon as a user types the file URL in the browser, and the file exists, and it has "system/files" in its URL, I get signaled, that's how the file_download hook function works. We don't have a file_download_completed hook, unfortunately. So if the user gets a Denied Access Page, I won't know that - in
all cases where a module uploads files and does not record them in {files}.

For the files uploaded with the upload module, and hence recorded in {files}, I check if the user has access "right" to the node to which the file is attached, to determine if the download was a success or failure.

I can give a false positive, in medical jargon ;)

I'll have to think about this.

What are your thoughts ?

Caroline
A coder's guide to file download in Drupal

#10

livingegg - September 30, 2008 - 23:49

The project release patch can not be applied to the latest version of project release module because there is already a project_release_file_download function in the .module - that would make this patch obsolete. However, I don't think this means that this patch was included into the core project release module - because the module still does not give any information to the download counter module.

Just a heads up to anyone trying to solve this problem - it still remains unsolved to the best of my knowledge.

 
 

Drupal is a registered trademark of Dries Buytaert.