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
I wrote a small patch for this actually...
the patch also includes a previous patch from this issue: http://drupal.org/node/119860
#2
The patch was 2 parts.. here's the download_counter.module patch
#3
That download_counter patch was corrupt.. i'm never doing patches on windows again... here's the new version
#4
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...
<?phpforeach (module_implements('file_download') as $module) {
?>
and the admin could configure this to a "t".
Thanks!
#5
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
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
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
and an update...
made it so it appends _download_count to the module name when it saves the variable
<?phpforeach (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
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
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.