Hello,
I've been working on expanding this module to limit by extensions as well as size per role.
It is nearly working. When I get it tested as clean, are you interested in incorporating it as a patch.
Just wanted to post this update here to start a conversation about expanding this module before I send the patch.
Attached is an image of the config page I have working. The limits are almost tested for files and image types.
Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | filefield_role_limit_add_extensions_1695038_5_8.patch | 11.47 KB | kongoji |
| #5 | filefield_role_limit_add_extensions_1695038_5.patch | 11.49 KB | kongoji |
| #3 | filefield_role_limit.tar_.gz | 45.69 KB | darrell_ulm |
| #3 | filefield_role_limit_add_extensions_1695038.patch | 10.99 KB | darrell_ulm |
| 5009c8cc9d29c91d5b00006c.jpeg | 134.22 KB | darrell_ulm |
Comments
Comment #1
kongoji commentedHi darrellulm,
your idea is brilliant, I look forward to see your patch!
The screenshot seems very promising and, as far as I understood, this is how your patch should work (please correct me if I'm wrong):
The extensions specified for a role have to be a sub-set of general field settings' extensions or they can be different?
To make an example, what happen if I set for a field the extensions
.mp3, .aviand for the role "Administrator" I set totally different.mp4, .mpg?Will the Administrator role see all (
.mp3, .avi, .mp4, .mpg), or there'll be a settings validation error because.mp4, .mpgis not into.mp3, .avi, or Administrator will only see.mp4, .mpg?I think this could be an interesting point to talk about, let me know.
Are you working also on the 6.x module version or (if not) are you interested to?
Thank you for having taken the time to work on expanding this module
Comment #2
darrell_ulm commentedHello again,
I don't know about brilliant, in Drupal 6 the file field, I believe had some nice role based options, but it could be useful.
Answers:
The only issue I'm having is with the widget, I need to fix it blocking on file size by role. I think this is because while developing some data got stuck in there. So I need to clean out my content fields and test it again.
It goes for the more specific, in this case .mp4, .mpg.
In your example, the admin will only have .mp4, .mpg available for upload. The options are completely by role, so if the Admin needs the other extensions, they all can be listed like: .mp3, .avi, .mp4, .mpg.
I am not right now, but I thought Drupal 6 filefield module (depreciated) had some of these options for roles.
Comment #3
darrell_ulm commentedHi, thought I would upload these in case anyone wanted to try to start incorporating limiting by extensions.
I want to get back to it, but many projects, etc. so here is some code, both a patch which should be applied to the version before the last update, and also just a file of the module with all the extension stuff added in, may be easier to try to incorporate as there are many changes.
I was hoping I could get back to it, but there are many things on my plate(s), so if useful in any way, cool. Just want to upload what is here before it gets too stale.
:)
Thanks!
*note: just changed the status
Comment #4
darrell_ulm commentedNeeded to change the status.
Comment #5
kongoji commentedHi darrellulm,
first of all, I want to thank you for this patch, it introduces some great features and you did a wonderful job with it.
The patch had a couple of @todos at the beginning, I took the freedom to fix them.
For extension validation I preferred using drupal
_file_generic_settings_extensionsfunction, so that also commas and leading dots can be handled.I also added a few
check_plainfunctions to better escape field settings.There is still one
/** @todo this!!! */comment on_filefield_role_limit_field_widget_file_form_alterfunction, but I'm not very sure what is referred to.In that function I uncommented line
//$widget[$key]['#upload_validators']['file_validate_size'][0] = $max_upload_size_plain;,otherwise file size limit wouldn't work.
Thank you again, I hope you find the time to reply me soon!
Comment #6
darrell_ulm commented@kongoji Cool! The check_plain's are the way to go, glad you caught those, wish I had more time to do more with it before I submitted it, but was hoping it would be of use. Also about _file_generic_settings_extensions, nice!
You can ignore the "/** @todo this!!! */" that is some comment I put it probably to remind myself to put in check_plains ;)
Not sure why I commented out
Probably to test the extension stuff on it's own, and that was why file size was not limiting correctly for me, makes sense. I did this a little on the rushed side, but hope it can be of use.
Did not test it yet, hope either I (or someone else) can soon,
Thank you!
Comment #7
darrell_ulm commentedTested this a little bit (patch applied fine). Seems to be behaving w/ same issues, in that it does not always report when the file is too large to upload, and in some cases will upload the file even if exceeds the limit.
Notes:
This seemed to be the same behavior I was getting before, even w/o the extension enhancement w/ the limit by size only.
Do you get the same issues when trying to add different files? I picked a file field w/ unlimited files so I could add many to a content type to test this. Do you know any reasons this might occur?
Thank you!
Comment #8
kongoji commentedHi darrellulm,
I removed the last @todo from the patch, thank you to have found the time to check my notes.
I try to reply to your notes here below:
I will investigate better on warning messages on file upload, but at the moment I don't see any easy way to fix them, since it seems to me to be a core problem.
Comment #9
darrell_ulm commented@kongoji
Yes, you are correct on both points, the 1st point about admin upload is limitless which is good, and also on the point of the Drupal 7's ajax upload not working correctly the second time after an incorrect 1st attempt.
Not sure if we're going to get a second reviewer, so I'll say:
Looks good to me.
and Thank you! :)
Comment #10
kongoji commentedHi darrellulm,
I committed the patch on 7.x-1.x-dev version (2fdd21f).
If no issue will be opened in a week from now, I'm going to release a 7.x-1.2 module version.
Comment #11
darrell_ulm commentedHi kongoji,
Thanks that is great! I hope I can test on the weekend, but feel free to release when you feel like doing it.
Thanks again.
Comment #12
kongoji commentedHi darrellulm,
since 7.x-1.2 module version is out from 2 weeks and no issues were opened in the meantime, I set this issue as fixed.
Thank you again for the amazing job you did!
Comment #14
darrell_ulm commentedHi @kongoji, looks good! I'm still interested in tracking down the issue of after an error is flagged, the next upload does not always work. I suppose this is another ticket. I'm not 100% this is just an issue with core.
If so is there a core issue we can point people to look at?
It looks like this may be the issue:
http://drupal.org/node/1020916