• 0

Best method to address multiple menu sections with per-user permission


Question

I'm in the middle of implementing permissions on a multi-level tabbed/dropdown menu navigation setup. Is there a better method to implementing permissions compared to wrapping each menu item in an if statement?

User permissions are stored in a table and pulled in to an array, there are 10 menu items and each menu item has numerous sub-menu items. I have, for example, 20 different columns in the database that are boolean flags to indicate access to a particular menu item.

    Home
    Admin -----> Users
                 Notices
                 Setup
    Projects --> Active Projects
                 Inactive Projects
                 Updates
    Reports
    Preferences
    Research --> Open Tickets
                 Closed Tickets
                 Unassigned

Ideally, I want to have a flag for each menu item that determines if the individual account has access to that section. The only method to pull this off I can come up with is wrapping each menu item in an if condition, but this right off the bat sounds like it will get rather unmanageable quickly.

I'm not concerned about performance, since the generated menu is cached on creation (and the cached version referenced each time unless the user permissions are detected to have changed from the cached version - then a new menu is generated).

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

only non-conditional method of doing it that i could think of is to keep a list of menu items for each permission level, and then compile the complete menu depending on which permission the user is assigned.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.