Closed (fixed)
Project:
Menu Per Role
Version:
7.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
23 Nov 2010 at 20:47 UTC
Updated:
23 Apr 2012 at 03:11 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jarush commentedAny update of Menu_Per_Role for Drupal 7??
I'm using Drupal 7 now, and also want to use this module...
Hope it will come to Drupal 7 soon...
Comment #2
AlexisWilke commentedWhoever wants to take over the D7 version, let me know. 8-)
I don't have the time and we're not yet using D7.
Thank you.
Alexis Wilke
Comment #3
ken hawkins commentedChanging title to reflect need of coder. Also setting status to major as I think we'll soon see an influx of those looking for a D7 version.
I'd be happy to help debug, test, etc, but my Drupal code skills just aren't there to port something like this.
Comment #4
jarush commentedGreat!
I'd be happy to help debug & test also.
Comment #5
AdrianC-1 commentedSubscribing
Comment #6
bigdave commentedsubscribing
Comment #7
thekevinday commentedI really do not want to stretch myself thin, so I am trying to avoid picking up another project at them moment.
That said, I might be able to provide the initial coding and then leave the rest to the admins here.
Before I do that, however, you might want to also look at and consider this module: http://drupal.org/project/chain_menu_access.
It may/may not be a good to use the API that module provides for the drupal 7 version of this module.
Comment #8
AlexisWilke commentedthekevinday,
I can create the D7 version once you have a tarball ready.
Thank you.
Alexis Wilke
Comment #9
Anonymous (not verified) commentedsubscribing for D7
Comment #10
sapox commentedSubscribing.
Could be an option to try to port it to D7 using the coder module?
Comment #11
AlexisWilke commentedCoder module?! Would that really help in changing all the code? I think it only checks the validity of your code by trying to see whether there's bugs in there.
Comment #12
sapox commentedSure, it'll do half of the job. Because it will help to port al the functions API's that are used from version 6 to 7, database calls, etc. Coder module will not do it by itself, but it'll show line by line where is something that must be changed.
Of course the other half can't be done this way, which includes the actual integration of the module with the rest of drupal. This part requires, more close knowledge of how this module works and how must be integrated with the new D7.
Comment #13
AlexisWilke commentedMenu per Role is a rather small module, so it should not be that bad.
From what I've seen of D7, the changes to the roles are non-existent.
However, the menu handling is completely transformed. So there could be a bit of work, not just API call because we had hooks, etc. that were D6 specific and it is not unlikely that in D7 you want to use a different approach. So that will take a little bit of thinking for the core of Menu per Role. The rest (i.e. admin forms) would certainly be easy to transform just with coder.
Thank you.
Alexis
Comment #14
kvanlombeek commentedCurious as well to test the updated D7 module
Comment #15
thekevinday commentedSorry for the late submit, I am behind.
Here is a working D7 version, but much testing and review is needed.
There is only 1 outstanding problem that may/maynot be a core bug:
in includes/menu.inc, around line #3025 inside menu_link_save():
In my case, that if case is failing to succeed even when
(array_intersect_assoc($item, $existing_item)) != $existing_itemis TRUE.This could be a bug with my PHP version.
My work-around is adding:
and replacing:
with
The problem seems to cause the hook_menu_link_update() to not fire and therefore updating a menu link will not do anything.
Please let me know if anyone comes across this issue and what PHP version they are using.
I am using PHP 5.3.2.
Comment #16
AlexisWilke commentedHi thekevinday,
Okay, I tested and #15 package works for me.
Note that I made some changes in the D6 version so the users can decide whether UID=1 and menu administrators can see or not the hidden menus. I thought later I could have used another permission and a per user flag instead of just a couple flags as it is now. But it serves the purpose for this simple module. It most certainly will be asked for you to do the same in D7.
One thing that is definitively missing is an upgrade route. You must reformat the old D6 data from my explode() to your serialize(). I used explode() because it is a lot faster, although I don't mind it being done either way, yet this means you need an upgrade path...
Thank you.
Alexis Wilke
Comment #17
thekevinday commentedWell then lets keep life simple and stick with your higher-performance "explode" approach.
I moved the explode/implode operations into two functions so that if this were to be changed in the future, there is only one spot to change.
For those of you who tested #15, it is best to uninstall that version and re-install this version of the proposed D7 menu_per_role.
This one should not need an upgrade path.
Comment #18
ronino commentedIs there a D7 dev version, so installing and testing is much easier? So far I only see different separate packages. I'd very much like to use this module in D7...
Comment #19
AlexisWilke commentedRonino,
That's the way it is generally done when we move from one major version to another, unless the author does the move him/herself.
I suggest you test the version in #17 and report your results (i.e. working/not working)
Thank you.
Alexis
Comment #20
SMonsen commentedSubscribing
Comment #21
simg commentedseems to work fine for me (thanks !!!)
only issue that I've found is that the admin user (ie uid = 1) gets to see all menu items regardless of settings - this may be by design?
Comment #22
AlexisWilke commentedsimg,
Yes. uid = 1 "problem" is by design. Although now there is a flag in the settings in D6.
Thank you for the report.
Alexis Wilke
Comment #23
clashar commented+1
Comment #24
Joe90 commentedThanks for the 7.x version from #17. It worked for me, but I did have problems changing the settings. Eventually had to reset "Blogs" which was the menu item I was working on, and even then the settings didn't go away but was then allowed to save changes. Possibly a cache issue? Also note when un-gzipping, edit out the last _ after the tar before doing so!
Comment #25
AlexisWilke commentedJoe90,
When you say "settings", I suppose you mean the flags appearing in the Menu fieldset?
There was a problem like that in D6 that I fixed recently and it is not unlikely that the D7 presented here used the previous version of Menu per role, so we'd have to port the fixes. If my assumption is correct, it will not save anything when you create a new node. After that, editing works just fine.
Thank you.
Alexis
Comment #26
Joe90 commentedOK thanks Alexis.
Should I be able to type in a url that is covered by menu per role and see it without being logged in, as I can.
Example:
Blogs is "protected" for the role "Staff" to only view. So "Blogs" does not show in the navigation menu when not logged in but shows when logged in. Good :). However if I type in the url of a blog post when not logged (http://example.com/node/22) in I can see it. Not good :(. Is this by design or have I missed something?
Comment #27
AlexisWilke commentedJoe90,
You missed something. We clearly say that the destination is not in any way affected. In other words it doesn't get protected just because you hide the menu. To do so, you want to use another module that protects nodes. There are many such modules to choose from. tac_lite is a bit complicated, it protects using taxonomy terms but you can use rules to automatically assign terms to your nodes.
Anyway, a list of such is presented in the Menu per Role project page.
http://drupal.org/project/menu_per_role
Thank you.
Alexis Wilke
Comment #28
Joe90 commentedThanks Alexis, I kind of figured this out, after I had walked away and thought about it ;) Have had some success with taxonomy elsewhere on my site so will give it a go, unless I decide to give Views a crack :)
Comment #29
simg commentedI've noticed the same problem as joe90 on #24.
not sure about it being a new node (this was a link to a forum) but the role permissions flags weren't being saved. clicking reset on the forum link made it start working fine.
Comment #30
simg commentedalso just found with a menu link created from node/add that the roles weren't saving.
there is no "reset" link, but disabling then re-enabling the link made it work correctly.
Comment #31
AlexisWilke commentedsimg,
There was a problem in D6 saving a new menu item. It was fixed in D6, but it could be that D7 was created before D6 and the fix did not make it in D7. Core is expected to call module hooks to ensure such things don't happen... If that's the case, then we'll need to emit a patch for Core, unfortunately.
Thank you.
Alexis
Comment #32
simg commentedAlexis,
No, thank *you* :)
ps: I would also say I think the "by design" issue I mentioned in #21 is a design bug. I can (almost) see an argument for having uid =1 see all menu items but the code currently allows anyone with "Administer menu per role" permission to see all menu items.
I could be missing something, but most times, I want to hide menu items from a role (or an administrator) for their "convenience" not really for "security" purposes.
Would happily submit a patch if would be included into the module :)?
Cheers
Simon.
Comment #33
AlexisWilke commentedThere is a "fix" in D6, a new administrative page which let you select whether UID = 1 and administrators should see the menus or not (there are 2 flags)
I guess I'd be more interested in having a fix for the 2 save problems.
Comment #34
simg commentedHey, thanks Alexis will wait for the extra D6 flag to make it into D7.
Would offer to look at the "saves" issue but currently flat out on two D7 projects. Might come back to this issue in a couple of weeks if it hasn't already been solved.
Comment #35
thekevinday commentedD7 does not need to care about whether or not UID = 1 has the appropriate roles.
UID = 1 in D7 bypasses all permissions, so this is not a problem. (or is something that cannot be changed??)
All other administrators would have to be in a role that enables the "Administer menu per role" permissions.
Comment #36
AlexisWilke commentedthekevinday,
UID = 1 sees everything in D6 too... except the Log In menu item once logged in. So to be consistent, it makes sense to hide some other menus to UID = 1 too.
And for the administrators, unless we put yet another permission, it makes sense to eventually hide the menus from them otherwise they cannot directly see the result and they are the only ones who can modify those menu per role flags.
Thank you.
Alexis
Comment #37
geert commentedHello,
The version #17 did not work for me
----------------------------------------------------
* Notice: Undefined index: log in update_authorize_install_batch_finished() (line 236 of C:\xampp\htdocs\drupal7\modules\update\update.authorize.inc).
* Warning: Invalid argument supplied for foreach() in update_authorize_install_batch_finished() (line 236 of C:\xampp\htdocs\drupal7\modules\update\update.authorize.inc).
* Notice: Undefined index: log in update_authorize_install_batch_finished() (line 277 of C:\xampp\htdocs\drupal7\modules\update\update.authorize.inc).
* Notice: Undefined index: tasks in update_authorize_install_batch_finished() (line 278 of C:\xampp\htdocs\drupal7\modules\update\update.authorize.inc).
* Installation failed! See the log below for more information.
---------------------------------------------------
I removed all from the system and tried #15. So far, this works ok for me and does what I expect it to do: hide the menu item, role based.
Geert
Comment #38
joelstein commentedThe module attached in #17 worked great for me. Note: I was not upgrading... just installing fresh. Thanks!
Comment #39
shadowdknight commentedHi,
Im using version on #17,
It seems I have problem updating the menu for selected roles,
after changing the role the changes is not saved.
Thanks
Comment #40
AlexisWilke commentedshadowhitman,
Is that when creating a new page, or even when editing a page?
Thank you.
Alexis
Comment #41
shadowdknight commentedHi,
Excuse me for lack of info, I had a site with 3 roles : editor , manager and admin:
1.I created Menu called "Testing" :
Under "Hide menu item for selected roles", I checked : Anonymous, Editor and Manager
Save
2.I wanted to change my setting and allow Manager to access that menu:
I unchecked Manager from the list of "Hide menu item for selected roles"
Save
But when I reload, the menu is still invisible for Manager role,
and when I went back to check the settings still the same : Manager is still checked on the list of of "Hide menu item for selected roles"
Comment #42
AlexisWilke commentedAh! So the flags did stick, it's the functionality that isn't working...
As a manager, can you go to that page? If not, then the Core system is hiding that menu, not Menu per Role.
Thank you.
Alexis
Comment #43
devtherock commentedHi All
I download and install #17 but I was unable to alter roles once selected, so I made changes on menu_per_role.module file call "menu_per_role_menu_link_update" function inside "menu_per_role_menu_link_alter" now it is saving multiple roles. Attached the changed code. I hope I solve it in a right way, comments and feedback are welcomed.
Thanks
Regards
Dev/Kuldev
Comment #44
likewhoa commentedSubscribing
Comment #45
nfriend commented#43 works like a charm for me. New D7 install. So glad to see this here as I got very used to it in D6! Thanks!
Neil
Comment #46
hermes14 commentedThis is my scenario:
User menu, that contains User account and Logout items. I'm adding a 'Reserved area' item, that should only show up whenever a user is not logged in (i.e. anonymous role), but when I log in as administrator it actually shows always up. This doesn't happen with other roles I created, i.e. it correctly hides the item whenever I log in. I tried to deny access to logged user and administrator, besides allowing only to anonymous but it's always there...
Am I missing something?
Comment #47
nfriend commented@hermes14
If by Administrator you mean User 1, I believe this Admin gets to see the whole show - that's a perk for being admin! Typically that's only going to be a developer and the like. Create another role with most of the permissions you want but is not an admin and use that to eliminate that menu from showing.
Neil
Comment #48
hermes14 commentedThat's what I meant, but I find it a bit confusing to have administrator listed in "Hide menu item from selected roles" and cannot actually hide the selected item.
Comment #49
modoq commentedsubscribing
Comment #50
underwearninja commentedI installed along side version 7.x-2.x-dev of Simple Access (http://drupal.org/project/simple_access) hoping I could enable menus even though Simple Access hides the menus. It didn't work as I expected.
It does work as advertised though, it just doesn't play with SA as I would have desired. If someone knows of a way to protect the content, yet still show it in a menu, that'd be great!
Comment #51
AlexisWilke commentedunderwearninja,
Yes, you have to edit the menu link and enter a full path that starts with http://... then the menu system treats it as an external link and does not hide it if the destination is not reachable.
Obviously, if someone then goes to that page, he/she will get an access denied error (at least, that's what's expected by default.)
Thank you.
Alexis
Comment #52
bkudrle commentedCode from #43 worked well for me also. Am only using it to allow access for roles, not deny access to roles. Thanks so much for the good work.
Comment #53
laroccadahouse commentedfresh install of d7 + file from #43. created a test menu. when i go to edit the menu, there is no fieldset for setting what roles can access.
Comment #54
AlexisWilke commentedlaroccadahouse,
Are you testing as UID 1? If not, you may need to check out permissions...
Thank you.
Alexis
Comment #55
laroccadahouse commentedyes i was logged in as UID1. i eventually gave up and installed this module: http://drupal.org/project/menu_admin_per_menu
Comment #56
AlexisWilke commentedlaroccadahouse,
That looks like a cool module and much better adapted to what you were trying to do.
Thank you.
Alexis
Comment #57
OldAccount commented#43 is working for me, thank you!
Comment #58
AlexisWilke commentedI now created a new version 7.x-1.x-dev.
Note that I'm not supporting it, so if you have problems, you may have to find someone to fix it.
Thank you.
Alexis Wilke
See: http://drupal.org/node/1189878
Comment #60
heymjo commentedworks like a charm on D7.8, many thanks !
Comment #61
benjamin69 commentedHello,
Thank you for this module he works very well !
it really does what i want for my sidemenu.
Comment #62
AlexisWilke commentedYou shouldn't change post settings on closed issues unless you are re-opening it.
Thank you.
Alexis