I think you need some kind of user object that is created on login and is either passed to every function or made available by some other means. Perhaps a singleton. Or possibly a member variable passed to the constructor of classes that require this type of access control.
Don't pass the type of the caller to the function... or try to determine the type from the called function. Both of these are bad design as they require the called function to be aware of the calling type.
This is bad because:
- it requires the function to be aware of all possible types that can call the function
- it makes it difficult to add new types in the future
- it assumes that the calling function even has a type (what if it is being called from a static/global function?)
A better approach would be to have some kind of access level variable and pass that to the function.
I will do it through a session created when the user logs on.The session has a member userType, as has "User", set when "User"logs in.The User does almost every action through a session, so I check the userType.