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)
| 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 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 511 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 1114 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 593 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 580 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 572 of file User.php.

References CreateNewUserAndMailPasswordFromFile().

User::Delete | ( |  | ) |

Definition at line 191 of file User.php.

References $Result, and U_OKAY.

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

Definition at line 278 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 664 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 1034 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 234 of file User.php.

References Get().

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

Definition at line 287 of file User.php.

User::GetMailChangeCode | ( |  | ) |

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

Referenced by UserEditingUI\GetRequestAccountForm().

Here is the caller graph for this function:

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

Definition at line 428 of file User.php.

References $Result.

User::GetPrivList | ( |  | ) |

Definition at line 1000 of file User.php.

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

Definition at line 1217 of file User.php.

Referenced by CreateNewUserAndMailPassword().

Here is the caller graph for this function:

User::GetResetCode | ( |  | ) |

Definition at line 685 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 915 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 872 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 136 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 1061 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 1235 of file User.php.

References GrantPriv().

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

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

User::Id | ( |  | ) |

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

References UpdateValue().

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

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

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 469 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 708 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 486 of file User.php.

References IsLoggedIn().

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

Definition at line 693 of file User.php.

References GetResetCode().

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

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

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

Definition at line 1084 of file User.php.

User::LastActiveDate | ( |  | ) |

Definition at line 268 of file User.php.

References Get().

User::LastIPAddress | ( |  | ) |

Definition at line 272 of file User.php.

References Get().

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

Definition at line 248 of file User.php.

References Get().

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

Definition at line 323 of file User.php.

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

User::Logout | ( |  | ) |

Definition at line 410 of file User.php.

References IsLoggedIn().

User::Name | ( |  | ) |

Definition at line 224 of file User.php.

References Get().

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

Definition at line 1199 of file User.php.

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

Definition at line 1211 of file User.php.

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

Definition at line 1205 of file User.php.

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

Definition at line 985 of file User.php.

References $Result, U_NOTLOGGEDIN, and U_OKAY.

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

Definition at line 715 of file User.php.

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

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

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

Definition at line 210 of file User.php.

Referenced by CWUser\__construct().

Here is the caller graph for this function:

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

Definition at line 566 of file User.php.

References UpdateValue().

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

Definition at line 556 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 1254 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 1263 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 1245 of file User.php.

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

Definition at line 1011 of file User.php.

References GrantPriv(), and U_NOTLOGGEDIN.

User::Status | ( |  | ) |

Definition at line 120 of file User.php.

References $Result.

Referenced by SendEMail().

Here is the caller graph for this function:

User::StatusMessage | ( |  | ) |

Definition at line 126 of file User.php.

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

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

Referenced by SPTUser\GetCryptKey().

User::$LoggedIn
| protected

Definition at line 1077 of file User.php.

Referenced by IsLoggedIn().

User::$Result
| protected

Definition at line 1076 of file User.php.

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

User::$UserId = NULL
| protected

Definition at line 1075 of file User.php.

Referenced by CWUser\FetchAssociatedResource(), 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/AxisPHP/User.php