I want to start by saying I have searched through the issues for workbench access, and I have found a lot of issues with similar topics, but it seems like the functionality that I am looking for has been committed (at least in the dev version), the problem is, I can't get the functionality working.
So just as a preface, let me explain the setup that I have:
I have 3 users: admin, editor, coach.
I have the main menu with 3 top level links, Home, About, and Athletics.
I have workbench access (and the other workbench modules set up as well) set up with the main menu for section control.
The sections I have set up are: all of main menu, home, about, and athletics.
I have tried using both roles and assigning editors by hand, but I assign sections in this pattern:
admin -> all of main menu
editor -> all of main menu
coach -> athletics
I have also turned on the check box that says: "Limit available menu items based on Workbench Access."
Basically this is what I want to happen: When the coach goes to his workbench and attempts to make a page, lets say a "basic page" with the title "soccer", I want him to be able to have the access to put it into the main menu, but only under athletics (which is what I believe that check box I mentioned earlier, and the issues that have had committed patches are referring to. As of right now, If I give "coach" the "Administer menus and menu items" permission under the drupal core permissions, when "coach" goes to make a new page called soccer, he can click "provide a menu link" and then is given the option to put it anywhere in the menu, not just under athletics When I turn off the Administer Menus permission, the provide a menu link check box disappears when creating content, and the content does not go under any menu.
I have tried pretty much everything I can think of to get this working, I have created a new menu called "workbench main" and created new top level links there and re-configured workbench_access to use the "workbench main" menu instead of main menu, and I assigned section permissions accordingly (as mentioned earlier, I have tried setting editors by hand and using roles (I have 3 editor roles I use, admin, editor, and athletics editor, for accounts admin, editor, and coach respectively) and no difference was made). When creating new content as "coach", it does use the correct section (he can only choose athletics or any child of it as the section), but he is still able to choose athletics as the section but place it under about in the menu. Or, even worse, directly under the "main menu" so "soccer" becomes a top level link.
As I said, I believe that workbench_access already contains the functionality I am looking for, but I must be doing something wrong. If anyone can help me out with this, I would really appreciate it and like to thank you in advance. If you need me to provide you with any more details, just post a reply and I will provide them ASAP.
Thanks,
Gode
P.S. Attached is a picture demonstrating what is happening. I edited the html (with chromes firebug equivalent) to turn the select box into regular text (linux mint wont let me print screen with a drop down open). As you can see, I am logged in as coach and the only section I have access to is "athletics", yet I can put the "soccer" page I am creating anywhere I want in the menu.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | interdiff.txt | 2 KB | seantwalsh |
| #23 | workbench_access-1996418-22.patch | 2.78 KB | seantwalsh |
| #13 | workbench_access-interdiff-1996418-12-13.patch | 1.29 KB | kevinchampion |
| #13 | workbench_access-1996418-13.patch | 2.78 KB | kevinchampion |
| #12 | limit-menu-items-1996418-ll.patch | 2.74 KB | iLLin |
Comments
Comment #1
agentrickardWork on this should be tested and fixed in testWorkbenchAccessMenu().
Comment #2
Gode.Agarunov commentedI actually just took care of this issue, after 4 or 5 days of messing around with it, it turns out I'm just dumb.
On the workbench access settings page, if "Require a Workbench Access form element" is checked, than the menu items will not be automatically limited to match the section access that the user.
If you uncheck it, then when an editor goes to create a new piece of content, rather than giving them a select list of what section they want the content under, it automatically turns on "create a menu link for this item" and trims the parent list to the sections that the user has access to and their children. Whereas if it is not checked, the select form for section placement comes up, and the create a menu link for this item is not turned on by default, and even when it is checked and the parent list appears, the items are not trimmed.
So now that that is taken care of, I have a feature request of you, agentrickard. In order to allow editors to place content into the menu (and therefore creating a section for that content), you have to provide them the "Administer menus and menu items" permission. Giving them that permission allows them to reorder the whole menu. Because of that, not only can the editor reorder a piece of content that he created out of his section and lose access to it, but he can reorder another editors section into his own, edit the content, and then reorder it back into the other editors section. This kind of defeats the purpose of limiting menu items, and my coworker and I are currently looking for a method to manage this. If that permission is not given and the editor goes to make a new piece of content, the "create a menu link for this item" checkbox does not appear, and after creating the content it becomes "unassigned" as far as sections go.
A possible fix would be: rather than trimming the parent select list, have the section select list show up as before, except when a section is selected, it automatically puts that content under that section of the menu.
Alternatively, workbench_access would have to have it's own menu permissions and I guess it's own menu select section.
Anyways,
I hope this helps somebody out, this was a HUGE pain to figure out.
P.S. Thank you AgentRickard for all your hard work on this module, it really is a great module that is going to do wonders for the workflow of our future clients.
Comment #3
agentrickardSure. Sorry for the delay, I've been out of office for 2 weeks.
Comment #4
Gode.Agarunov commentedSo I just wanted to add a couple things I have learned experimenting the past few days:
First, if you are using a menu for access control, then unfortunately you have to give the editors access to the menu. That results in an editor who is able to pull a piece of content out of it's place in the menu and place it in his section, at which point he can edit it and then reorder the menu to place it back in it's original spot. To get around this we can use a module like path access to disallow the editor from reordering the while menu, and then using a module like submenu reorder to only allow the editor to reorder the sections he has access to.
Second, and I believe also worth mentioning is the module submenu tree. In the past, we would have individual menus for each subsection of the website, and then use a custom script to combine those menus into the main menu. Now, we can use just one menu with different children being different access sections, and then using a submenu tree block to display the sub menu. Ie the end user clicks about in the main menu. They get taken to the about page which has a left sidebar with a menu containing all of about's children. You just put one submenu tree block into the left sidebar and without individual configurations it uses the active trail to display the sub menu.
Thanks again for all your work guys, great module
Comment #5
agentrickardBTW, the reason we don't do this now is that it's actually pretty hard to do correctly.
Comment #6
sylvain lecoy commentedYes it is hard, for my part I resolved partially the needing like this. I didn't thicked the "Limit Menu Items During Content Creation" box as some of my section are purely lists of teaser and then it would have been impossible to create a menu item for each content created within this section.
However, for the rest of the website, I am using this snipper on node_form_alter:
Then in the hook_node_insert:
It has the effect creating a workbench section based on the new menu item created, and affect the author as the newly created section. This way the author can create sub-sections and so on without granting him the full menu admin access.
To solve completely the problem, I think you gave some directions, which is to limit the menu editing on sub-sections only, I'll have a check at submenu reorder.
Comment #7
Adysone commentedHi everyone,
I found a "solution". Configure Workbench access and check "Limit available menu items based on Workbench Access.".
Then, add a module with 1 hook. It's a copy-paste from the menu module which add the menu tab in the node editing form with one change : the "access". I putted '#access' => user_access('access content'), but you can add a hook_permission and define your custom permission.
Sorry for my English!
Thanks,
Comment #8
agentrickardAnyone care to work this into a proper patch?
Comment #9
iLLin commentedFYI, if your module weight is after workbench access then it won't filter the menu items and basically overwrite the work/filtering it did. I had to add
To the bottom of that code snippet above. Or you will need to adjust your weight in the database. I think the workbench_access module should add the above so it can be handled correctly and then it would only be processed once.
Comment #10
iLLin commentedScratch comment #7 and my last comment. All that is unnecessary.
In workbench_access.module line 1417 it checks for a custom form. I am assuming this is the Section required field a user must select to place their content into. Correct?
Then in the else, you have the workbench_access_default_form_element() function that actually adjusts the menu accordingly. Why is it setup this way?
I hacked around and did this to test:
Then in the file menu.workbench_access.inc is did this start of line 218
By setting the menu access to TRUE, it will have the menu show up and be filtered accordingly. This also allows you to not give administer rights to the role for menus.
I'm still playing around with stuff so just want to put out what I have done so we can figure out why we can't include the required form element and still have the menu filtered and displayed.
Comment #11
iLLin commentedHere is an initial patch to address this issue. I ran into a problem when you are using the required field form and the limit the menu setting and applied two fixes for that. Check it out and let me know if there is a better way to do it.
Hmm, how do I add patches now? Update the issue?
Comment #12
iLLin commentedPatch added.
Comment #13
kevinchampion commentedI can't comment on whether or not this is the "right" approach, but I did test and found this approach to work. That said, I think this should be a permission since it's an issue of granting access and you may want to have different access for different roles.
This patch makes the default variable consistent so there's not a false positive on install and fixes a typo in the setting description.
Comment #14
stewart.adam commentedThis patch breaks configuration detection for me when using the menu access scheme with "Require a workbench access form element" enabled; every node under workbench access' control displays a warning saying it is not configured due to
workbench_access_default_form_element()being called all the time instead of only in the else clause.Comment #15
mstrelan commentedFWIW this seems to be resolved by enabling Node menu permissions and assigning the following permissions.
Workbench Access will still limit the available menu items to those the user can publish to. No need to enable "Administer menus and menu items"
It might still be preferable to get the patch committed instead.
Comment #16
mstrelan commentedPatches in #12 and #13, and a work around in #15, so setting to needs review.
Comment #20
ashleywilson commentedAnyone still on this? Need this working for any meaningful access provisioning during page creation.
Comment #21
seantwalsh@ashleywilson I'm working on this today for a client. Hope to post a working patch shortly.
Comment #22
gooddesignusa commentedI actually got this working with some custom code using a menu reference field on the taxonomy terms. It was a lot easier than I thought.
Ideally it would be an option inside the workbench area but this works for my needs.
Basically using a form alter for the node edit form, I load up the taxonomy terms used for access control on that node and grab the menu reference value from the field on the taxonomy term.
I than loop through the menu options and disable the ones they do not have access to.
Drupal didn't have the ability to add disabled to the select dropdown options so I had to use a custom theme function. I also had to write some validation to make sure the editor couldn't re-enable the option through web inspector before saving the node.
When I have some time I can try to post an example.
Comment #23
seantwalshThis updated patch applies on 7.x-1.x-dev. Note for this to work correctly you'll need to uncheck "Require a Workbench Access form element". Ideally this could be fixed as the code noted below seems to be the culprit. Simply removing that code just breaks the ability to assign a section, although the menu filtering still works. Hopefully someone can offer a suggestion and we can roll another patch fixing it for good.
Comment #25
seantwalshTest fails are coming from the addition from earlier patches. Going to work on this a bit more to see if that is really needed or should be handled in a different manner.
Comment #26
madanzes commentedAnyone working on this. Same issue happens in my side..