#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2017
    Posts
    5
    Rep Power
    0

    Web Development in PHP


    Hello there, I want to know "How can i structure groups within a website? (groups like in mean-- admin ,moderators, helpers,users, etc-etc) ? " in context of PHP ... this site has the groups like this as i said, please someone provide me some concepts and ideas how i can implement this ?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,322
    Rep Power
    630
    If I understand correctly, you would establish the group a user belongs to as part of the login process which would be stored in the users database. Then program your script to allow links only to the pages associated with the group to which that user belongs.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,780
    Rep Power
    4536
    Sounds like you want a Role-based Access Control system. You'll have users, roles and actions, with tables linking all three. The simplist way to think about this is having read, write and update actions. An administrator role would be able to perform all of those actions while a user role may only be able to read. Once roles & actions are linked, then link them to a specific user and you have your access control.

    That's just the methodology, though. On each PHP page, you'll need to define check if the user is allowed to perform the action. The devil is in the details, there, on how you do that correctly.

    -John
    -- Cigars, whiskey and wild, wild women. --
  6. #4
  7. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,333
    Rep Power
    9645
    Do you even know what you want? Do you have an idea in mind for how these will work on your site? Or are you just looking for ideas about what user groups could do?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2017
    Posts
    5
    Rep Power
    0
    Thanks for the infos ...
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2017
    Posts
    5
    Rep Power
    0
    Originally Posted by requinix
    Do you even know what you want? Do you have an idea in mind for how these will work on your site? Or are you just looking for ideas about what user groups could do?
    yes i was just trying to play with the things ... i am thinking of developing an online music web app with PHP as backend ... and i want to structure the system within mainly Admins, Mods,Helper and
    User categories with Admin having the most powerful actions like disabling site member, checking systems,etc-etc and users with list previlages.I don't think
    i should about these coz u know how this works tell,so just wanted to implement those things in my small project ... I just want some helps how can i really do it. Please drop your responses , they will help me out really.
  12. #7
  13. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,333
    Rep Power
    9645
    There are a bunch of ways to do this. Easiest is to make an array of all the possible actions and list out which roles can do them.

    Using a forum as an example, I'm thinking of something like
    PHP Code:
    // not listing admin because they can do everything
    $actions = [
        
    "create a thread" => ["mod""helper""user"],
        
    "delete a thread" => ["mod"],
        
    "move a thread" => ["mod""helper"]
    ]; 
    When a user logs in, you could put all that data into the session.
    PHP Code:
    $_SESSION["user can"] = [];
    foreach (
    $actions as $name => $roles) {
        
    $_SESSION["user can"][$name] = ($_SESSION["role"] == "admin" || in_array($_SESSION["role"], $roles));

    If you wanted to know whether the user could create a thread then
    PHP Code:
    if ($_SESSION["user can"]["create a thread"]) { 
    Regardless of the approach, remember to put checks like that in two places: where you give the user the option to do the action (show the button) as well as the place that actually does the action (the code that handles the button). Because it's not enough to just hide the button - you have to make sure the action really isn't possible to do with the wrong role.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2017
    Posts
    5
    Rep Power
    0
    Thank you all for the positive response ... keep the ideas coming

IMN logo majestic logo threadwatch logo seochat tools logo