Permissions By Role

SomebodySysop - April 25, 2008 - 05:37
Project:Private Upload
Version:6.x-1.0-rc2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

I understand that a file is uploaded as Private depending upon users access to node the file is being attached to and 'view uploaded files' permission.

I'm wondering how difficult it would be to go a step further, and only allow a user to download the file if he has a particular role?

Like, if we added a select box in the node called "Role(s) Required for Private File Download", and only allowed a user to download the Private files in that node if they had those permission(s), if present.

What do you think?

#1

SomebodySysop - May 2, 2008 - 05:37
Status:active» needs review

I've modified private_upload.module to support assigning a role to private uploads. That is, if you upload a file as "private", you can additionally say: "Only users who have Role A can download this file.".

Attached is patch to private_upload.module and new private_upload.install file.

Please let me know what you think.

AttachmentSize
private_upload.ogr_.patch 6.28 KB
private_upload.install.txt 1.53 KB

#2

shittii - May 2, 2008 - 13:17

Excellent addition! Unfortunately I don't have the know-how to patch the module or review your code. Maybe the module author starbow can do it. Thanks anyway. :)

#3

SomebodySysop - May 3, 2008 - 18:28

OK, here is the patched module and install file.

AttachmentSize
private_upload.module.txt 34.95 KB
private_upload.install.txt 1.53 KB

#4

dezolt384 - August 16, 2008 - 17:43

thanks, it works perfectly!! but i've another issue: i can't select multiple roles.
how can i fix that?
Other solution could be selecting a single role leaving unaffected other permission.

#5

SomebodySysop - August 16, 2008 - 18:11

The code is only designed to select ONE role. Sorry!

#6

bmeier - May 21, 2009 - 15:58

I'm in the process of updating this code into 6.x-1.0-RC2. I can set and save a role but no functionality is added (the only requirement for viewing a private file is to be an authenticated user). I think this may be because authenticated users will have the permission to view the node and therefore the file attached to it regardless of specific role.

I'm not very experienced with Drupal but I'll post my finished code when I figure this out. I'll also see about being able to select multiple roles.

EDIT: I have it working for a single role but I'm going to add multiple role support. It checks to see if the node has any specific permissions and if so checks if the user has access, otherwise it grants access based on authenticated or anonymous.

#7

bmeier - May 21, 2009 - 19:01

I spent some time on multiple roles and got check boxes to display for each role (and have the correct default value) but I don't know how to access their values in private_upload_form_alter. Any help would be great.

I've attached the working code for single roles I put "//MOD" tags wherever I changed things. I apologize if my coding style is awkward this is the first module I've worked on.

AttachmentSize
private_upload.module.txt 37.81 KB

#8

bmeier - May 26, 2009 - 15:14
Version:5.x-1.0-beta6» 6.x-1.0-rc2

I've finished the multiple role system (a good learning experience for me) if anyone else would like to use it. You can use the install file supplied by SomebodySysop above.

Edit: The javascript for this is really broken I don't know how to deal with it, if a file is uploaded the initial permissions you select are discarded. Afterwards if you edit the form again it will work as intended. Again any help would be great.

AttachmentSize
private_upload.module.txt 36.56 KB

#9

higgins - July 13, 2009 - 17:32
Category:feature request» bug report
Status:needs review» needs work

This module's exactly what I was looking for - file upload, downloadable for a specific user role!!! Great!

I'm quite familiar with PHP programming but I'm a drupal newb so I need to ask u for help on SomebodySysop's code (post #3).
But after I changed the code to yr code (module and install file), installed the module, I get this error: warning: Missing argument 1 for private_upload_menu() in /home/user/public_html/drupal/modules/private_upload/private_upload.module on line 45

Seems to me that the function private_upload_menu is missing its required argument. But where can I fix that?

Also, if I create a node and attach a file, I miss the checkbox for role (which was the old 'private' field). I assume, that this is caused by the missing argument which should be passed on the the function (see above). I'm using drupal 6.12!

Anyone has an idea how I can fix that issue? Would desperately need this module to work.

Any help appreciated, THANX!

#10

pjsz - October 23, 2009 - 18:29

These patches did not work for me. I downloaded the patched module and diffed it with patch my patched version and got many diffs.

Still trying. Thanks.

 
 

Drupal is a registered trademark of Dries Buytaert.