## Class TUser

Description

Implements interfaces:

- IUser

TUser class

TUser implements basic user functionality for a Prado application. To get the name of the user, use Name property. The property IsGuest tells if the user a guest/anonymous user. To obtain or test the roles that the user is in, use property Roles and call isInRole(), respectively.

TUser is meant to be used together with IUserManager.

- since: 3.0
- version: $Id: TUser.php 2541 2008-10-21 15:05:13Z qiang.xue $
- author: Qiang Xue <qiang.xue@gmail.com>

Located in /Security/TUser.php (line 34)

    TComponent
       |
       --TUser

Direct descendents

Class | Description
--- | ---
TDbUser | TDbUser class

Method Summary
TUser __construct (IUserManager $manager)
boolean getIsGuest ()
IUserManager getManager ()
string getName ()
array getRoles ()
mixed getState (string $key, [mixed $defaultValue = null])
boolean getStateChanged ()
boolean isInRole (string $role)
IUser loadFromString (string $data)
string saveToString ()
void setIsGuest (boolean $value)
void setName (string $value)
array|string setRoles (mixed $value)
void setState (string $key, mixed $value, [mixed $defaultValue = null])
void setStateChanged (boolean $value)
Methods
Constructor __construct (line 53)

Constructor.

- access: public

TUser __construct (IUserManager $manager)

- IUserManager $manager: user manager

getIsGuest (line 87)

- return: if the user is a guest, defaults to true.
- access: public

boolean getIsGuest ()
getManager (line 63)

- return: user manager
- access: public

IUserManager getManager ()
getName (line 71)

- return: username, defaults to empty string.
- access: public

string getName ()
getRoles (line 108)

- return: list of roles that the user is of
- access: public

array getRoles ()
getState (line 178)

Returns the value of a variable that is stored in user session.

This function is designed to be used by TUser descendant classes who want to store additional user information in user session. A variable, if stored in user session using setState can be retrieved back using this function.

- return: the value of the variable. If it doesn't exist, the provided default value will be returned
- access: protected
- see: TUser::setState()

mixed getState (string $key, [mixed $defaultValue = null])

- string $key: variable name
- mixed $defaultValue: default value

getStateChanged (line 209)

- return: whether user session state is changed (i.e., setState() is called)
- access: public

boolean getStateChanged ()
isInRole (line 136)

- return: whether the user is of this role
- access: public

boolean isInRole (string $role)

- string $role: role to be tested. Note, role is case-insensitive.

loadFromString (line 156)

- return: the user object
- access: public

IUser loadFromString (string $data)

- string $data: user data that is serialized and restored from session

saveToString (line 147)

- return: user data that is serialized and will be stored in session
- access: public

string saveToString ()
setIsGuest (line 95)

- access: public

void setIsGuest (boolean $value)

- boolean $value: if the user is a guest

setName (line 79)

- access: public

void setName (string $value)

- string $value: username

setRoles (line 116)

- return: list of roles that the user is of. If it is a string, roles are assumed by separated by comma
- access: public

array|string setRoles (mixed $value)
setState (line 197)

Stores a variable in user session.

This function is designed to be used by TUser descendant classes who want to store additional user information in user session. By storing a variable using this function, the variable may be retrieved back later using getState. The variable will be persistent across page requests during a user session.

- access: protected
- see: TUser::getState()

void setState (string $key, mixed $value, [mixed $defaultValue = null])

- string $key: variable name
- mixed $value: variable value
- mixed $defaultValue: default value. If $value===$defaultValue, the variable will be removed from persistent storage.

setStateChanged (line 217)

- access: public

void setStateChanged (boolean $value)

- boolean $value: whether user session state is changed

#### Inherited Methods

Inherited From TComponent

> TComponent::addParsedObject()
> TComponent::attachEventHandler()
> TComponent::canGetProperty()
> TComponent::canSetProperty()
> TComponent::createdOnTemplate()
> TComponent::detachEventHandler()
> TComponent::evaluateExpression()
> TComponent::evaluateStatements()
> TComponent::getEventHandlers()
> TComponent::getSubProperty()
> TComponent::hasEvent()
> TComponent::hasEventHandler()
> TComponent::hasProperty()
> TComponent::raiseEvent()
> TComponent::setSubProperty()
> TComponent::__get()
> TComponent::__set()

Documentation generated on Mon, 22 Feb 2010 12:18:58 +0000 by phpDocumentor 1.3.0RC4