How to generate a user role grid
- by Svish
I have the following tables:
users (id, username, ... )
roles (id, name)
roles_users (user_id, role_id)
I am wondering how I can create a nice sort of user-role-grid from that which an admin can use to administer roles to users in a clear way. What I would like is basically a table full of checkboxes sort of like this:
Login Editor Admin
Alice ¦ ¦ ¦
Bob ¦ ? ?
Carol ¦ ¦ ?
[Apply]
Generating the table isn't too much of a deal, but I am very unsure how to handle it when it comes to how to name all the checkboxes and especially how to read and update the database in a not too clumsy way. Does anyone have any good advice or pointers on how to do this in a mostly clean way?
I'm using the Kohana 3 framework, if there is anything there that can make this even easier, but I of course welcome any answer.