[support] Issues with access arguments

Carl Wiedemann carl.wiedemann at gmail.com
Fri Apr 29 15:45:08 UTC 2011


I don't think you are using the 'page arguments' parameter correctly. Check
out the documentation on hook_menu
http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_menu/6or
peruse other modules' implementations.

I would also suggest that your effort be posted as an issue to the Private
Download issue queue and you post a patch such that you may contribute to
the existing body of work.
http://drupal.org/project/issues/search/private_download

On Fri, Apr 29, 2011 at 3:15 AM, Davide Mirtillo <davide at ser-tec.org> wrote:

> Hello, i'm trying to develop a module similar to private_download, but
> with multiple directories:
>
> http://drupal.org/project/private_download
>
> The module has been written based on this post:
>
>
> http://www.drupalcoder.com/blog/mixing-private-and-public-downloads-in-drupal-6
>
> I managed to create the hook_menu implementation, but i am running into
> issues with the access callback function.
>
> My drupal install seems to completely skip the access argument check and
> i can't figure out why, since the same access arguments variable present
> in the hook_menu implementation in the original module is working
> flawlessly.
>
> I'd really like some ideas on why the files are downloadable by everyone
> and the permission check does not have any effect.
>
> This is the code of my custom module:
>
> /**
>  * Implementation of hook_perm().
>  */
>
> function custom_private_download_perm() {
>  return array('access role A files', 'access role B files');
> }
>
> /**
>  * Implementation of hook_menu().
>  */
>
> function custom_private_download_name_menu() {
>  $items = array();
>
>  $items['system/files/kb/role/a/%'] = array(
>    'access arguments' => array('access role A files'),
>    'type' =>  MENU_CALLBACK,
>    'page callback' => 'file_download',
>    'page arguments' => array('kb/role/a'),
>  );
>
>  $items['system/files/kb/role/b/%'] = array(
>    'access arguments' => array('access role B files'),
>    'type' =>  MENU_CALLBACK,
>    'page callback' => 'file_download',
>    'page arguments' => array('kb/role/b'),
>  );
>  return $items;
> }
>
> /**
>  * Implementation of hook_file_download().
>  */
>
> function custom_private_download_file_download($filepath) {
>  // define default file header attributes
>  $header = array(
>    'Content-Type: '. file_get_mimetype($filepath),
>    'Content-Length: '. filesize(file_create_path($filepath)),
>    'Content-Disposition: attachment; filename="'.
> mime_header_encode(basename($filepath)) .'"'
>  );
>  // additional user-defined file header attributes (if any)
>  return array_merge($header, explode("\n",
> variable_get('private_download_header', "Content-Transfer-Encoding:
> binary\nCache-Control: max-age=60, must-revalidate")));
> }
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20110429/527b4059/attachment.html 


More information about the support mailing list