SUser Class Reference
[Session Handling]

Represents a user and his/her personal data. More...

Inheritance diagram for SUser:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 clearFlash ()
 Clear the list of pending notifications for this user.
 clearSessionData ($key=null)
 Clear session data for a given key, or all session data.
 doc ()
 Return a documentation string about this class.
 flash ($flash)
 Add a notification to the user's flash (a shortcut to setFlash()).
 getAttributes ()
 Get the names of all attributes for this object/entity.
 getFlash ()
 Get the flash for this user.
 getName ()
 Get the user's full name.
 getSessionData ($key)
 Fetch additional data stored in this user object (with a key).
 getUniqueAttributes ()
 Get the list of unique attributes for this object (candidate keys).
 isAdmin ()
 Check to see if a user has the ADMIN role.
 isAnonymous ()
 Check to see if a user's role is ANONYMOUS.
 issetSessionData ($key)
 Check to see if session data is set for a certain key.
 reset ()
 Reset the role of a user.
 setFlash ($flash)
 Add a notification to the user's flash.
 setSessionData ($key, $value)
 Save additional data into this user object (with a key).

Public Attributes

const ADMIN
 Logged in as administrator, (i.e., full permissions).
const ANONYMOUS
 Not currently logged in (i.e., no identity).
const NOT_ACTIVE
 Means the user is not currently active in the system (not allowed to login).

Protected Attributes

 $active
 Whether or not the user is active (or disabled).
 $firstName
 The first name of the user as a string.
 $flash
 The list of messages waiting to be displayed to the user.
 $id
 The user's id for persistant storage -- i.e., database primary key.
 $lastName
 The last name of the user as a string.
 $role
 The user's current role (changes based on their login status).
 $sessionData
 Misc session data stored for this user by web app controllers.
 $userName
 The username of the user for login.


Detailed Description

Represents a user and his/her personal data.

This class can be used to represent a user and his/her personal data. It can be stored in the session (to follow the same user around to multiple different pages) and also written out to/ read from the database for storage.

The user object can keep data about the user's name, email, etc., the user's role (whether they are authenticated and with what level of permission), and also other small pieces of data that applications wish to store for a particular user. Finally, it stores a "flash" -- a set of pending messages to the user, generated by applications the user is using, that should be displayed to them on the screen at the next possible opportunity.

Author:
Jonathan Stuart-Moore <jwsm@shodor.org> (2007)

Monte Evans <monte@shodor.org> (2007)

Date:
5/4/07

updated 6/17/07

updated 5/24/07


Member Function Documentation

SUser::clearSessionData ( key = null  ) 

Clear session data for a given key, or all session data.

If a key is passed, clear session data that has previously been stored for that key using setSessionData(). If no key is passed, clear all session data stored for this user.

Parameters:
$key [string]: The name of session data to clear, or blank if all session data should be cleared.
Returns:
[mixed]: False if a key is specified but not found

SUser::flash ( flash  ) 

Add a notification to the user's flash (a shortcut to setFlash()).

Parameters:
$flash [string]: The notification

SUser::getAttributes (  ) 

Get the names of all attributes for this object/entity.

Return an array of all the instance variables for this object/entity that should be committed to the database when commit() is called on this object.

Returns:
[array]: The list of attribute names (as strings)

Reimplemented from SModel.

Reimplemented in CSERDUser, and SGlobalUser.

SUser::getFlash (  ) 

Get the flash for this user.

Get the list of notifications waiting to be displayed to this user

Returns:
[array]: The list of notification strings

SUser::getName (  ) 

Get the user's full name.

Join the user's first and last names with a space

Returns:
[string]: The user's full name

SUser::getSessionData ( key  ) 

Fetch additional data stored in this user object (with a key).

Retrieve additional data stored in the user object using setSessionData().

Parameters:
$key [string]: The name of the stored session data (i.e., scope.attribute)
Returns:
[mixed]: The stored value, or null if there is no matching key

SUser::getUniqueAttributes (  ) 

Get the list of unique attributes for this object (candidate keys).

Return a list of the unique attributes (candidate keys) for this object. The first item in this list must be the primary key. But you should theoretically be able to populate on any attribute in this list.

For most objects, this function will return a list with one element -- the string 'id'

Returns:
[array]: The list of unique attribute names (as strings)

Reimplemented from SModel.

Reimplemented in CSERDUser, and SGlobalUser.

SUser::isAdmin (  ) 

Check to see if a user has the ADMIN role.

Returns:
[bool]: True if the user is logged in as ADMIN, false if not

SUser::isAnonymous (  ) 

Check to see if a user's role is ANONYMOUS.

Returns:
[bool]: True if the user is ANONYMOUS (not logged in), false if not (is logged in)

SUser::issetSessionData ( key  ) 

Check to see if session data is set for a certain key.

Parameters:
$key [string]: A key to check for stored session data (i.e., scope.attribute)
Returns:
[bool]: True if there is data set at that key, false if not

SUser::reset (  ) 

Reset the role of a user.

Reset a user's role to ANONYMOUS, i.e., log them out of any role they currently have.

Reimplemented from SModel.

Reimplemented in CSERDUser.

SUser::setFlash ( flash  ) 

Add a notification to the user's flash.

Add a notification for the user that should be displayed to them onscreen. A controller will have to actively ask the user object for its flash and then print that flash to the screen.

Parameters:
$flash [string]: The notification

SUser::setSessionData ( key,
value 
)

Save additional data into this user object (with a key).

Store additional data in this user object (instead of putting it directly into an index in the session). This data can be used to store things such as pages most recently viewed by the user. The data can be recalled later using getSessionData().

Parameters:
$key [string]: The name of the session data to be stored. (i.e., scope.attribute)
$value [mixed]: The value to be stored


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:03:59 2010 for Common by  doxygen 1.5.6