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

Comments

njkt’s picture

StatusFileSize
new1.81 KB

I wrote a small patch for this actually...

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

njkt’s picture

StatusFileSize
new1.66 KB

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

njkt’s picture

StatusFileSize
new1.81 KB

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

Chill35’s picture

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...

foreach (module_implements('file_download') as $module) {

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

Thanks!

njkt’s picture

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.

Chill35’s picture

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!

njkt’s picture

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

Is this what you were thinking?


  $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'),
		);
	}
  }

njkt’s picture

and an update...

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


  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'),
		);
	}
  }

Chill35’s picture

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

livingegg’s picture

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.

WorldFallz’s picture

Status: Active » Closed (won't fix)

closing due to new maintainer and an unsupported version. A new 6.x-2.x version is forthcoming, please open new issues against that version when available if necessary.