Hi
I have a wee bit of trouble deciding how I'm going to store the permissions for users on my site. It must be a way where it's easy to add new types of permissions and easy to add and delete permissions for a user.
My initial thought was to have a table that look like this.
user (id of user)
permission (string to represent a permission)
Then fill it with things like (1, "may_read_forum"), (1, "may_post_in_forum") and so on and so fourth. Then in the relevant places in the code you do an sql query like "SELECT * FROM permissions WHERE user = users_id AND permission = 'may_read_forum' LIMIT 1"
Another way would be to have a permissions filed in the user table and have like a comme delimited list of permissions represented by numbers (1, 4, 6, 7, 8) and then have a table where these permissions were stored with the numeric id and their name. Here you could do a quesry like "SELECT permissions FROM users WHERE user = users_id LIMIT 1" in the beginning of the site and parse and store all the users permissions.
Any other ideas? The first one is clearly the easiest to do. The second would require parsing the result from the query. However, the first on could be a pretty BIG table if the number of users get hig. Say 50.000 users and then say that we have 10-20 permission setting on each user. That would total 1.000.000 records. And then think how often these would be looked through.
Any smart ideas on a good sollution are most wellcome.