Short description
This module creates new settings for each FileField field to define different file upload max size limit for each user role (the limit can apply to single file or to the whole node's files).
Module full description
The Filefield Role Limit module is an extension of CCK FileField module and adds the capability to limit the max upload file size for each different user role.
This module creates new settings for each FileField field to define different file upload max size limit for each user role (the limit can apply to single file or to the whole node's files).
Different limit values can be provided for each user role and the module will automatically switch to default FileField max upload size behavior if no settings per user role are provided.
The Filefield Role Limit module works also with ImageField module.
Dependencies
Sandbox project
http://drupal.org/sandbox/kongoji/1445696
Core version
6.x
Git access
git clone --branch 6.x-1.x http://git.drupal.org/sandbox/kongoji/1445696.git filefield_role_limit
PAReview
http://ventral.org/pareview/httpgitdrupalorgsandboxkongoji1445696git-6x-1x
Screenshot
See attached file.
Author's note
This module was born from the need to have separate max upload size both for each role and node. I searched for long time a module who could extend FileField in that way, but I couldn't fine anything fitting my needs.
Reviews of other projects
http://drupal.org/node/1454106#comment-5650010
http://drupal.org/node/1454042#comment-5650160
http://drupal.org/node/1390524#comment-5652088
Reviews of other projects #2
http://drupal.org/node/1458772#comment-5661178
http://drupal.org/node/1457398#comment-5666114
http://drupal.org/node/1458858#comment-5666502
Reviews of other projects #3
http://drupal.org/node/1463358#comment-5681276
http://drupal.org/node/1434388#comment-5683354
http://drupal.org/node/1429208#comment-5683408
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | File size | 41.08 KB | wilmar81 |
| #1 | File configuration | 23.85 KB | wilmar81 |
| filefield_role_limit.png | 80.4 KB | kongoji |
Comments
Comment #0.0
kongoji commentedmade a sentence more clear to understand
Comment #0.1
kongoji commentedMade module short description clearer
Comment #1
wilmar81 commentedHi!
I just tested your module and noticed a bug: although I set a maximum file size for "authenticated" role, I could upload a file with a greater size.
Here's how you can recreate the bug:
1- I created a user with role "authenticated"
2- I created a content type and added a new field as you suggested in README.txt
3- The field settings are as follow:
- Permitted upload file extensions: pdf
- I didn't configure 'Maximum upload size per file', but configured 'Maximum upload size per file per role' and set it to '10K' for authenticated users.
The file I uploaded has 1.5M.
Even when I set 'Maximum upload size per file' (2M) and 'Maximum upload size per file per role' (10K), I'm still able to upload my file (1.5M).
You can see attached files.
Comment #2
kongoji commentedThank you wilmar81 for your review!
I reproduced the bug and I'm sorry about it, I missed some checks in the module and it worked anyway for me because of other developing I did to other modules.
Now I did a new drupal clean install and I corrected the bug (or at least now it works for me).
I took the chance to refactor the code a little bit using hook_form_alter to change the max file size dinamically,
moreover I modified .install file to make sure this module is always weighter than FileField module.
Right now ventral.org online tool is not working, so I made code checks on my local installation. As soon as it will be back online, I'll check with the online tool too.
Wait for your feedbacks again!
Comment #3
mkadin commentedGood work on this module. I've test it it and it works pretty darn well. A few notes from my review:
1) I was able to run the PAReview.sh script on your work, and it passes without issue.
2) There are a few places in your code where you have commented out code sections. I think the convention is to avoid this type of stuff...comments should be for just that...comments. :)
3) It's great that you provide some information to the user when they install the module via drush. The text is escaped funkily though. it's outputted with some HTML entity encoding:
FileField Role Limit settings are available for FileField fields under Administer > Content management > Content types or Administer > Content management > Content types > Fields.
4) Lastly, I think the descriptions for the text fields that take the maxmimum upload sizes could be a little overwhelming, and they all say pretty much the same thing. Imagine a site with 10 or 20 roles, that page could become a little crazy. Maybe there's some way to explain what should be put into each textfield more generally? Core does seem to have its explanation twice, but having it 40 times might be a bit much.
Other than that it looks pretty great to me! I could definitely see a use case for this in my work.
Comment #4
kongoji commentedThank you for your review mkadin!
You pointed out very good points, I think I fixed all of them:
2) I removed commented code, it was there because of the previous fix from wilmar81's review.
3) I totally forgot about drush! I changed "
>" html entity with the char ">", now it should work fine even on Drush.4) That's a very interesting point, thank you for your suggestion. I moved description from every field to the parent fieldsets only: you were right, it looks a lot better now! I also tried to semplified a little bit the sentences. They are a copy of the FileField max upload size description for the original fields, so I tried to not change them too much.
Turn this issue to "needs review" again, hope to have new feedback soon!
Comment #4.0
kongoji commentedCorrected a sentence grammar mistake
Comment #4.1
kongoji commentedAdded a review of other application
Comment #5
jpontani commentedJust being kinda nitpicky design-wise, but let's say I want to use this on my live site. My live site has 18 roles currently, fieldset is going to be HUGE with that many roles. Why not just switch to an addition style where you choose the role in a drop down and have a textbox next to it, and clicking Add actually adds that role/limit check instead of having it save blanks initially?
Just a thought...now on to manual review.
- You still have some commented out code (lines 106, 108, 122) in your .module file.
- You have a few code lines that are LOONNNGGG. Try spanning them across multiple lines (lines 53, 60, 255, 276)
- You have quite a few occurrences of "[some boolean] === TRUE", this is unnecessary. For example line 35 has
Comment #6
kongoji commentedHi jpontani, thank you for your review!
I implemented mkadin's suggestion about interface (comment #3) moving every field description to a single fieldset description in the top. I believe his solution is a good halfway between compact and simple interface, but I'm seriously taken your suggestion for a new version of the module to be realized after it will become a full project.
I fixed all other points you wrote, deleting commentend code, concatenating long strings in multiple rows and simplifying "if" structures.
Hope to get new feedbacks soon!
Comment #6.0
kongoji commentedAdded a new review of other applications
Comment #7
kongoji commentedComment #8
klausiReview of the 6.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.
manaul review:
Otherwise I think this is nearly ready. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #9
kongoji commentedHi klausi, thank you for your review!
I fixed all points you said, I only have some concern about
isn't more simple for translators to have a single sentence to translate rather than having N identical sentences except the module's name?
I mean, look at how many strings have to be translated, when it would be a lot simpler to have a standard like The %name module installed successfully.
It's just my opinion (I changed the sentence the way you told in my module), but I think that localization work should be standardized a little bit more.
Changed to "needs review" again, wait for your feedbacks and reviews!
Comment #9.0
kongoji commentedAdded a review of other project
Comment #9.1
kongoji commentedAdded a new project review
Comment #9.2
kongoji commentedAdded a new review link
Comment #10
kongoji commentedNew Reviews of other projects (Reviews of other projects #2) added.
Comment #11
klausimanual review:
But that are just minor issues, otherwise I think this is RTBC. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #12
klausiForgot to remove the tag.
Comment #12.0
klausiAdded a new review
Comment #12.1
kongoji commentedAdded new project review
Comment #12.2
kongoji commentedAdded new review of other project
Comment #13
kongoji commentedHi klausi,
thank you for reviewing my project!
I think I've been able to fix all the things you noticed, removing filter_xss() from .install file and concatenating the field description strings.
I added 3 new reviews (see "Reviews of other projects #3"), so I add a bonus tag.
Comment #14
patrickd commentedPlease don't assign the issue to your self, only the current reviewer should do this.
Comment #15
klausiAssigning to tim.plunkett, as he said he might have time to review this.
Comment #16
tim.plunkettThe module looks great, and welcome to the community of project contributors on drupal.org.
I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
As you continue to work on your module, keep in mind: Commit messages - providing history and credit and Release naming conventions.
Comment #17
kongoji commentedWow! Thank you tim.plunkett and everybody else who spent time reviewing this project (wilmar81, mkadin, jpontani and klausi, thank you!)
The review project gave me the chance to learn a lot more about coding drupal modules, I'll keep an eye on projects waiting for reviews queue.
Project page is now available here:
http://drupal.org/project/filefield_role_limit
Thank you all!!!
Comment #18.0
(not verified) commentedAdded new other project review