CWIS Developer Documentation
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
User Class Reference
Inheritance diagram for User:
Inheritance graph
[legend]

Public Member Functions

 __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 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...
 

Public Attributes

const PW_REQUIRE_PUNCTUATION = 1
 
const PW_REQUIRE_MIXEDCASE = 2
 
const PW_REQUIRE_DIGITS = 4
 

Protected Attributes

 $DB
 
 $UserId = NULL
 
 $Result
 
 $LoggedIn
 

Detailed Description

Definition at line 48 of file User.php.

Constructor & Destructor Documentation

User::__construct (   $UserInfoOne = NULL,
  $UserInfoTwo = NULL 
)

Definition at line 57 of file User.php.

References $UserId, U_NOSUCHUSER, and U_OKAY.

Member Function Documentation

User::ChangePassword (   $OldPassword,
  $NewPassword,
  $NewPasswordAgain 
)

Check provided password and set a new one if it war correct.

Parameters
string$OldPasswordCurrent password.
string$NewPasswordPassword to set.
string$NewPasswordAgainConfirm new password.
Returns
U_OKAY on success, a different L_ constant on fail

Definition at line 515 of file User.php.

References $Result, Get(), SetPassword(), U_BADPASSWORD, U_ILLEGALPASSWORD, U_NOTLOGGEDIN, U_OKAY, and U_PASSWORDSDONTMATCH.

static User::CheckPasswordForErrors (   $Password,
  $UserName = NULL,
  $Email = NULL 
)
static

Determine if a provided password complies with the configured rules, optionally checking that it does not contain a specified username or email.

Parameters
string$PasswordPassword to check.
string$UserNameUsername to check (OPTIONAL)
string$EmailEmail to check (OPTIONAL)
Returns
array of problems or empty array on success.

Definition at line 1118 of file User.php.

References U_EMPTYPASSWORD, U_PASSWORDCONTAINSEMAIL, U_PASSWORDCONTAINSUSERNAME, U_PASSWORDNEEDSDIGIT, U_PASSWORDNEEDSMIXEDCASE, U_PASSWORDNEEDSPUNCTUATION, U_PASSWORDTOOSHORT, and U_PASSWORDTOOSIMPLE.

User::CreateNewUserAndMailPassword (   $UserName,
  $EMail,
  $EMailAgain,
  $EMailSubject,
  $EMailBody 
)

Definition at line 597 of file User.php.

References $Result, GetRandomPassword(), IsValidLookingEMailAddress(), Set(), U_EMAILSDONTMATCH, U_ILLEGALEMAIL, U_MAILINGERROR, and U_OKAY.

Referenced by CreateNewUserAndMailPasswordFromFile().

Here is the caller graph for this function:

User::CreateNewUserAndMailPasswordFromFile (   $UserName,
  $EMail,
  $EMailAgain,
  $TemplateFile = "Axis--User--EMailTemplate.txt" 
)

Definition at line 584 of file User.php.

References CreateNewUserAndMailPassword().

Referenced by CreateNewUserWithEMailedPassword().

Here is the caller graph for this function:

User::CreateNewUserWithEMailedPassword (   $UserName,
  $EMail,
  $EMailAgain,
  $TemplateFile = "Axis--User--EMailTemplate.txt" 
)

Definition at line 576 of file User.php.

References CreateNewUserAndMailPasswordFromFile().

User::Delete ( )

Definition at line 188 of file User.php.

References $Result, and U_OKAY.

User::Get (   $FieldName)

Definition at line 275 of file User.php.

References UpdateValue().

Referenced by ChangePassword(), GetBestName(), GetMailChangeCode(), GetUniqueCode(), LastActiveDate(), LastIPAddress(), LastLocation(), Name(), SendEMail(), and UserEditingUI\UpdateUserAttributes().

Here is the caller graph for this function:

User::GetActivationCode ( )

Definition at line 668 of file User.php.

References GetUniqueCode().

Referenced by IsActivationCodeGood(), and SendEMail().

Here is the caller graph for this function:

static User::GetAnonymousUser ( )
static

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.

Returns
Anonymous user

Definition at line 1038 of file User.php.

References $Result.

Referenced by ResourceFactory\GetRecentlyReleasedResources(), ResourceFactory\GetReleasedResourceTotal(), and Classification\RecalcResourceCount().

Here is the caller graph for this function:

User::GetBestName ( )

Get the best available name associated with a user, i.e., the real name or, if it isn't available, the user name.

Returns
Returns the best available name for the user.

Definition at line 231 of file User.php.

References Get().

User::GetDate (   $FieldName,
  $Format = "" 
)

Definition at line 284 of file User.php.

User::GetMailChangeCode ( )

Definition at line 704 of file User.php.

References Get(), and GetUniqueCode().

Referenced by IsMailChangeCodeGood(), and SendEMail().

Here is the caller graph for this function:

static User::GetPasswordRulesDescription ( )
static

Get a string describing the password rules.

Returns
string Descriptive string.

Definition at line 1276 of file User.php.

Referenced by UserEditingUI\GetRequestAccountForm().

Here is the caller graph for this function:

User::GetPasswordSalt (   $UserName)

Definition at line 432 of file User.php.

References $Result.

User::GetPrivList ( )

Definition at line 1004 of file User.php.

User::GetRandomPassword (   $PasswordMinLength = 6,
  $PasswordMaxLength = 8 
)

Definition at line 1221 of file User.php.

Referenced by CreateNewUserAndMailPassword().

Here is the caller graph for this function:

User::GetResetCode ( )

Definition at line 689 of file User.php.

References GetUniqueCode().

Referenced by IsResetCodeGood(), and SendEMail().

Here is the caller graph for this function:

static User::GetSqlQueryForUsersWithoutPriv (   $Privilege,
  $Privileges = NULL 
)
static

Get an SQL query that will return IDs of all users that do not have the specified privilege flags.

This method is useful primarily for subqueries.

Parameters
mixed$PrivilegePrivilege or array of privileges.
mixed$PrivilegesOne or more additional privileges. (variable length argument list) (OPTIONAL)
Returns
SQL query to retrieve user IDs.

Definition at line 919 of file User.php.

static User::GetSqlQueryForUsersWithPriv (   $Privilege,
  $Privileges = NULL 
)
static

Get an SQL query that will return IDs of all users that have the specified privilege flags.

This method is useful primarily for subqueries.

Parameters
mixed$PrivilegePrivilege or array of privileges.
mixed$PrivilegesOne or more additional privileges. (variable length argument list) (OPTIONAL)
Returns
SQL query to retrieve user IDs.

Definition at line 876 of file User.php.

static User::GetStatusMessageForCode (   $StatusCode)
static

Get text error message for a specified error code.

Parameters
int$StatusCodeOne of the U_ constants.
Returns
string error description

Definition at line 133 of file User.php.

References U_BADPASSWORD, U_DUPLICATEEMAIL, U_DUPLICATEUSERNAME, U_EMAILSDONTMATCH, U_EMPTYPASSWORD, U_ERROR, U_ILLEGALEMAIL, U_ILLEGALPASSWORD, U_ILLEGALUSERNAME, U_MAILINGERROR, U_NOSUCHUSER, U_NOTLOGGEDIN, U_OKAY, U_PASSWORDCONTAINSEMAIL, U_PASSWORDCONTAINSUSERNAME, U_PASSWORDNEEDSDIGIT, U_PASSWORDNEEDSMIXEDCASE, U_PASSWORDNEEDSPUNCTUATION, U_PASSWORDSDONTMATCH, U_PASSWORDTOOSHORT, U_PASSWORDTOOSIMPLE, and U_TEMPLATENOTFOUND.

Referenced by UserEditingUI\UserFormHasErrors().

Here is the caller graph for this function:

User::GetUniqueCode (   $SeedString,
  $CodeLength 
)

Definition at line 1065 of file User.php.

References Get().

Referenced by GetActivationCode(), GetMailChangeCode(), and GetResetCode().

Here is the caller graph for this function:

User::GivePriv (   $Privilege)

Definition at line 1239 of file User.php.

References GrantPriv().

User::GrantPriv (   $Privilege)

Definition at line 954 of file User.php.

References $Result, U_ERROR, U_NOTLOGGEDIN, and U_OKAY.

Referenced by GivePriv(), and SetPrivList().

Here is the caller graph for this function:

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

Check whether user has specified privilege(s).

Parameters
mixed$PrivilegePrivilege or array of privileges.
mixed$PrivilegesOne or more additional privileges. (variable length argument list) (OPTIONAL)
Returns
TRUE if user has one or more of specified privilege(s), otherwise FALSE.

Definition at line 820 of file User.php.

User::Id ( )

Definition at line 217 of file User.php.

References $UserId.

Referenced by UserEditingUI\UpdateUserAttributes().

Here is the caller graph for this function:

User::IsActivated (   $NewValue = DB_NOVALUE)

Definition at line 683 of file User.php.

References UpdateValue().

User::IsActivationCodeGood (   $Code)

Definition at line 676 of file User.php.

References GetActivationCode().

User::IsAnonymous ( )

Report whether user is anonymous user.

Returns
bool TRUE if user is anonymous, otherwise FALSE.

Definition at line 499 of file User.php.

Referenced by CWUser\__construct(), CWUser\Get(), and CWUser\Set().

Here is the caller graph for this function:

User::IsLoggedIn ( )

Report whether user is currently logged in.

Returns
bool TRUE if user is logged in, otherwise FALSE.
See also
User::IsNotLoggedIn()

Definition at line 473 of file User.php.

References $LoggedIn.

Referenced by IsNotLoggedIn(), and Logout().

Here is the caller graph for this function:

User::IsMailChangeCodeGood (   $Code)

Definition at line 712 of file User.php.

References GetMailChangeCode().

User::IsNotLoggedIn ( )

Report whether user is not currently logged in.

Returns
bool TRUE if user is not logged in, otherwise FALSE.
See also
User::IsLoggedIn()

Definition at line 490 of file User.php.

References IsLoggedIn().

User::IsResetCodeGood (   $Code)

Definition at line 697 of file User.php.

References GetResetCode().

static User::IsValidLookingEMailAddress (   $EMail)
static

Definition at line 1189 of file User.php.

Referenced by CreateNewUserAndMailPassword().

Here is the caller graph for this function:

static User::IsValidPassword (   $Password,
  $UserName,
  $Email 
)
static

Definition at line 1101 of file User.php.

static User::IsValidUserName (   $UserName)
static

Definition at line 1088 of file User.php.

User::LastActiveDate ( )

Definition at line 265 of file User.php.

References Get().

User::LastIPAddress ( )

Definition at line 269 of file User.php.

References Get().

User::LastLocation (   $NewLocation = NULL)

Definition at line 245 of file User.php.

References Get().

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

Definition at line 327 of file User.php.

References $Result, $UserId, U_BADPASSWORD, U_NOSUCHUSER, U_NOTACTIVATED, and U_OKAY.

User::Logout ( )

Definition at line 414 of file User.php.

References IsLoggedIn().

User::Name ( )

Definition at line 221 of file User.php.

References Get().

static User::NormalizeEMailAddress (   $EMailAddress)
static

Definition at line 1203 of file User.php.

static User::NormalizePassword (   $Password)
static

Definition at line 1215 of file User.php.

static User::NormalizeUserName (   $UserName)
static

Definition at line 1209 of file User.php.

User::RevokePriv (   $Privilege)

Definition at line 989 of file User.php.

References $Result, U_NOTLOGGEDIN, and U_OKAY.

User::SendEMail (   $TemplateTextOrFileName,
  $FromAddress = NULL,
  $MoreSubstitutions = NULL,
  $ToAddress = NULL 
)
User::Set (   $FieldName,
  $NewValue 
)

Definition at line 307 of file User.php.

References $Result, U_NOTLOGGEDIN, U_OKAY, and UpdateValue().

Referenced by CreateNewUserAndMailPassword(), and UserEditingUI\UpdateUserAttributes().

Here is the caller graph for this function:

static User::SetEmailFunction (   $NewValue)
static

Set email function to use instead of mail().

Parameters
callback$NewValueCallable email function or method that accepts the same arguments as mail().

Definition at line 207 of file User.php.

Referenced by CWUser\__construct().

Here is the caller graph for this function:

User::SetEncryptedPassword (   $NewEncryptedPassword)

Definition at line 570 of file User.php.

References UpdateValue().

User::SetPassword (   $NewPassword)

Definition at line 560 of file User.php.

References UpdateValue().

Referenced by ChangePassword().

Here is the caller graph for this function:

static User::SetPasswordMinLength (   $NewValue)
static

Set password minimum length.

Parameters
int$NewValueNew minimum length.

Definition at line 1258 of file User.php.

static User::SetPasswordMinUniqueChars (   $NewValue)
static

Set password minimum unique characters.

Parameters
int$NewValueNew number of required unique characters.

Definition at line 1267 of file User.php.

static User::SetPasswordRules (   $NewValue)
static

Set password requirements.

Parameters
int$NewValueNew password rules as a bitmask of PW_* constants.

Definition at line 1249 of file User.php.

User::SetPrivList (   $NewPrivileges)

Definition at line 1015 of file User.php.

References GrantPriv(), and U_NOTLOGGEDIN.

User::Status ( )

Definition at line 117 of file User.php.

References $Result.

Referenced by SendEMail().

Here is the caller graph for this function:

User::StatusMessage ( )

Definition at line 123 of file User.php.

User::UpdateValue (   $FieldName,
  $NewValue = DB_NOVALUE 
)

Definition at line 1232 of file User.php.

Referenced by Get(), IsActivated(), Set(), SetEncryptedPassword(), and SetPassword().

Here is the caller graph for this function:

Member Data Documentation

User::$DB
protected

Definition at line 1078 of file User.php.

Referenced by SPTUser\DecryptPassword(), and SPTUser\GetCryptKey().

User::$LoggedIn
protected

Definition at line 1081 of file User.php.

Referenced by IsLoggedIn().

User::$Result
protected
User::$UserId = NULL
protected

Definition at line 1079 of file User.php.

Referenced by __construct(), Id(), and Login().

const User::PW_REQUIRE_DIGITS = 4

Definition at line 53 of file User.php.

const User::PW_REQUIRE_MIXEDCASE = 2

Definition at line 52 of file User.php.

const User::PW_REQUIRE_PUNCTUATION = 1

Definition at line 51 of file User.php.


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