Hi there!
This module restricts users from the view of the taxonomy term page, if you've replaced the listing of nodes, which are attached to a taxonomy term, by the view.
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/jepSter/2325357.git permissions_by_term
cd permissions_by_termSandbox project page: https://www.drupal.org/sandbox/jepster/2325357
Please review. If you have any questions, please feel free to ask.
Thanks.
Reviews of other projects
https://www.drupal.org/node/2342629#comment-9345825
https://www.drupal.org/node/2371277#comment-9345903
https://www.drupal.org/node/2310291#comment-9345935
Second iteration of reviewing other projects
https://www.drupal.org/node/2408789#comment-9528767
https://www.drupal.org/node/2408615#comment-9528793
https://www.drupal.org/node/2408185#comment-9528817
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | Error testdrupal.png | 13.2 KB | gaurav.pahuja |
| #8 | issue1.png | 229.91 KB | veso_83 |
| #7 | term_permissions_404_link.jpg | 5.98 KB | pushpinderchauhan |
| #7 | term_permissions_notices.jpg | 31.53 KB | pushpinderchauhan |
| #7 | term_permissions_notice_node_edit.jpg | 18.03 KB | pushpinderchauhan |
Comments
Comment #1
PA robot commentedProject 1: https://www.drupal.org/node/2325361
Project 2: https://www.drupal.org/node/2312097
As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).
If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #2
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxjepSter2325357git
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
neelam.chaudhary commentedComment #4
neelam.chaudhary commentedHi jepSter,
Your git clone path has been edited by me as the path provided was your private path not the public path which can be used for cloning of the project by any other user.
Manual review
Individual user account
OK. Applicant geekygnr is an individual user account.
Multiple applications
OK. No additional applications.
Licensing
OK. Follows the Drupal.org licensing requirements.
3rd party (non-GPL) code
OK. No 3rd party code.
Module duplication
OK. No duplication.
Project page
OK. Adequate presentation of project.
README.txt
Not OK. Please upload README.txt as per the guidelines of drupal as this is uploaded as blank file.
Code length/complecity
OK. About 400 lines of code .
Coding style
Not OK. The code is not formatted as per drupal coding standards.
Comment #5
jepster_Hi neelam.chaudhary,
thanks for your review.
I've updated the coding style and the README.txt as you've mentioned.
Please review again.
Comment #6
jepster_*status update*
Comment #7
pushpinderchauhan commented@jepSter, thankyou for your contribution.
Automated Review
Best practice issues identified by pareview.sh / drupalcs / coder. Yes, http://pareview.sh/pareview/httpgitdrupalorgsandboxjepster2325357git reported number of issues that need to be fix.
Manual Review
Also I am wonder with following code, you simply unset the field for unauthorized user but if any authorized user have updated this value then what happen. Still I am unable to complete the flow of this module so unsure how it is going to be work. Also there should be consistency for unauthorized user, at one place you are using
drupal_access_denied();and at other place401-unauthorized.Not sure about following code as I am unable to produce this message for unauthorized user.
if (!(array_shift(user_load_multiple(array(), array('name' => $name))))) {Same at this place.
$u = array_shift(user_load_multiple(array(), array('name' => $name)));So development happened and the result is the "Taxonomy Term Permissions"-module.It needs correction and also go through https://www.drupal.org/node/997024 again.The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
As I am not a git administrator, so I would recommend you, please help to review other project applications to get a review bonus. This will put you on the high priority list, then git administrators will take a look at your project right away :-)
Thanks Again!
Comment #8
veso_83 commentedHi jepSter,
The module seems to work fine although there are some minor warnings in the code, see the attachment.
Comment #9
jepster_Hi,
@ er.pushpinderrana:
Thank you so much for your detailed review!
I've done some refactoring on my module and I hope that the module is now ready for a full-project on Drupal.org. In following my answer to each point of your review.
I've done so and got no reply so far. Also I've implemented taxonomy term related permission for nodes, beside the views, in meantime.
The lines are now in max. 80 characters width. Additionally there's now more, clearer description for what the module does.
I was going trough ALL issues from pareview.sh. There's nothing outstanding now.
I hope I've done my work. Please ask if you have any issues.
Thanks again for your review!
Comment #10
gaurav.pahuja commentedAutomated Review
Best practice issues identified by pareview.sh / drupalcs / coder.
http://pareview.sh/pareview/httpgitdrupalorgsandboxjepster2325357git
Manual Review
Does not cause module duplication and fragmentation.
href="https://www.drupal.org/node/2181737">README Template
.Enabaled this module on a vanila Drupal 7.3 installation. Tried providing permission to multiple terms to different user roles. Seems to be working fine.
Comment #11
gaurav.pahuja commentedJust want to understand use of hook_node_view in your module
Somehow I generated content using devel generate module and then start getting this error:
Comment #12
gaurav.pahuja commentedComment #13
jepster_Hi gaurav.pahuja,
thank you so much for your review!
I've added an if case to permissions_by_term_node_view(); which is checking if this field exists. So you don't get this error anymore. Also I've added explaination to README.txt and on the module's project page about the setup of the module's functionality.
Checked my changes with pareview.sh again.
Kind regards
Comment #14
rafalenden commentedLooks like all issues was fixed by jepSter.
Comment #15
jepster_Hi,
I'm setting the status to "needs review" again, since there was no step forward since the "Reviewed & tested by the community" status.
Please help me, to make this sandbox project a full project.
Thanks
Comment #16
rafalenden commentedComment #17
jepster_Comment #18
jepster_Comment #19
jepster_Comment #20
jepster_Comment #21
mpdonadioAutomated Review
Review of the 7.x-1.x branch (commit ac5ebaf):
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. You have to get a review bonus to get a review from me.
Manual Review
(+) Don't split translated strings across lines just to satisy PAReview. Split strings are harder to translate.
I would split permissions_by_term_form_alter() into specifc alters for the different forms instead of having them all in one form.
(*) permissions_by_term_form_alter() for 'taxonomy_form_term' needs some sore of permission check on it. You should implement hook_permission, and define your own.
The db_select() in permissions_by_term_form_alter can utilize one of the ->fetchAll() methods for building up the results.
permissions_by_term_submit() isn't a hook_submit. It's the submit handler for permissions_by_term_form_alter().
permissions_by_term_validate isn't a hook_validate. It's the validation handler for permissions_by_term_form_alter().
In permissions_by_term_process_node(), isn't the $variables['node'] aready there?
(*) hook_process_node() is the wrong place to that logic for hiding results in a view. Look at https://api.drupal.org/api/views/views.api.php/group/views_hooks/7 for a better hook to use. I think hook_views_post_execute would be the best fit.
(*) hook_node_view should not be used to deny access to a node. There are many ways this can go wrong. You need to use the node access system. See https://api.drupal.org/api/drupal/modules%21node%21node.module/group/nod... for how to do this properly. You really need to use grants for this.
In permissions_by_term_node_view, where is field_secured_areas coming from?
You aren't using a lot of the Entity API. You can likely just use the Field API, eg field_get_items, to eliminiate a module dependency.
(*) permissions_by_term_autocomplete_multiple, the `exit(drupal_json_output($matches));` wrong. See https://api.drupal.org/api/drupal/modules%21profile%21profile.admin.inc/... and https://api.drupal.org/api/drupal/modules%21profile%21profile.module/fun... for an example in core for autocomplete w/ JSON.
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #22
jepster_Hi,
thanks for the review! It helped me to learn a few more new things in Drupal module development. So I've worked on the Permissions by Term module and I hope that I've fixed all the mentioned issues in the module right now:
[DONE] (+) Don't split translated strings across lines just to satisy PAReview. Split strings are harder to translate.
[DONE] (*) permissions_by_term_form_alter() for 'taxonomy_form_term' needs some sore of permission check on it. You should implement hook_permission, and define your own.
[DONE] The db_select() in permissions_by_term_form_alter can utilize one of the ->fetchAll() methods for building up the results.
[DONE] permissions_by_term_submit() isn't a hook_submit. It's the submit handler for permissions_by_term_form_alter().
-> I've mentioned this in the comment above the function header.
[DONE] permissions_by_term_validate isn't a hook_validate. It's the validation handler for permissions_by_term_form_alter().
-> I've mentioned this in the comment above the function header.
[DONE] In permissions_by_term_process_node(), isn't the $variables['node'] aready there?
-> This hook_process_node() is replaced by hook_views_post_execute().
[DONE] (*) hook_process_node() is the wrong place to that logic for hiding results in a view. Look at https://api.drupal.org/api/views/views.api.php/group/views_hooks/7 for a better hook to use. I think hook_views_post_execute would be the best fit.
[DONE] (*) hook_node_view should not be used to deny access to a node. There are many ways this can go wrong. You need to use the node access system. See https://api.drupal.org/api/drupal/modules%21node%21node.module/group/nod... for how to do this properly. You really need to use grants for this.
-> hook_node_view() is replaced by hook_node_access().
[QUESTION] In permissions_by_term_node_view, where is field_secured_areas coming from?
[ANSWER] I've remoed the Entity API dependency. Items for the field with the code field_secured_areas are now retrieved by field_get_items(). In this field are the terms stored, which are secured by the Permissions by Term module.
[DONE] You aren't using a lot of the Entity API. You can likely just use the Field API, eg field_get_items, to eliminiate a module dependency.
[DONE] (*) permissions_by_term_autocomplete_multiple, the `exit(drupal_json_output($matches));` wrong. See https://api.drupal.org/api/drupal/modules%21profile%21profile.admin.inc/... and https://api.drupal.org/api/drupal/modules%21profile%21profile.module/fun... for an example in core for autocomplete w/ JSON.
Yes, I couldn't get any answer since months.
After the review there are a few more modifications in the code.
Yes, I know PHPUnit very well and I know Simpletest. Maybe I'll implement some tests in a later version.
Of course the module is checked with pareview.sh again.
If you have any questions or another issues, please feel free to ask and post your issues/feedback. Any help is appreciated.
Thanks again! :)
Comment #23
klausiReview of the 7.x-1.x branch (commit dd7ad77):
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. You have to get a review bonus to get a review from me.
manual review:
Will continue later.
Comment #24
jepster_Hi Klausi,
thanks for your review.
If tested the code by PAReview.sh with http://git.drupal.org/sandbox/jepSter/2325357.git as address of the Git repository. Then you'll receive no notices. Since you've cite "This automated report was generated with PAReview.sh" in your post, I don't know how you get a different reporting. Are you using the coder module? Is it anyways enough, if the validation on PAReview.sh is OK, since both tools "seem" to use Coder Sniffer?
Implemented now.
I've wrote the strings for t() now across lines.
In the current version I've used drupal's query builder instead of user_load() to improve the performance impact.
Thanks again for your review! Your help is appreciated.
Comment #25
klausiI'm using the latest dev version of Coder sniffer, which might not be updated on the online pareview.sh site yet.
manual review continued:
So those are quite a few issues and the permissions_by_term_views_post_execute() is a blocker right now, since this will blow up any site that uses a View which is completely unrelated to nodes and terms. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #26
jepster_Hi Klausi,
thanks for your review. I've worked again on the module and here's my reply to each of your mentioned issues.
Ok, now it's understood and changed properly.
I've optimized all the SQL-stuff now according to your guidance. Thanks again for your observations.
I've extended permissions_by_term_views_post_execute(); now by a foreach loop which is walking over all elements in $view->result for checking if the view contains nodes. Only then the further code in this function is executed. Since taxonomy terms can be always related to nodes and I don't know a different concrete method to remove the nodes from the view, than in permissions_by_term_views_post_execute();, I would like to keep this function as it is by now. Of course I'm open for a better suggestion, if you provide me more details.
Yes, it's done.
drupal_access_denied(); is now removed and define('PERMISSIONS_BY_TERM_NODE_ACCESS_DENY', 'deny'); used instead.
Doc block is changed now.
Since the table contains only 2 columns, I would like to prefer to saving this module dependency.
Comment #27
jepster_* status update *
Comment #28
jepster_Comment #29
jepster_Comment #30
jepster_Added "PAReview: review bonus"-tag again, after reviewing three more project applications.
Comment #31
polaki_viswanath commentedHi,
After a look I would like to suggest that you must work on the below mentioned points
Install file
1. Need to set one column as primary key for permissions_by_term_user and permissions_by_term_role tables in the schema.
Info file
1. File format must be changed. See how to write info files in drupal 7 in URL: https://www.drupal.org/node/542202
Module file
1. Line lenght must not exceed 80 characters.
2. Remove unwanted new lines and spaces.
3. Remove unused variables.
4. Move forms to inc files so as to make module file clean.
5. Use global keywords at start of functions using it.
6. Use db_select, db_insert instead of db_query all the times.
7. For fetching rows in associative array use fetchAssoc() instead of fetchAll(PDO::FETCH_ASSOC).
8. use join function instead of writing plain join sql queries.
9. Remove too many return statements in your functions.
Thanks
Comment #32
klausiSome corrections:
@polaki_viswanath: that points don't look like application blockers, anything else that you found or should this now be RTBC?
Comment #33
klausimanual review:
So the last point is a blocker right now, you need to know how Drupal security API functions work.
Comment #34
jepster_Hi Klausi,
thanks again for your review.
I've read the linked article and so I've commited as the article described.
The unused code has been deleted.
Done.
I've changed the comment.
The function is returning the correct value now.
I've used pareview.sh after I've commited the changes to fix any code standard problems.
I hope that everything is fine now. If not, please let me know and I'll do the fixes.
Thanks again!
Comment #35
klausimanual review:
But otherwise looks RTBC to me now.
Assigning to stBorchert as he might have time to take a final look at this.
Comment #36
stborchertJust did a quick look into this:
* I really (really!) would prefer creating a patch for Taxonomy Term Permissions to add the missing features (it seems you copied large parts of the module and simply renamed some stuff?). Patches have a stronger impact than a simple question about a feature ...
* User A creates a node associated to Term 1. User B has no access to Term 1 but edits the node. What will happen?
Comment #37
jepster_Hi,
I've tried to communicate with the creators of Taxonomy Term Permissions, but there isn't any chance. So I've invested time to create my own module (since a large amount of time). We had this discussion already in the upper part of the project application issue.
The permissions from "Permissions by Term" can be overwritten by the upper permission layer from drupal.
Thank you for your review.
Comment #38
kscheirerThank you for addressing the concerns about Taxonomy Term Permissions, but how does this module compare to Taxonomy Access Control or TAxonomy Access Control Lite?
"Restricts users from accessing the nodes related to specific taxonomy terms per roles and users." vs "Access control for user roles based on taxonomy categories"
I guess since your module is a fork from an existing one there's probably a good reason, but this info will also help users choose the right module. Can you describe the reason for the fork or why a user should use your module instead?
Comment #39
jepster_It works with views and works with multi language.
There's more description about the fork in the project description.
Comment #40
klausiSo back to RTBC I guess? Could you add the differences to the modules kscheirer mentioned to the project page?
Comment #41
kscheirer@jepSter, you're right, the reason for forking is given on the project page, I just missed it!
Comment #42
mpdonadioI'll do a final review of this tomorrow.
Comment #43
mpdonadioAutomated Review
Git errors:
Review of the 7.x-1.x branch (commit cedd148):
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. You have to get a review bonus to get a review from me.
Manual Review
@klausi #35-1,2 are not addressed, but those are not blocking issues.
Avoid translated breaking strings (eg, hook_help) across lines. Code can be longer that 80 cols, comments shouldn't. See https://www.drupal.org/node/322729
Can permissions_by_term_form_alter() use one of the more specific forms, eg hook_form_FORM_ID_alter()? If so, it should. If not, you should comment why.
(+) Agree that permissions_by_term_views_post_execute() needs some rethinking. I can see this messing up a lot of admin views.
Personally, I prefer to return NODE_ACCESS_IGNORE at the bottom of hook_node_access to make it more obvious to someone reading the code what is going on.
The comment on permissions_by_term_node_access() doesn't match what the code is doing, since no redirection is happening.
Not seeing any blocking issues.
Comment #44
mpdonadioThanks for your contribution, jepSter!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
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.
Thanks to the dedicated reviewer(s) as well.