By tpete1k on
I'm using the fileshare module to allow sharing of files for users (authenticated can upload/download, anonymous can only download). The problem is that any authenticated user can create a folder or delete a folder. Is there a way to restrict this access? I only want the admin to be able to create/delete fileshare folders. I've looked in access control and roles, searched the forums etc. but can't figure it out. Is there another module that might work better?
Comments
That's my question too
Fileshare seems really useful but I too would like to prevent users from deleting folders. On my site I allow Content Managers to upload and delete files at the right place in our file system but it's too easy for them to delete a whole directory and its contents by mistake.
Is there a good way of limiting folder create/delete?
Thanks.
Possible Solution to Fileshare: Limit Folder Create/Delete?
Let me preface this with I'm no programmer and only know enough about PHP to recognize it when I see it. Reading the various posts I think I developed a rough work-around/fix. Thanks goes to dondurito for his post about limiting folder creation and opening my eyes to doing this for deleting files.
Open fileshare.module and go to hook_perm section, approximately line 68. Under function fileshare_perm, I added ,'delete files' as an option. Then go to section that handles deleting files (line 520). Line 528 does a check against access to deleting files. I changed (user_access('modify files') to (user_access('delete files'). In theory this should then check if they have access to delete files as was created in the first part. Reupload the module, go to Access Control, check delete files under fileshare for the appropriate roles, and voila it should work. All roles can see the red X to delete the file, but if they click on it they get a message saying they do not have that permission.
A copy of my code: first part (includes a fix from dondurito http://drupal.org/node/129445)
and the second part
If this is terribly wrong, someone please advise me. If it works, I'm glad to have helped.