IronNoob

Please login or register.

Login with username, password and session length
Advanced search  

News:

Migrated to dedicated hosting. Post any weirdness you observe in the Lounge.

Author Topic: How should I setup a user permissions table for a forum?  (Read 82 times)

0 Members and 1 Guest are viewing this topic.

mustyoshi

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3099
  • I'm a pig, your argument is invalid.
    • View Profile
How should I setup a user permissions table for a forum?
« on: May 03, 2013, 09:45:17 am »

I'm rewriting the database of my forums to make them cleaner and more efficient hopefully.

And I was wondering how I should handle user permissions for viewing boards. Any suggestions would be greatly appreciated.
EDIT:
What I have so far.
« Last Edit: May 06, 2013, 10:53:07 am by mustyoshi »
Logged

Act of God, insurance companies don't cover it.
[/m

Ķįŋg_Ţŗęļįcoŋ

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 456
  • I am motherfucking Trelicon.
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #1 on: May 03, 2013, 10:15:39 am »

You have a forum?
Logged

mustyoshi

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3099
  • I'm a pig, your argument is invalid.
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #2 on: May 03, 2013, 10:40:30 am »

You have a forum?
I have like half a forum.
You can't private message yet, and there's no moderation.
Logged

Act of God, insurance companies don't cover it.
[/m

Ķįŋg_Ţŗęļįcoŋ

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 456
  • I am motherfucking Trelicon.
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #3 on: May 03, 2013, 11:54:00 am »

You have a forum?
I have like half a forum.
You can't private message yet, and there's no moderation.


can you message me the link? ;)
Logged

Core

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2815
  • Ironnoob Nicegod
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #4 on: May 03, 2013, 12:20:05 pm »

I'd just have a row where you store the topics, and have it like "permissions." 1 = everyone can see, 2 = moderators can see, 3 = admins can see, etc.
Logged
Quite your mind, silence your heart. ~Core

mustyoshi

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3099
  • I'm a pig, your argument is invalid.
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #5 on: May 03, 2013, 04:11:48 pm »

I'd just have a row where you store the topics, and have it like "permissions." 1 = everyone can see, 2 = moderators can see, 3 = admins can see, etc.
That's what I figured people would suggest.
Logged

Act of God, insurance companies don't cover it.
[/m

Core

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2815
  • Ironnoob Nicegod
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #6 on: May 03, 2013, 04:14:55 pm »

I'd just have a row where you store the topics, and have it like "permissions." 1 = everyone can see, 2 = moderators can see, 3 = admins can see, etc.
That's what I figured people would suggest.

It's probably the simplest you can get. That's what I'm currently using in my own forum, and it seems to be working fine. But, you need to make sure that they still can't access it via the URL.
Logged
Quite your mind, silence your heart. ~Core

Void_Knight

  • Man of Mystery
  • Global Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 9602
  • Nope, Void_Knight.
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #7 on: May 03, 2013, 04:59:03 pm »

I'd just have a row where you store the topics, and have it like "permissions." 1 = everyone can see, 2 = moderators can see, 3 = admins can see, etc.
Have a table storing "groups" with permission bits as booleans, then store the group ID or whatever in the user so the database can just fetch the appropriate permission group and get the permissions the user is allowed from their permission group.

That's how The Tavern has quite a lot of groups of users that can do different things.
« Last Edit: May 03, 2013, 05:01:14 pm by Void_Knight »
Logged

Void_Knight

  • Man of Mystery
  • Global Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 9602
  • Nope, Void_Knight.
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #8 on: May 03, 2013, 05:08:43 pm »

Here's an example I made in excel with highlighted rows to help you see it.


If the ID of a group is too vague and hard to figure out if you're editing it via database - you can always do it by Name.
Logged

Core

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2815
  • Ironnoob Nicegod
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #9 on: May 03, 2013, 05:12:23 pm »

I'd just have a row where you store the topics, and have it like "permissions." 1 = everyone can see, 2 = moderators can see, 3 = admins can see, etc.
Have a table storing "groups" with permission bits as booleans, then store the group ID or whatever in the user so the database can just fetch the appropriate permission group and get the permissions the user is allowed from their permission group.

That's how The Tavern has quite a lot of groups of users that can do different things.

I've never used booleans before, mainly because they confuse me.

But, yeah, you could also use that.
Logged
Quite your mind, silence your heart. ~Core

Void_Knight

  • Man of Mystery
  • Global Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 9602
  • Nope, Void_Knight.
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #10 on: May 03, 2013, 05:15:49 pm »

I'd just have a row where you store the topics, and have it like "permissions." 1 = everyone can see, 2 = moderators can see, 3 = admins can see, etc.
Have a table storing "groups" with permission bits as booleans, then store the group ID or whatever in the user so the database can just fetch the appropriate permission group and get the permissions the user is allowed from their permission group.

That's how The Tavern has quite a lot of groups of users that can do different things.

I've never used booleans before, mainly because they confuse me.

But, yeah, you could also use that.
Seriously?

Booleans are either 0 (false) or 1 (true). Pretty straightforward and not hard at all if you ask me.
Logged

Core

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2815
  • Ironnoob Nicegod
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #11 on: May 03, 2013, 05:16:48 pm »

I'd just have a row where you store the topics, and have it like "permissions." 1 = everyone can see, 2 = moderators can see, 3 = admins can see, etc.
Have a table storing "groups" with permission bits as booleans, then store the group ID or whatever in the user so the database can just fetch the appropriate permission group and get the permissions the user is allowed from their permission group.

That's how The Tavern has quite a lot of groups of users that can do different things.

I've never used booleans before, mainly because they confuse me.

But, yeah, you could also use that.
Seriously?

Booleans are either 0 (false) or 1 (true). Pretty straightforward and not hard at all if you ask me.

Alright, yes, I know how they are used or whatever, I just don't know how to set them up.
Logged
Quite your mind, silence your heart. ~Core

mustyoshi

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 3099
  • I'm a pig, your argument is invalid.
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #12 on: May 03, 2013, 05:26:15 pm »

Here's an example I made in excel with highlighted rows to help you see it.


If the ID of a group is too vague and hard to figure out if you're editing it via database - you can always do it by Name.
Hmm, interesting, right now I only have 6 permission levels; can't view, to full moderation privileges. I have them as a single int, where each user group, which I'm planning on having some sort of user created group deal, where they can make their own subforums and stuff. So custom user rules will be needed for those special boards.
Idk, it's a mess right now :c
Logged

Act of God, insurance companies don't cover it.
[/m

Void_Knight

  • Man of Mystery
  • Global Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 9602
  • Nope, Void_Knight.
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #13 on: May 03, 2013, 05:53:01 pm »

Here's an example I made in excel with highlighted rows to help you see it.


If the ID of a group is too vague and hard to figure out if you're editing it via database - you can always do it by Name.
Hmm, interesting, right now I only have 6 permission levels; can't view, to full moderation privileges. I have them as a single int, where each user group, which I'm planning on having some sort of user created group deal, where they can make their own subforums and stuff. So custom user rules will be needed for those special boards.
Idk, it's a mess right now :c
The reason I've made it like the example above is it's easier to assign permissions to groups and add new groups without editing code at all, plus it's easier to check if a user is higher in permissions rank than a certain user so you can have it so admins can't ban you or do anything to your account, moderators can't ban or do anything to admins' accounts. Works nicely.

Then, simply put I do the following to only allow a person to do something if they're able to lets say "Moderate"

if ($LocalUser->Permissions["Moderate"]) echo $LocalUser->Username.", you're a moderator. c:";


If user is higher than the other user in rank, echo "You're higher!"


$user1 
= &$LocalUser// reference pointer, ftw.
$user2 = new UserAccount(8); // User #8 

if ($user1->Permissions["Rank"] > $user2->Permissions["Rank"]) echo "You're higher!";
Logged

Theblindman45

  • Full Member
  • ***
  • Online Online
  • Posts: 173
  • Oh hai dere
    • View Profile
Re: How should I setup a user permissions table for a forum?
« Reply #14 on: Today at 07:38:58 am »

Here's an example I made in excel with highlighted rows to help you see it.


If the ID of a group is too vague and hard to figure out if you're editing it via database - you can always do it by Name.
Hmm, interesting, right now I only have 6 permission levels; can't view, to full moderation privileges. I have them as a single int, where each user group, which I'm planning on having some sort of user created group deal, where they can make their own subforums and stuff. So custom user rules will be needed for those special boards.
Idk, it's a mess right now :c
Can I be a mod on there?
Logged
Simple things make big impacts"-Theblindman45
 

Page created in 0.158 seconds with 21 queries.