title: How to structure multiple users with multiple permission levels?
body: <p>The site I am working with has a somewhat convoluted way with dealing with users and permissions. </p>
  
  <p>These are the user types:</p>
  
  <ul>
  <li>User</li>
  <li>Facility Approver</li>
  <li>Facility Admin</li>
  <li>Corporate Approver</li>
  <li>Corporate Admin</li>
  </ul>
  
  <p>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:</p>
  
  <pre><code>user_id     facility_id     userlevel
  joebob      ABCInc          Facility Admin
  </code></pre>
  
  <p>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?</p>
  
  <p>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? </p>
  
  <p>I was seeing if like <a href="https://stackoverflow.com/questions/1451/what-is-the-best-way-to-handle-multiple-permission-types/1477#1477">this</a> 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.</p>
  
  <p>Also user levels are directly linked to users in the User Table, but those server different purposes.</p>
  
  <p>Is there a completely better way to structure all of this?</p>