Program design help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bryan

    #1

    Program design help

    I'm making a site that I'm having trouble wrapping my head around...it
    makes sense in my head but I can't seem to figure out the best way to
    code it.

    Basically, there are different users levels...
    beta, free, paid, etc...
    and there are different user types
    example: gamer, programmer, dog... etc
    but each user has his own set of "objects" he can use...for example a
    dog would have his bones, collar, etc
    a gamer would have his PC, photos, videos etc... a programmer would
    have his favorite projects, his current projects, his ideas, and to do
    lists etc

    and they can pay for new "objects" or "features" basically, I need to
    figure out how to keep track of all this in the most optimized way as
    possible... here's an example
    User level: paid
    User type: programmer
    because he's a paying user, he gets all the objects for his user type,
    make sense? so we need to then ON his "control panel" let him see the
    objects he has since he's paid so like in a 3 column layout... blocks
    on left and right and then a center column with.. whatever..so example
    blocks would be, projects, blog...etc I hope this makes sense. any help
    is much appreciated.

  • zman

    #2
    Re: Program design help


    bryan wrote:[color=blue]
    > I'm making a site that I'm having trouble wrapping my head around...it
    > makes sense in my head but I can't seem to figure out the best way to
    > code it.
    >
    > Basically, there are different users levels...
    > beta, free, paid, etc...
    > and there are different user types
    > example: gamer, programmer, dog... etc
    > but each user has his own set of "objects" he can use...for example a
    > dog would have his bones, collar, etc
    > a gamer would have his PC, photos, videos etc... a programmer would
    > have his favorite projects, his current projects, his ideas, and to do
    > lists etc
    >
    > and they can pay for new "objects" or "features" basically, I need to
    > figure out how to keep track of all this in the most optimized way as
    > possible... here's an example
    > User level: paid
    > User type: programmer
    > because he's a paying user, he gets all the objects for his user type,
    > make sense? so we need to then ON his "control panel" let him see the
    > objects he has since he's paid so like in a 3 column layout... blocks
    > on left and right and then a center column with.. whatever..so example
    > blocks would be, projects, blog...etc I hope this makes sense. any help
    > is much appreciated.[/color]

    create three session variables

    UserType
    UserLevel

    lets say that UserTyoe=1 is dog

    If UserType=1 Then
    give access to all dog objects
    end if

    Now to solve the type and level hieracrhy

    If UserLevel=1 then
    Case UserType
    1: give access to all dog objects
    2: give access to all gamer objects
    ......
    End Case
    elseif UserType=2 Then
    Case UserType
    1: give access to all dog objects
    2: give access to all gamer objects
    ......
    End Case
    .....

    and so on


    Hope this helps
    Zafar
    --------------------------------------------------------------


    Comment

    • bryan

      #3
      Re: Program design help

      Yeah, help a little. THanks.

      Comment

      • Treefrog

        #4
        Re: Program design help


        bryan wrote:[color=blue]
        > I'm making a site that I'm having trouble wrapping my head around...it
        > makes sense in my head but I can't seem to figure out the best way to
        > code it.
        >
        > Basically, there are different users levels...
        > beta, free, paid, etc...
        > and there are different user types
        > example: gamer, programmer, dog... etc
        > but each user has his own set of "objects" he can use...for example a
        > dog would have his bones, collar, etc
        > a gamer would have his PC, photos, videos etc... a programmer would
        > have his favorite projects, his current projects, his ideas, and to do
        > lists etc
        >
        > and they can pay for new "objects" or "features" basically, I need to
        > figure out how to keep track of all this in the most optimized way as
        > possible... here's an example
        > User level: paid
        > User type: programmer
        > because he's a paying user, he gets all the objects for his user type,
        > make sense? so we need to then ON his "control panel" let him see the
        > objects he has since he's paid so like in a 3 column layout... blocks
        > on left and right and then a center column with.. whatever..so example
        > blocks would be, projects, blog...etc I hope this makes sense. any help
        > is much appreciated.[/color]


        The perfect place to use polymorphism. ;o)

        Identify common properties for you users, e.g.

        class user
        {
        var username;
        var password;
        }

        then extend it for each user.

        class programmer extends user
        {
        var favoriteLanguag e;
        }

        class gamer extends user
        {
        var favoriteGame;
        }

        class dog extends user
        {
        var favoriteBone;
        }


        // store what kind of user they are in the database and at the top of
        each page, instatiate that type. Actually, I'd create a "static" method
        on user that returns the correct type.

        e.g.
        $currentUser = user::getUser($ dbUserType); // get user return type of
        dog, or whatever

        Away you go.

        Hope that helps.

        Comment

        Working...