I'm creating a menu system in PHP and MySQL. I will have several different menus and each menu will have a set of menu items connected to it.
On the site, I also have different user permissions, some users can see all menu items and some items are hidden from some users. I'm curious on how I could handle the permissions in a clean way that will allow for more types of users in the future to be easily added.
What I have thus far is something like this:
-------------------
|Menus
-------------------
|id| |display name|
-------------------
----------------------------------------------------------
|Menu items
----------------------------------------------------------
|id| |menu_id| |label| |link| |parent| |sort| |permission|
----------------------------------------------------------
I'm thinking that the permission
column could either be a comma separated string that I can match against the current user's permission id. It could also be a reference to some other table that defines all possible combinations of the currently existing permissions.
One solution could also be to simply store multiple menu items where the only difference is the permission although this would lead to duplicate storage and perhaps a pain to administer.
I'd love to hear some thought on how to structure this and what could be considered clean, dynamic and crappy.
Thanks.