Hi !
while setting up Nodereview in our site, we discovered that the "Reviews" tab was showing for every content type (instead of only those configured in admin/config/nodereview). As we started searching for the cause of this behaviour we found out that the path node/%/reviews in hook_menu is also used in the view review_list (we don't know if this clash causes other problems but it didn't look good). The problem is that the function used to filter permissions for the Reviews tab ( read_reviews_access($arg)
) is called from the hook's access callback, but not from the view access validator (so it's never called and the tab is shown everywhere).
Since we are already using the module views_php in our site, we fixed it by adding php code in the access settings of the view. We used
return read_reviews_access(arg(1));
. We can confirm this works as expected, but as a solution, it would add another module dependency to nodereview.
Maybe a solution that doesn't involve views_php would be to use different paths for the hook and the view, and/or just embedding the view from the hook's callback (once the access function has been called).
Comments
Comment #1
gargsuchi CreditAttribution: gargsuchi commentedThis problem exists in the 6.x version as well.
Comment #2
agupta CreditAttribution: agupta commentedThe view should be disabled by default. Attaching patch.
Comment #3
agupta CreditAttribution: agupta commentedComment #4
h3rj4n CreditAttribution: h3rj4n commentedI've fixed this by creating a custom access plugin for the view. The plugin is provided by the module and default selected when you apply the patch. The tab wont be showing up anymore if the review functionality isn't selected for that content type.
Comment #5
jay.lee.bio CreditAttribution: jay.lee.bio commented#4 worked! :D
Comment #6
h3rj4n CreditAttribution: h3rj4n commentedIt doesn't work quite yet. The review tab wasn't visible for content types that should have them. Changed this in the following patch.
Problem was in the callback from the views plugin. It contained the wrong function name. After changing this the value the view provides is wrong. Changed it to NULL and get the value from the URL in the access callback.
Comment #7
jay.lee.bio CreditAttribution: jay.lee.bio commentedYeah sorry, #4 made the "Reviews" tab disappear from everywhere. #5 works perfectly though, and this time I double-checked! :D
Comment #8
h3rj4n CreditAttribution: h3rj4n commentedI wasn't able to apply this patch on the current HEAD so I recreated it.
Comment #9
h3rj4n CreditAttribution: h3rj4n commentedForgot a file in the patch.
Comment #10
h3rj4n CreditAttribution: h3rj4n commentedFound some code in the contextual filter of the view that's not needed anymore. This is handled by the access views plugin created for this module.
Somebody should check this again see that I'm right ;)
Comment #11
h3rj4n CreditAttribution: h3rj4n commentedIgnore comment #10, it's wrong!
Patch #9 is the way to go!
Comment #12
yaworsk CreditAttribution: yaworsk commentedI was looking at the patch and I'm not sure we need it... it seems like the easiest way to do this is the validate the argument by checking the content type. If the content types validate to those which have node reviews, i think everything works.
If that's the case, we just need to change the default view and i would think we could use some logic to check which content types are enabled for reviews and pass that in.