Jump to content

Recommended Posts

I dont know if it would be user lever, however my issue is lets say we have users and then we have admins.

 

The site has a bunch of videos in sections. The admins set which sections each user is allowed to see. Would that be a user level system or something simpler?

Link to comment
https://forums.phpfreaks.com/topic/121755-making-a-user-level-type-thing/
Share on other sites

I use a 2 part system for updating use permissions

 

part 1 is each account is given an initial "level" so they are Admin/ Power User/ User/ Super admin etc. 

This grants them the abilities of that level.

When I add new functions to my user management system I set which user types can get them.

 

Secondly all the permissions granted are stored in a mysql table that has a  structure of

 

UserID  FunctionID

 

so if I want I can add/remove functions for certain users making each account completely customizable.

one option, relevant specifically to your situation here, is just to have a simple many-many table relationship:

 

user_id | video_id

 

when the admin allow a user to watch a video, insert the corresponding entry into the table.  then, when you want to check permissions, you simply need to check if the entry exists.  similarly, when admin no longer want a user to view it, delete the entry.

 

you'll want an overall distinction between admin and users, which is a simple matter of putting a boolean flag in the users table.  it's not extensible (it can only be true or false for admin status), but it will do the trick if you never intend to get anymore complicated.

  • 3 weeks later...

The way i have done this in the past would be to have a users table, a groups table and a members table.

 

Users:

Uid | Username | Password

1 System ChangeMe

 

Groups:

Gid | Groupname

1 Administrators

12 Premium Membership

 

Members:

Mid | Uid | Gid

1 1 1

 

Then you do the same thing for your videos

 

Video_Members:

id | vid | gid

1 | 25 | 1

2 | 25 | 12

 

In the above example administrators and premium members would have access to video 25.

 

This might seem complicated at first but once you develop some oop functions to manage the memberships then it becomes a lot less complicated in the long run. Plus you could then use the same membership system should you add other features to the site.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.