|
Posted by Treefrog on 05/11/06 11:09
bryan wrote:
> 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.
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 favoriteLanguage;
}
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.
Navigation:
[Reply to this message]
|