Hello!
I found, that "node/add/add-product" menu item has "_node_add_access" access callback. It means, that this menu item will be available if user can create nodes of any type, for example, articles (even user can only create non-product nodes).
There is the screenshot: http://i.imgur.com/PglemZw.jpg
If user will click on this menu item, node_add_page page callback will redirect him to page of other content type node or will show him the list of content types - so we need just add an access callback to hide "add-product" menu item from admin menu.
So, I suggest to add an access callback which will be check only product nodes creation access.
Comment | File | Size | Author |
---|---|---|---|
#7 | commerce_backoffice-new-access-callback-2694721-5.patch | 1.42 KB | jantoine |
#4 | new_access_callback-2694721-4.patch | 2.13 KB | Evgeny_Yudkin |
Comments
Comment #2
Evgeny_Yudkin CreditAttribution: Evgeny_Yudkin as a volunteer and at DrupalJedi commentedComment #3
Evgeny_Yudkin CreditAttribution: Evgeny_Yudkin as a volunteer and at DrupalJedi commentedComment #4
Evgeny_Yudkin CreditAttribution: Evgeny_Yudkin as a volunteer and at DrupalJedi commentedAdded codestyle fixes
Comment #5
Evgeny_Yudkin CreditAttribution: Evgeny_Yudkin as a volunteer and at DrupalJedi commentedComment #6
mglamanComment #7
jantoine CreditAttribution: jantoine as a volunteer commentedThe attached patch, for whatever reason, removes some lines and then adds the exact same lines back in. There are also Drupal coding issues and changes unrelated to the fix. Attached is a cleaned up patch that fixes these issues.
Since this patch has absolutely no functional changes and the patch works, I'm marking this as RTBC.
Comment #8
mglamanCouldn't we just invoke
_node_add_access
here?Also, thanks for patch without code styling fixes. Makes it much easier to review.
Comment #9
fox mulder CreditAttribution: fox mulder commented#7 resolves the problem for me
Comment #10
jantoine CreditAttribution: jantoine as a volunteer commented@mglaman,
No, we can't just invoke _node_add_access because it does not take a bundle parameter and will return TRUE if the user has access to adding, say, an 'article' bundle. Invoking _node_add_access here produce the same result as using it as the 'access callback' parameter, displaying the top menu item when a user doesn't have access to add a product display type.
Comment #11
mglamanCool. We don't have tests enabled here (wink wink, hint hint for anyone wanting to step up.) So I'm running a test on CK2's behat test suite with this patch: https://travis-ci.org/mglaman/commerce_kickstart/builds/138525887.
If that's green I'll commit.
Thanks everyone!
Comment #12
Evgeny_Yudkin CreditAttribution: Evgeny_Yudkin as a volunteer and at DrupalJedi commented@mglaman,
As I see, build is green (excepting php7 and hhvm jobs).
Comment #14
mglamanFixed! Sorry, I've been tied up with client work and 2.x :) Meant to commit earlier.
Comment #15
Evgeny_Yudkin CreditAttribution: Evgeny_Yudkin as a volunteer and at DrupalJedi commentedThanks!