Hide admin menu if no admin option is available

Posted by Jorge on Programmers See other posts from Programmers or by Jorge
Published on 2014-05-08T14:23:19Z Indexed on 2014/06/07 15:39 UTC
Read the original article Hit count: 369

Filed under:
|
|

If you have a menu "Admin tasks" and different admin tasks (like 10) that you could separately assign to each user, but there are users who don't have any admin tasks, how would you deal with "Hiding admin menu" for those users?

I was thinking of 3 ways:

1) Javascript, check if Admin menu is empty and then hide it.

2) Check for all permissions in Admin menu, with a counter, and show it if counter > 0. And then also re-check the permissions for each item to show.

3) Save all permissions in associative array. Test all and assign ' true' to granted items. When building the menu, have a function that tests if there is at least one permission granted. I wouldn't need to re-check permissions against DB, just against the array for each item.

Is there any better way?

© Programmers or respective owner

Related posts about security

Related posts about html