Julius Posted November 14, 2011 Share Posted November 14, 2011 Hello, I'm creating a website with forum, and till I didn't go too far, I want to make a user levels or something like that. So here it is: i want for example first user to be moderator of first forum; second user would be moderator of first and second forums; I want myself to be an administrator and could be moderator of both of those forums. How should I separate these levels? I hope you understood my problem Quote Link to comment https://forums.phpfreaks.com/topic/251117-moderators-administrators-how-to/ Share on other sites More sharing options...
ManiacDan Posted November 14, 2011 Share Posted November 14, 2011 Google for user access control or user levels. It's very simple. Quote Link to comment https://forums.phpfreaks.com/topic/251117-moderators-administrators-how-to/#findComment-1288024 Share on other sites More sharing options...
Julius Posted November 14, 2011 Author Share Posted November 14, 2011 done. found nothing exactly what I need or explained in very complicated way. If it's so easy, come on, share your knowledge, please Quote Link to comment https://forums.phpfreaks.com/topic/251117-moderators-administrators-how-to/#findComment-1288035 Share on other sites More sharing options...
ManiacDan Posted November 14, 2011 Share Posted November 14, 2011 Add a user_level to your user table. Add a page to edit people's user levels. On every page, when you check for their login, also check to make sure they have the appropriate user level. Done. That's the most basic summary, you can expand on it any way you like, but it DOES involve a lot of code if you want to do it right. Quote Link to comment https://forums.phpfreaks.com/topic/251117-moderators-administrators-how-to/#findComment-1288046 Share on other sites More sharing options...
Julius Posted November 14, 2011 Author Share Posted November 14, 2011 This is simple, and not flexible. I want more complicated version of this. If I would do like you said, I should: create one level for all forums or create very many levels for those cases when user is moderator of first and second forum, first and third forum, second and third forum, or second third and fourth forums. this is flexibility I need. All I have thought out is to create group_names (id, name for example id 1 name user), and group_members ( group_id, member_id, forum_id). Right? But in this case, if there are twelve forums, and one user is moderator of all if them, there would be twelve entries in group_members with the same group_id and member_id. Right? And if I want to add administrator, then in group_members forum_id field i should put zero or leave it blank, because administrator should be moderator of all forums? I want to do this as good as I can for the first time Quote Link to comment https://forums.phpfreaks.com/topic/251117-moderators-administrators-how-to/#findComment-1288053 Share on other sites More sharing options...
KevinM1 Posted November 14, 2011 Share Posted November 14, 2011 This is a great problem to force you (and others) to start thinking like a programmer. Like with other problems, what you need to do is start jotting down what you perceive to be the right way to go re: table columns, and then normalize. Right now, it's hard to tell if you want 1:* relationships, which would necessitate a foreign key in one of your tables, or *:* relationships, which would necessitate pivot tables, or a mix between the two. So questions to answer: How many user levels are you anticipating? What rights should each user level have? How many moderators can an individual sub-forum have? The answers to these questions should inform your design. Remember: good programmers tend to use paper or a whiteboard before writing code. Don't be in a rush to sit down and code immediately. Quote Link to comment https://forums.phpfreaks.com/topic/251117-moderators-administrators-how-to/#findComment-1288069 Share on other sites More sharing options...
Philip Posted November 14, 2011 Share Posted November 14, 2011 Remember: good programmers tend to use paper or a whiteboard before writing code. Don't be in a rush to sit down and code immediately. Couldn't agree more. I've found after I sit down with a whiteboard and doodle a db design or logic pattern out, I tend to code quicker and end up with a result that is way more flexible & better fits my needs then when I don't. If you get completely stumped, there are plenty of open source PHP applications out there that have user permission systems, and robust ones at that. Quote Link to comment https://forums.phpfreaks.com/topic/251117-moderators-administrators-how-to/#findComment-1288077 Share on other sites More sharing options...
ManiacDan Posted November 14, 2011 Share Posted November 14, 2011 Yes, of course it's simple and not flexible, because you said that you googled for solutions and couldn't understand them because they were too complex. Suddenly you would understand me if I explained it properly in high complexity? Why should I spend half an hour writing an article for you, personally, when you've already said you read articles and they were no good? You could also make a separate table for the user levels, that's true, but involving multiple tables was too complex for you I thought, given: found nothing exactly what I need or explained in very complicated way. Your groups could be leveled as well. You could have a group for "global admin" as well as an admin for each section. What the groups are and how they apply are up to you. Quote Link to comment https://forums.phpfreaks.com/topic/251117-moderators-administrators-how-to/#findComment-1288081 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.