开发者

How to assemble an admin menu dynamically?

开发者 https://www.devze.com 2023-01-06 23:39 出处:网络
I\'m trying to work out the best way to assemble the navigation menu of my admin application dynamically, based on the result of going through each of the objects on each of the pages, such that only

I'm trying to work out the best way to assemble the navigation menu of my admin application dynamically, based on the result of going through each of the objects on each of the pages, such that only pages with objects that are available to the user are displayed in the menu!

As a simple example, say I have two user types; SECRETARY and MANAGER. I have a simple admin page to manage staff with two fields that I can update; "address" and "date of birth". Normally, both fields have an access level whic开发者_StackOverflowh allows SECRETARY to do our normal CRUD operations. Our administrator comes along one day and decides that "date of birth" needs MANAGER level access - it's straight-forward enough to hide that field on the page or make it read-only. Now, all of a sudden, the administrator decides that the "address" field needs MANAGER level access too. Given there are no fields on this page available to the SECRETARY user now, how does my menu know to display it or not (without creating a separate rule for the menu option)?

Things like ACL and Navigation in Zend only seem to go as far as making a menu option an access control object. This: http://www.tonymarston.net/php-mysql/role-based-access-control.html#menu-system seems to do what I'm asking, but I can't find any demos or code chunks which talk about this particular topic.

The next question is, if I have to go as far as maintaining a list of all the objects on a page in the db, why not include the HTML in the db too, and have the application dynamically assemble the page instead of using a View + template? (could be cached of course)

Any suggestions?


Speaking in rough and general terms, after checking permissions for individual page objects, I could count how many objects are valid. If that count = 0, then I would omit the page.

No code for you, but that's the theoretical basis of the approach I'd take.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号