This morning, I decided to make filebrowser able to share multiple directories, each with specific access permissions. I did this by making each shared directory a node and use other node_access modules for handling permissions.
This was for our client-facing extranet where we share files with each client and only want a client to see the files that are pertinent to them. I would appreciate it if others would try this out.
There were many changes, probably too many to mention, but I'll try:
* A node interface was created to manage individual filebrowser_root values as well as a table to store them.
* The filebrowser directory structure was altered to include a node id as part of the directory.
* The filebrowser_page() function now optionally takes a $node and returns the output instead of printing it if a node was passed in.
* Many of the existing functions were altered to accept a $node parameter and the $node->filebrowser_root was used instead of the global variable.
I'm sure I'm missing something, but here's what I have.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | filebrowser.mysql | 155 bytes | javanaut |
| #1 | filebrowser_nodeified_0.patch | 12.83 KB | javanaut |
| filebrowser_nodeified.patch | 12.65 KB | javanaut |
Comments
Comment #1
javanaut commentedOh, I also added a few perms:
'create filebrowser node'
'edit own filebrowser nodes'
in addion to the existing:
'access filebrowser'
I'm not sure how compatible 'access filebrowser' is with the node_access concept other than a way to categorically deny access to a role. In this patch, I've added some code for hook_access('view',$node) such that if the user doesn't have 'access filebrowser' permission, FALSE is returned and node_access is not even checked.
Comment #2
lvadillo commentedWhere can I get the mysql file and the patched (nodeified) module?
Comment #3
javanaut commentedYou'll need to apply the latest patch file in this thread. Until the module owner applies the patch (if he chooses to), the module won't exist here as a separate file.
I didn't notice that the mysql file wasn't included in the patch. I've attached it to this post.
Information on applying patches can be found here:
http://drupal.org/node/323
I hope it helps,
-Mark
Comment #4
lvadillo commentedIt sure does, thanks Mark.
Comment #5
bernardl commentedThis patch is great - thanks for writing it!
I have 2 comments:
1) Is it possible to do something about the re-write rule such that folders will not look like this:
http://www.drupal.org/filebrowser/48/folder
'filebrowser/48' should be replaced by the alias for the node
2) Would it be possible to modify the node such that you can actually have some text above the file browser? Perhaps to describe
what the files are about?
Anyways, this is a useful patch, keep up the good work.
P.S. Can we get some graphics for common formats like pdf, doc, tar.gz, zip, etc.? It'd be nifty to have those...
Comment #6
javanaut commented1) You could use the path module for specifying paths to each root directory, but when browsing through the subdirectories, the filebrowser path will return. I don't know of an easy way around this.
2) The README goes into a means of providing per-directory meta-information, but I didn't really go into that part of the code when changing it up. I suppose it should still work however the README says it should, as the underlying browsing mechanism is pretty much untouched.
Check out the admin/settings/filebrowser path for icon location. Alas, no icons ship with this module, but apache has a set of icons that may work for you in the icons directory (/usr/share/apache/icons on my server).
Comment #7
javanaut commentedI did just think of a way to use an aliased path to dynamically map to a filebrowser directory.
The menu hook could be used along with path alias info to create a dynamic path using filebrowser/NN/foodir and replacing the filebrowser/NN part with the path alias.
I'll look more into this later.
Comment #8
bernardl commentedI looked at this but couldn't figure out how to get the alias working for the folder...
I tried to set $node->path = "filebrowser/$node->nid" but that didn't seem to help.
I have set up path alias for this filebrowser, but since it's been 'nodified', the alias is set up for node/48, not filebrowser/48 - I wonder if this is a problem...?
Comment #9
javanaut commentedThe main problem that I see with aliasing 'node/123' as 'myfiledir' is that some paths are already taken, such as 'node/123/edit'. If you had a folder called 'edit' in the top directory, there would be a conflict. I haven't found a clean way around this yet. One way might be to setup all subdirs as 'node/123/filebrowser/somedir', but then the default view ('node/123') would list files whose links would have to be different from subdirs. Then, 'myfiledir' would be mapped to 'node/123/filebrowser'. Unfortunately, path module won't currently let you create paths like this.
Comment #10
gábor hojtsyThis is an interesting approach, but highly unlikely that I would ever agree on comitting the changes. This module (among other fine Drupal modules :) is trying to praise the "simple is good" or "less is more" rule. Keeping it a simple solution for simple needs makes it manageable (and let me update it in ten minutes for 4.7 from 4.5). Anyway, if you are interested in managing an extension module to this module, or we can refactor some functionality to an include file and share among the two modules, I am looking forward to it.
BTW I would suggest you look at this patch, which is supposed to be an extension on your idea.
Comment #11
gábor hojtsyThis would be a completely different module. Filebrowser is a simple FTP-like browser. It does not need to be a catch-all solution. Please open a new project if you would like to have something this different.
Comment #12
gábor hojtsy