The site I am working with has a somewhat convoluted way with dealing with users and permissions.
These are the user types:
- User
- Facility Approver
- Facility Admin
- Corporate Approver
- Corporate Admin
Now there are also facilities, and that is where these permission levels come into play. Facilities are linked to users and user levels in a table like such:
user_id facility_id userlevel
joebob ABCInc Facility Admin
Pretty simple so far, but now what I want is be able to allow one user level to set restrictions on another user level for a certain facility. For example, I'm the Facility Admin and I want to only allow Users to submit certain forms. How would I store this?
I was thinking a new table that links facility_id, userlevel and permissionlevel. But what exactly would permissionlevel be? An int? Or would I add columns to the table like canOrderThings or canSearchForStuff?
I was seeing if like this would work, but it seems like it would get a tad messy and hard to keep track if you have a large number of permissions. How would you add permission levels without throwing everything out of wack? Or even setting permission levels would be a bit challenging I think.
Also user levels are directly linked to users in the User Table, but those server different purposes.
Is there a completely better way to structure all of this?