CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
User Class Reference
Inheritance diagram for User:
[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)
| 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
| $Status

## 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 | $OldPassword | Current password.
  string | $NewPassword | Password to set.
  string | $NewPasswordAgain | Confirm new password.

Returns
  U_OKAY on success, a different L_ constant on fail

Definition at line 516 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 | $Password | Password to check.
  string | $UserName | Username to check (OPTIONAL)
  string | $Email | Email to check (OPTIONAL)

Returns
  array of problems or empty array on success.

Definition at line 1028 of file User.php.

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

User::Delete | ( |  | ) |

Definition at line 189 of file User.php.

References $Result, and U_OKAY.

User::Get | ( |  | $FieldName | ) |

Definition at line 276 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 578 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 948 of file User.php.

References $Result.

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

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 232 of file User.php.

References Get().

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

Definition at line 285 of file User.php.

User::GetMailChangeCode | ( |  | ) |

Definition at line 614 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 1186 of file User.php.

Referenced by UserEditingUI\GetRequestAccountForm().

Here is the caller graph for this function:

User::GetPasswordSalt | ( |  | $UserName | ) |

Definition at line 433 of file User.php.

References $Result.

User::GetPrivList | ( |  | ) |

Definition at line 914 of file User.php.

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

Definition at line 1131 of file User.php.

User::GetResetCode | ( |  | ) |

Definition at line 599 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 | $Privilege | Privilege or array of privileges.
  mixed | $Privileges | One or more additional privileges. (variable length argument list) (OPTIONAL)

Returns
  SQL query to retrieve user IDs.

Definition at line 829 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 | $Privilege | Privilege or array of privileges.
  mixed | $Privileges | One or more additional privileges. (variable length argument list) (OPTIONAL)

Returns
  SQL query to retrieve user IDs.

Definition at line 786 of file User.php.

static User::GetStatusMessageForCode | ( |  | $StatusCode | ) |
| static

Get text error message for a specified error code.

Parameters

  int | $StatusCode | One 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 975 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 1149 of file User.php.

References GrantPriv().

User::GrantPriv | ( |  | $Privilege | ) |

Definition at line 864 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 | $Privilege | Privilege or array of privileges.
  mixed | $Privileges | One 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 730 of file User.php.

User::Id | ( |  | ) |

Definition at line 218 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 593 of file User.php.

References UpdateValue().

User::IsActivationCodeGood | ( |  | $Code | ) |

Definition at line 586 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 500 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 474 of file User.php.

References $LoggedIn.

Referenced by CWUser\HasPriv(), IsNotLoggedIn(), and Logout().

Here is the caller graph for this function:

User::IsMailChangeCodeGood | ( |  | $Code | ) |

Definition at line 622 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 491 of file User.php.

References IsLoggedIn().

User::IsResetCodeGood | ( |  | $Code | ) |

Definition at line 607 of file User.php.

References GetResetCode().

static User::IsValidLookingEMailAddress | ( |  | $EMail | ) |
| static

Definition at line 1099 of file User.php.

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

Definition at line 1011 of file User.php.

static User::IsValidUserName | ( |  | $UserName | ) |
| static

Definition at line 1001 of file User.php.

User::LastActiveDate | ( |  | ) |

Definition at line 266 of file User.php.

References Get().

User::LastIPAddress | ( |  | ) |

Definition at line 270 of file User.php.

References Get().

User::LastLocation | ( |  | $NewLocation = `NULL` | ) |

Definition at line 246 of file User.php.

References Get().

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

Definition at line 328 of file User.php.

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

User::Logout | ( |  | ) |

Definition at line 415 of file User.php.

References IsLoggedIn().

User::Name | ( |  | ) |

Definition at line 222 of file User.php.

References Get().

static User::NormalizeEMailAddress | ( |  | $EMailAddress | ) |
| static

Definition at line 1113 of file User.php.

static User::NormalizePassword | ( |  | $Password | ) |
| static

Definition at line 1125 of file User.php.

static User::NormalizeUserName | ( |  | $UserName | ) |
| static

Definition at line 1119 of file User.php.

User::RevokePriv | ( |  | $Privilege | ) |

Definition at line 899 of file User.php.

References $Result, U_NOTLOGGEDIN, and U_OKAY.

User::SendEMail | ( |  | $TemplateTextOrFileName,
|  |  | $FromAddress = `NULL`,
|  |  | $MoreSubstitutions = `NULL`,
|  |  | $ToAddress = `NULL`
| ) |  |

Definition at line 629 of file User.php.

References $Result, $Status, Get(), GetActivationCode(), GetMailChangeCode(), GetResetCode(), Status(), U_MAILINGERROR, U_OKAY, and U_TEMPLATENOTFOUND.

User::Set | ( |  | $FieldName,
|  |  | $NewValue
| ) |  |

Definition at line 308 of file User.php.

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

Referenced by 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 | $NewValue | Callable email function or method that accepts the same arguments as mail().

Definition at line 208 of file User.php.

Referenced by CWUser\__construct().

Here is the caller graph for this function:

User::SetEncryptedPassword | ( |  | $NewEncryptedPassword | ) |

Definition at line 571 of file User.php.

References UpdateValue().

User::SetPassword | ( |  | $NewPassword | ) |

Definition at line 561 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 | $NewValue | New minimum length.

Definition at line 1168 of file User.php.

static User::SetPasswordMinUniqueChars | ( |  | $NewValue | ) |
| static

Set password minimum unique characters.

Parameters

  int | $NewValue | New number of required unique characters.

Definition at line 1177 of file User.php.

static User::SetPasswordRules | ( |  | $NewValue | ) |
| static

Set password requirements.

Parameters

  int | $NewValue | New password rules as a bitmask of PW_* constants.

Definition at line 1159 of file User.php.

User::SetPrivList | ( |  | $NewPrivileges | ) |

Definition at line 925 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 1142 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 988 of file User.php.

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

User::$LoggedIn
| protected

Definition at line 991 of file User.php.

Referenced by IsLoggedIn().

User::$Result
| protected

Definition at line 990 of file User.php.

Referenced by ChangePassword(), Delete(), CWUser\EmailWrapper(), GetAnonymousUser(), GetPasswordSalt(), GrantPriv(), CWUser\Login(), Login(), RevokePriv(), SendEMail(), Set(), CWUser\Set(), and Status().

User::$Status
| protected

Definition at line 992 of file User.php.

Referenced by SendEMail().

User::$UserId = NULL
| protected

Definition at line 989 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:

- lib/ScoutLib/User.php