moon 111 Posted May 16, 2008 Share Posted May 16, 2008 I have a class User which when created as an object gets the information for a specific user and has functions that the user could use (change email, add credits etc.). I now would like to add some functions for adding, deleting and managing users, and I'm not sure if I should create a new class or put it in the old one. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/105942-class-problem/ Share on other sites More sharing options...
KevinM1 Posted May 16, 2008 Share Posted May 16, 2008 I have a class User which when created as an object gets the information for a specific user and has functions that the user could use (change email, add credits etc.). I now would like to add some functions for adding, deleting and managing users, and I'm not sure if I should create a new class or put it in the old one. Thanks There are really two questions you have to ask: 1. Should all users be allowed to have those administration capabilities (which I put in bold) available to them from the outset? 2. Does it make sense to put functions that make sweeping system changes into the same class that previously allowed only individual changes? I can't think of a reason, other than wanting to save a few keystrokes, to shoehorn administration functions into a generic user class. This sort of thing is better left to an administration class of some sort that is responsible for largescale user manipulation. Quote Link to comment https://forums.phpfreaks.com/topic/105942-class-problem/#findComment-542970 Share on other sites More sharing options...
nloding Posted May 16, 2008 Share Posted May 16, 2008 I did it this way: Make an Admin class that does admin functions. If $user->is_admin (or however you check), instantiate the $admin class. It is only instantiated on admin panel screens for 'better' security. If there's a better way, let me know. I'm still wrapping my head around OOP. Quote Link to comment https://forums.phpfreaks.com/topic/105942-class-problem/#findComment-543102 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.