The sandbox url for this module : http://drupal.org/sandbox/victheme/1115096
The purpose of this module is simply to limit download quota of uc_file product file for user who purchase "membership" plans via uc_recurring.
The workflow to install the module :
1. Install uc_file and configure ubercart products so it can be downloaded
2. Install uc_recurring, configure it, create a "membership" plans, select which roles should uc_recurring grants upon purchase of the membership plans
3. Install drupie_download_role, configure it to limit how many download per X days for X roles, The module will attempt to calculate the current month for user who purchases like 4 months in advance.
4. Put the button for download theme function in your theme
The expected results for user who purchases multiple monthly membership subscription :
Example : User X purchase 4 months in advance and admin set 4 monthly download limit
The correct result : user X can only download 4 download per month for 4 months totalling of 16 downloads.
If you encounters : user X can download 16 download during the 4 months without monthly limitation, so user X can download 16 times in 1 day, then there still bug in the module left unresolved.
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | drupalcs-result.txt | 1.61 KB | klausi |
Comments
Comment #1
tr commentedComment #2
marcp commentedA couple of us looked at the code for 15 minutes and it makes good use of the Drupal API. Neither of us is experienced with the Ubercart codebase to RTBC this, so it would be great if someone familiar with the Ubercart internals could review:
1. The code around the comment that says:
which directly queries the uc_recurring_users table.
2. The other direct queries of Ubercart tables: uc_file_products, uc_files_products (is this the same as uc_file_products?), uc_file_users. Since Ubercart has been around for a while and has a core API it seems like it would be good to utilize the API as much as possible.
3. The ddr_check_access() function is doing a lot which makes it hard to review. Is it possible to break this down into more manageable chunks? Possibly pull out the "check if the user subscription is still valid" portion into a separate function?
4. Running the code through Coder would be great. It will point out some coding style issues.
Comment #3
duckzland commentedThanks for the review,
I think for this stage, my effort on the module is to focus on its working status and will clean up and refactor the code if this application got approved.
Comment #4
marcp commentedSounds good. Looks like the status is still "needs review" so if you are working on it and don't want it to be reviewed again until it's ready, please change the status to "needs work." If you'd like to have it looked at again now, I wonder if there's a way to reach out to the Ubercart community to find someone to look at this.
Comment #5
duckzland commentedI'm still looking for more review, but more on the functionality side, to make sure that the module is working / doesn't have critical bug / no major security issue.
Anyway hopefully this module can be approved :)
Comment #6
joachim commented'Drupie'?
Comment #7
duckzland commented:) "drupie" just to make the name unique to others
Comment #8
joachim commentedI think it's better to have module names that are descriptive rather than idiosyncratic... surely something like uc_file_download_quota would describe what it does and be unique.
Comment #9
marcp commentedI agree with @joachim on this one. Now's the time to change it before everyone starts using it.
Comment #10
duckzland commentedyeah, maybe need more input of the appropriate name for this module.
Comment #11
jordojuice commentedI'm with joachim on something like uc_file_download_quota as this is relevant to how Ubercart modules are commonly named. With the ever expanding list of modules hosted on drupal.org, it is becoming difficult enough for users to find the module they're looking for. I absolutely agree that it's best to provide a descriptive name like this especially when it integrates with another module like Ubercart. uc_what_this_module_does is the common format here.
Comment #12
jordojuice commentedUpdating tags
Comment #13
duckzland commentedRenamed everything to uc_file_download_quota
Comment #14
tr commentedNeeds work to conform to Drupal coding standards. Read http://drupal.org/coding-standards .
Comment #15
duckzland commentedFixed coding style as coder module suggested, renamed the functions with uc file download quota as prefix, fix minor bug
Comment #16
klausi* do not include the "version" in the info file, see http://drupal.org/node/231036
* README.txt is missing
* uc_file_download_quota.install: extra "*" on line 35 is not needed
* the comments on top of uc_file_download_quota.module belong in the README
* "Implementation of hook_perm" ==> "()" is missing
* same for hook_menu
* uc_file_download_quota_configuration_form() doc block needs to be fixed
* no newline between doc block and function definition
* theme_ddr_limit_form(): the element to be themed should be name spaced with your module name
* do not implement hook_init() to include a file!!! Inlude it when you need it.
Comment #17
duckzland commentedFixed as #16 suggested
Comment #18
klausiREADME.txt still missing.
Comment #19
tr commentedThe repository hasn't been changed since July - the issues mentioned in #14 and #16 are all still in there.
Comment #20
duckzland commentedsorry, I didnt notice that the push I did this morning failed, I've pushed the latest code to the repository.
Comment #21
duckzland commentedMoving to need review
Comment #22
klausi* Git release branch missing, see http://drupal.org/node/1015226
* line breaks in README.txt are not correct ('\r'), you should use unix line endings. see http://drupal.org/node/318#indenting
* uc_file_download_quota_help(): there should be no empty line between function and code block. Also applies to other functions.
* hook_help(): All end user text in your module should be passed through t() for translation
* do not break code lines, they can be as long as needed
* "// unlimited user fix" Comments should start with a capital letter and end with a "."
Comment #23
duckzland commented* Git release branch missing, see http://drupal.org/node/1015226
-> added
* line breaks in README.txt are not correct ('\r'), you should use unix line endings. see http://drupal.org/node/318#indenting
-> changed
* uc_file_download_quota_help(): there should be no empty line between function and code block. Also applies to other functions.
-> applied
* hook_help(): All end user text in your module should be passed through t() for translation
-> applied
* do not break code lines, they can be as long as needed
-> I disagree so not applied
* "// unlimited user fix" Comments should start with a capital letter and end with a "."
-> not important, ignored
Comment #24
klausi* Push all your recent changes to the 6.x-1.x branch
* Remove the 6.x-1.x-dev branch to avoid confusion
* README.txt line endings are still broken in all branches
Comment #25
duckzland commentedchanged the delimiter in readme.txt
pushed all new changes to 6.x-1.x branch and removed the dev branch
Comment #26
klausiComment #27
duckzland commentedFix all as #26
Comment #29
duckzland commentedrun the code against http://ventral.org/pareview/ and passed without error.
So please review it again.
Comment #30
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. Go and review some other project applications, so we can get back to yours sooner.
manual review:
Otherwise I think this is nearly ready.
Comment #31
duckzland commentedfixed everything as stated except :
"$model = $form_state['clicked_button']['#post']['sku'];": do not access raw POST data, use $form_state['values'] instead.
-> will break the module function if used with multiple forms together.
Comment #32
themebrain commentedReview 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.
Source: http://ventral.org/pareview - PAReview.sh online service
Manual review:
- Array doesn't follow coding standard http://drupal.org/coding-standards#array
- Should add t function for the text for example:
Comment #33
duckzland commentedcommited in the last commit
Comment #34
KhaledBlah commentedI am not a Ubercart expert but here's what I've seen to be problematic:
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.
Source: http://ventral.org/pareview - PAReview.sh online service
I've checked out the 6.x-1.x branch and looked at your code. Some of your lines are too long (e.g. line 14 in the module file).
As I said I am not a Ubercart expert but the logic I've seen and understood seems to be good. Good Job!
Comment #35
duckzland commentedfixed.
added new conditional actions for functions coz I'm bored just to fix formatting all the time
Comment #36
duckzland commentedMoving status to need review again
Comment #37
patrickd commentedYour project page is not very detailed, please have a look at the tips for a great project page, you may also use HTML-tags for better structure. Same with your README, make sure it follows the guidelines for in-project documentation (also have a look at the common Styles).
, please don't do such linebreaks and indentation within t() strings. as these strings will be detected automatically for translations, this is really ugly to translate.
array('1' => 'Daily', '7' => 'Weekly', '30' => 'Monthly', '90' => 'Quarterly', '360' => 'Yearly'),, You should translate this strings with t(). - also if you want integers - use them like integers NOT like strings! Using them your way makes it necessary to cast these values everytime you want to calculate something with them., using such hardcoded strings/numbers is a bad programming practice, please define proper constants.
I was not able to enable your module:
Because your setting a string (
'') as default value for the integer field uid for your table.Make sure to make a full test of your module's functionality after you applied changes! (Within installation and uninstallation!)
Comment #38
duckzland commentedThanks for the information,
1. .module, 14, 19, 336: line too long without breaks, please see some of drupal core, they also implement breaks for line too long.
2. .module, 103: Using the number in arithmetic function without type casting and working fine. t() function need to be added is true.
3. uc_file_download_quota_check_access(): return value; That is your personal opinion?
4. Noted
5. how slow is it going to be using time() a microsecond?
6. I thought once you disabling a module cache is rebuilt?
7. Yes
8. noted, which php version are you using?
Make sure to make a full test of your module's functionality after you applied changes! (Within installation and uninstallation!) -> RUDE
Please check that THIS code is written almost 2 years ago!!!!
Comment #39
duckzland commentedchanges code, and install default to use 0
Comment #40
joachim commented> 3. uc_file_download_quota_check_access(): return value; That is your personal opinion?
I'd say that's generally held standard practice...
Also:
Do you actually need 3 values? The main question is surely 'can this user download more?' and the answer is either yes or no -- you need return only TRUE or FALSE.
Comment #41
duckzland commentedyes we do need 3 return value, so we can redirect user / give user with correct messages
1 most likely user is not a member yet
2 user is a member but his/her quota is depleted
3 user still has download quota to use
about the value returned, I think its a matter of preferences. Like drupal node published status is either 0 or 1 not 'published' or 'not published'.
Comment #42
patrickd commentedNote that drupal uses constants for this not 0 or 1
See
NODE_PUBLISHED
NODE_NOT_PUBLISHED
I won't argue about programming best practices here, the reason I did not rbtc this issue was because the module was simply not working. That this code was "written almost 2 years ago" is no reason that this module is not working correctly - this is an issue you always should take care of.
Comment #43
duckzland commented"Note that drupal uses constants for this not 0 or 1"
Yeah but still the saved value is still 0 or 1. I really dont think it is a big deal to use number instead of constants.
"That this code was "written almost 2 years ago" is no reason that this module is not working correctly - this is an issue you always should take care of."
I have taken care of it, in my last commit. have u check before commenting this?
Comment #44
misc commentedSeems ok for me, setting as RTBC.
Comment #45
patrickd commentedaww, let's get this done
There is still a master branch, make sure to set the correct default branch: http://drupal.org/node/1659588 . Then remove the master branch,
Would you mind cleaning up your project page text a bit?
Thanks for your contribution and finally 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 (however be careful with this).
Thanks, also, for your
enormouspatience 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.
Thanks to the dedicated reviewer(s) as well.
Comment #46
duckzland commentedThank very much for the approval and thank you for all the reviewer that helps me improve as a coder.