views:

46

answers:

1

Hi folks,

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 which 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?

+1  A: 

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.

Andrew Heath
Thanks Andrew, that's more or less what I've been playing with - building an multi-dimensional array with each page as a parent node and all page objects as children - if there are no children, then don't show the page. Is it common practice to do this? Do you know of any projects/frameworks that incorporate this?
boatingcow
Hi Cow. Sorry but I'm not qualified to answer either of your two questions, as PHP is my first language and I've only been coding in it for ~7 months. Good luck with your menu though!
Andrew Heath