CWIS Developer Documentation
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
CWUser Class Reference

CWIS-specific user class. More...

Inheritance diagram for CWUser:
Inheritance graph
[legend]
Collaboration diagram for CWUser:
Collaboration graph
[legend]

Public Member Functions

 __construct ($UserInfo=NULL)
 Load user data from the given user info or from the session if available. More...
 
 Login ($UserName, $Password, $IgnorePassword=FALSE)
 Log the specified user in and associate the underlying Resource with this CWUser. More...
 
 Logout ()
 Log this user out and disassociate their underlying Resource from this CWUser. More...
 
 Privileges (PrivilegeSet $NewValue=NULL)
 THIS FUNCTION HAS BEEN DEPRECATED This provides compatibility for interfaces written to use a version of PrivilegeSet from CWIS 3.0.0 to 3.1.0. More...
 
 ResourceId ()
 Get the ID of the user resource associated with the user. More...
 
 GetResource ()
 Get the associated user resource for this user. More...
 
 HasPriv ($Privilege, $Privileges=NULL)
 Determine if a user has a given privilege, or satisfies the conditions specified by a given privilege set. More...
 
 Delete ()
 Delete the user and its associated user resource. More...
 
 Get ($FieldName)
 Get a value from the specified field. More...
 
 Set ($Field, $NewValue)
 Set a value for the specified field. More...
 
- Public Member Functions inherited from User
 __construct ($UserInfoOne=NULL, $UserInfoTwo=NULL)
 
 Status ()
 
 StatusMessage ()
 
 Delete ()
 
 Id ()
 
 Name ()
 
 GetBestName ()
 Get the best available name associated with a user, i.e., the real name or, if it isn't available, the user name. More...
 
 LastLocation ($NewLocation=NULL)
 
 LastActiveDate ()
 
 LastIPAddress ()
 
 Get ($FieldName)
 
 GetDate ($FieldName, $Format="")
 
 Set ($FieldName, $NewValue)
 
 Login ($UserName, $Password, $IgnorePassword=FALSE)
 
 Logout ()
 
 GetPasswordSalt ($UserName)
 
 IsLoggedIn ()
 Report whether user is currently logged in. More...
 
 IsNotLoggedIn ()
 Report whether user is not currently logged in. More...
 
 IsAnonymous ()
 Report whether user is anonymous user. More...
 
 ChangePassword ($OldPassword, $NewPassword, $NewPasswordAgain)
 Check provided password and set a new one if it war correct. More...
 
 SetPassword ($NewPassword)
 
 SetEncryptedPassword ($NewEncryptedPassword)
 
 CreateNewUserWithEMailedPassword ($UserName, $EMail, $EMailAgain, $TemplateFile="Axis--User--EMailTemplate.txt")
 
 CreateNewUserAndMailPasswordFromFile ($UserName, $EMail, $EMailAgain, $TemplateFile="Axis--User--EMailTemplate.txt")
 
 CreateNewUserAndMailPassword ($UserName, $EMail, $EMailAgain, $EMailSubject, $EMailBody)
 
 GetActivationCode ()
 
 IsActivationCodeGood ($Code)
 
 IsActivated ($NewValue=DB_NOVALUE)
 
 GetResetCode ()
 
 IsResetCodeGood ($Code)
 
 GetMailChangeCode ()
 
 IsMailChangeCodeGood ($Code)
 
 SendEMail ($TemplateTextOrFileName, $FromAddress=NULL, $MoreSubstitutions=NULL, $ToAddress=NULL)
 
 HasPriv ($Privilege, $Privileges=NULL)
 Check whether user has specified privilege(s). More...
 
 GrantPriv ($Privilege)
 
 RevokePriv ($Privilege)
 
 GetPrivList ()
 
 SetPrivList ($NewPrivileges)
 
 GetUniqueCode ($SeedString, $CodeLength)
 
 GetRandomPassword ($PasswordMinLength=6, $PasswordMaxLength=8)
 
 UpdateValue ($FieldName, $NewValue=DB_NOVALUE)
 
 GivePriv ($Privilege)
 

Static Public Member Functions

static EmailWrapper ($To, $Subject, $Message, $AdditionalHeaders)
 Adapter method to bridge between User class and Email class. More...
 
static GetCustomUserFields ()
 Get all custom user fields. More...
 
static GetDefaultUserFields ()
 Get the default user fields. More...
 
- Static Public Member Functions inherited from User
static GetStatusMessageForCode ($StatusCode)
 Get text error message for a specified error code. More...
 
static SetEmailFunction ($NewValue)
 Set email function to use instead of mail(). More...
 
static GetSqlQueryForUsersWithPriv ($Privilege, $Privileges=NULL)
 Get an SQL query that will return IDs of all users that have the specified privilege flags. More...
 
static GetSqlQueryForUsersWithoutPriv ($Privilege, $Privileges=NULL)
 Get an SQL query that will return IDs of all users that do not have the specified privilege flags. More...
 
static GetAnonymousUser ()
 Get the anonymous user (i.e., the User object that exists when no user is logged in), useful when a permission check needs to know if something should be visible to the general public. More...
 
static IsValidUserName ($UserName)
 
static IsValidPassword ($Password, $UserName, $Email)
 
static CheckPasswordForErrors ($Password, $UserName=NULL, $Email=NULL)
 Determine if a provided password complies with the configured rules, optionally checking that it does not contain a specified username or email. More...
 
static IsValidLookingEMailAddress ($EMail)
 
static NormalizeEMailAddress ($EMailAddress)
 
static NormalizeUserName ($UserName)
 
static NormalizePassword ($Password)
 
static SetPasswordRules ($NewValue)
 Set password requirements. More...
 
static SetPasswordMinLength ($NewValue)
 Set password minimum length. More...
 
static SetPasswordMinUniqueChars ($NewValue)
 Set password minimum unique characters. More...
 
static GetPasswordRulesDescription ()
 Get a string describing the password rules. More...
 

Protected Attributes

 $Resource = NULL
 The user resource associated with the user or NULL if the user isn't logged in. More...
 
- Protected Attributes inherited from User
 $DB
 
 $UserId = NULL
 
 $Result
 
 $LoggedIn
 

Additional Inherited Members

- Public Attributes inherited from User
const PW_REQUIRE_PUNCTUATION = 1
 
const PW_REQUIRE_MIXEDCASE = 2
 
const PW_REQUIRE_DIGITS = 4
 

Detailed Description

CWIS-specific user class.

Definition at line 13 of file CWUser.php.

Constructor & Destructor Documentation

CWUser::__construct (   $UserInfo = NULL)

Load user data from the given user info or from the session if available.

Parameters
mixed$UserInfoA user ID or user name. (OPTIONAL)

Definition at line 22 of file CWUser.php.

References $Resource, User\IsAnonymous(), User\SetEmailFunction(), and U_OKAY.

Member Function Documentation

CWUser::Delete ( )

Delete the user and its associated user resource.

Methods should not be called on the object after calling this method.

Returns
Returns the status of the deletion attempt.

Definition at line 276 of file CWUser.php.

References Resource\Delete(), and U_OKAY.

static CWUser::EmailWrapper (   $To,
  $Subject,
  $Message,
  $AdditionalHeaders 
)
static

Adapter method to bridge between User class and Email class.

Parameters
string$ToTo line for message.
string$SubjectSubject line for message.
string$MessageBody of message.
string$AdditionalHeadersOther message header lines, concatenated together into a string.
Returns
bool TRUE if message successfully accepted for delivery, otherwise FALSE.

Definition at line 183 of file CWUser.php.

References User\$Result.

CWUser::Get (   $FieldName)

Get a value from the specified field.

Parameters
string$FieldNameThe name of the field to get.
Returns
Returns the field value or NULL if user data isn't available, e.g., the user isn't logged in.

Definition at line 294 of file CWUser.php.

References Resource\Get(), and User\IsAnonymous().

static CWUser::GetCustomUserFields ( )
static

Get all custom user fields.

Returns
Returns an array of the custom user fields.

Definition at line 221 of file CWUser.php.

References MetadataSchema\SCHEMAID_USER.

static CWUser::GetDefaultUserFields ( )
static

Get the default user fields.

Returns
Returns an array of the default user fields.

Definition at line 247 of file CWUser.php.

References MetadataSchema\SCHEMAID_USER.

CWUser::GetResource ( )

Get the associated user resource for this user.

Returns
Returns the associated user resource or NULL if it's not available, e.g., the user isn't logged in.

Definition at line 137 of file CWUser.php.

CWUser::HasPriv (   $Privilege,
  $Privileges = NULL 
)

Determine if a user has a given privilege, or satisfies the conditions specified by a given privilege set.

Calling this function with a PrivilegeSet as the first argument is supported only for backwards compatibility. New code should not do this.

Parameters
mixed$PrivilegePrivilige number or Privilige set to check
mixed$PrivilegesAdditional privileges (as in parent::HasPriv()), or a Resource to use if the first arg was a PrivilegeSet.
Returns
TRUE if the user has the specified privilege (or satisfies the requirements of the specified privilege set.

Definition at line 154 of file CWUser.php.

Referenced by PrivilegeSet\MeetsRequirements().

Here is the caller graph for this function:

CWUser::Login (   $UserName,
  $Password,
  $IgnorePassword = FALSE 
)

Log the specified user in and associate the underlying Resource with this CWUser.

Parameters
string$UserNameUser to log in.
string$PasswordUser's password.
bool$IgnorePasswordTRUE to skip password validation (OPTIONAL, default FALSE)

Definition at line 70 of file CWUser.php.

References $Resource, User\$Result, and U_OKAY.

CWUser::Logout ( )

Log this user out and disassociate their underlying Resource from this CWUser.

Definition at line 97 of file CWUser.php.

CWUser::Privileges ( PrivilegeSet  $NewValue = NULL)

THIS FUNCTION HAS BEEN DEPRECATED This provides compatibility for interfaces written to use a version of PrivilegeSet from CWIS 3.0.0 to 3.1.0.

Parameters
PrivilegeSet$NewValueNew value (OPTIONAL, default NULL)
Returns
PrivilegeSetCompatibiliityShim for use in legacy code.

Definition at line 110 of file CWUser.php.

CWUser::ResourceId ( )

Get the ID of the user resource associated with the user.

Returns
Returns the ID of the associated user resource or NULL if it's not available, e.g., the user isn't logged in.

Definition at line 127 of file CWUser.php.

References Resource\Id().

CWUser::Set (   $Field,
  $NewValue 
)

Set a value for the specified field.

Parameters
string$FieldThe field to set (name, id, or MetadataField object).
mixed$NewValueThe value to which to set the field.
Returns
Returns the status of the operation.

Definition at line 318 of file CWUser.php.

References User\$Result, User\IsAnonymous(), Resource\Set(), and U_OKAY.

Member Data Documentation

CWUser::$Resource = NULL
protected

The user resource associated with the user or NULL if the user isn't logged in.

Definition at line 361 of file CWUser.php.

Referenced by __construct(), and Login().


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