CVS edit link for donquixote

Hallo..

I'd like to contribute a simple "Private Downloads" module, that allows to combine public and private downloads.

Currently there is no official way in Drupal 6 to combine public downloads (served by apache, better performance) with private downloads (served by PHP, with access checking based on CCK filefield permissions etc)

The only thing I found was this tutorial.
http://www.drupalcoder.com/story/406-mixing-private-and-public-downloads...

The module I'd like to contribute is based on the tutorial, except that it does not introduce a new permission, and it does not rewrite to "system/files".

Setting up the folders happens all in your central .htaccess file - you will need to do that anyway. In my .htaccess, it looks like this:
RewriteRule ^(sites\/default\/files\/downloads\/.*)$ index.php?q=$1
to protect the specified folder.

I should mention that it does not automatically protect thumbnails of protected images (generated by imagecache or imagefield), unless you specify that in your .htaccess file.

The module doesn't do much, but it's a decent solution for people who want to create a simple password-protected download area and don't like to write their own modules.

And here is the code (private_downloads.module and private_downloads.info are the only files).

<?php
// See http://www.drupalcoder.com/story/406-mixing-private-and-public-downloads-in-drupal-6

/**
 * Implementation of hook_file_download().
 */
function private_downloads_file_download($file) {
  $info = image_get_info(file_create_path($file));
  return array('Content-type: '. file_get_mimetype($file));
}


/**
 * Implementation of hook_menu().
 */
function private_downloads_menu() {
  $items[file_directory_path()] = array(
    // 'access arguments' => array('access content'),
    'access callback' => 1,
    'type' =>  MENU_CALLBACK,
    'page callback' => 'file_download',
  );
  return $items;
}
?>

-----

I plan to contribute other modules in the future, namely
- A menu display module that allows theming with suffix names (like "menu-item-link--menu-navigation.tpl.php" instead of just "menu-item-link.tpl.php") and other goodies.
- Advanced menu editor: A list of menu items to drag around (like in admin/build/menu-customize), but with inline fields to change the path and title for each item.
- Something similar for bulk editing url aliases.

Some of these already do their job on my local install, but I'd like to start my contributions with something simple, like the "Private Downloads".

-----

I hope this qualifies for CVS access?

CommentFileSizeAuthor
#1 private_downloads.zip6.49 KBdonquixote

Comments

donquixote’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new6.49 KB

And here is the zip.

donquixote’s picture

Please have a look at the following filefield issue, if you want to test this in combination with filefield.
http://drupal.org/node/516104
"Node access check for private files does not check node_access()"

There is an error in the current release of filefield, with the effect that access checking does not work as it should. To fix this, you can use the latest dev version, or apply the patch proposed in the issue.

donquixote’s picture

Hrm..
I did not know that this application would be posted in public.
If anyone has the necessary rights, could you be so kind and remove my name and city from the post? It's not that I will get into trouble if someone reads my name, I just would like to be consistent in my own privacy policy..
Thanks!

AjK’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

avpaderno’s picture

Component: Miscellaneous » new project application
Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

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