Permissions to see files

kors4r - January 24, 2008 - 22:47
Project:Docs
Version:5.x-1.0-alpha3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Something wrong is with permisions to see and download files.

My drupal: 5.6.

In permission rules in my case permission to see uploaded files for anonymous is unchecked. But - anonymous users can see link "Downloads" in navigation menu and can brows and download files.

I know, that in docs.module is (line 198):

function docs_nodeapi( &$node, $op, $teaser, $page) {

   $cache = docs_memo();
   $type = $cache['docs'] ? $cache['type'] : variable_get('docs_nodetype', 'File');

  switch ($op ) {
    //aka view_alter
    case 'view':
      $access = user_access('view uploaded files');
      if( $access ) {
        $node->content['docs_info'] = array(
            //me don't likes that, but it'll do for now
            '#value' => docs_node_information( $node ),
            '#weight' => -1,
            '#theme' => 'theme_docs_node_info',
          );

      }
      break;
    case 'validate':
      //not redundant check, should be fast enough, otherwise blame php
      if( $node->type == $type && empty($node->files) ) {
         form_set_error('upload', t('You must upload at least one file'));
      }
      break;       

  }

}

...but somethings wrong.

My patch:

in this code (line from 18):

function docs_menu( $may_cache ) {
  $items = array();
 
  if ( $may_cache ) {
    $items[] = array(
      'path' => 'admin/build/docs',
      'title' => t('Document manager settings'),
      'description' => t('Change the behaviour of the document manager'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array( 'docs_admin_settings' ),
      'access' => user_access('administer site configuration'),
    );
  } else {

    //the directory browser
    $items[] = array(
      'path' => 'docs',
      'title' => t('Downloads'),
      'description' => t('Document manager download interface'),
      'callback' => 'docs_browser',
      'access' => TRUE,
      'type' => MENU_NORMAL_ITEM,
    );

    //for backward compatibility with an ancient filebrowser module, deprecated
    $items[] = array(
      'path' => 'browser',
      'title' => t('Downloads'),
      'description' => t('Document manager download interface'),
      'callback' => 'docs_browser',
      'access' => TRUE,
      'type' => MENU_SUGGESTED_ITEM,
    );

  }

  return $items;
}

change from:
    $items[] = array(
      'path' => 'docs',
      'title' => t('Downloads'),
      'description' => t('Document manager download interface'),
      'callback' => 'docs_browser',
      'access' => TRUE,
      'type' => MENU_NORMAL_ITEM,
    );

to:
    $items[] = array(
      'path' => 'docs',
      'title' => t('Downloads'),
      'description' => t('Document manager download interface'),
      'callback' => 'docs_browser',
      'access' => user_access('access content'),
      'type' => MENU_NORMAL_ITEM,
    );

['access' => from TRUE to user_access('access content')]

Best regars (I know - my english is very poor)
kors4r

#1

jusspitti - June 16, 2009 - 15:12

I did apply this patch, but the downloads menu still appears... wondering why...

 
 

Drupal is a registered trademark of Dries Buytaert.