Hi,

I don't know if I'm getting the concept wrong, but I'm missing a permission to view/download all private files without giving the 'Administer files' to some role.

To clarify: I'm setting up a site where I don't need private files that are private per user but just private for authenticated users.

Thanks for hints if I should achieve that some other way.
eR

Comments

milanchheda’s picture

Not sure, if I got it correct but you can probably use public files instead of private. Public files will enable access to all files to everyone. To restrict it to just the authenticated users, you can capture the file callback and override it.

For e.g. if your files are stored in sites/all/files, than override it's callback whereby you can simply check if the user is logged in or not, using user_is_logged_in()

enochRoot’s picture

Thanks for the answer.
What exactly do you mean by 'its callback' ?
Also public files can be seen/downloaded by anybody, just by http request - no Drupal callbacks involved...

eR

dazz’s picture

I had a similar case, fix it by using hook_file_entity_access

function hook_file_entity_access($op, $file, $account) {
  /* allow every logged in user to view all files */
  if ($op == 'view' && $account->uid) {
    return FILE_ENTITY_ACCESS_ALLOW;
  }
}
enochRoot’s picture

Thx,
I'll try somthing like that.

devin carlson’s picture

Version: 7.x-2.0-unstable7 » 7.x-2.x-dev
Component: User interface » Code
Assigned: Unassigned » devin carlson
Status: Active » Needs review
StatusFileSize
new4.98 KB

A patch to add a new permission "view any private files".

devin carlson’s picture

Updated patch with more consistent permission name.

devin carlson’s picture

Status: Needs review » Fixed

Committed to 7.x-2.x.

enochRoot’s picture

Status: Fixed » Needs review

Well, the new permission shows up as an option, but I still need the 'Administer files' permission for the media browser to show any private file. Is that intended?

thx,
eR

devin carlson’s picture

Status: Needs review » Fixed

@enochRoot not sure, it sounds like it might be an issue with the Media module.

ParisLiakos’s picture

Status: Fixed » Needs work

we should add restrict access => TRUE here

ParisLiakos’s picture

Status: Fixed » Closed (fixed)

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