[eluser]Future Webs[/eluser]
been a while since i posted anything here but having a brain freeze so thought id use the collective brain for a kick start.
I have two tables in my database that I use to manage permissions for users. For example, can this user access the forums, can they contact other users, can they change their username etc.
Instead of setting up a table and giving every user a row in the permissions table i opted for a small table of permissions and a small table that links permissions to users. When i query the table to see if a user has permission to do something if nothing is returned i know they dont have permission
My permissions table has fields for
- perm_id (autoinc)
- perm_title
- perm_desc
My user_groups (mtm) table looks like
- id (autoinc)
- user_id (links to my users id)
- perm_id (links to the permissions perm_id)
Now, onto building the form based on the possible permissions available
My thinking was that I grab an array of all possible permissions and then loop checkboxes or drop menus set to (y/n) (on/off) etc inside my form fields.
I can also create another array with the users actual permissions to tell me if each permission in the loop is active or disabled and then match them up to the form.
when the form is submitted i can then unpick the post data, clear the previous users permissions and then save the new active permissions.
Im coming unstuck in how i build the form though. Assigning the description and the human readable title is easy enough but how would i set the actual field names.
You might say im going about this the wrong way and making life hard for myself and you might have a very simple solution. I guess its a bit of help with the concept and then also with implementing the field names im after.
either way im happy to hear any suggestions