Class to manipulate and authenticate users. All details of user management, including checking authentication, should be done through this class.
public function exists( |
| ) |
Determines if the object represents an existing, registered user.
True if the user exists, false otherwise.
public function profileUrl( |
| ) |
Get the URL to the user's profile page.
url | The new value to set. If missing, just return current value. |
Get the configured or default URL for the user's profile.
public function exportVars( |
| ) |
Convenience function to export relevant user data to a template. Sets the username, full name, e-mail, homepage, and display name in template variables USER_ID, USER_NAME, USER_EMAIL, USER_HOMEPAGE, and USER_DISPLAY_NAME respectively.
tpl | The template to put the data in, passed by reference. |
private function checkPassword( |
| ) |
Checks if a password is valid for the current user.
pass | The password to check. |
True if the password is correct, false owtherwise.
Create a passoword reset code for the user.
String containing the reset code.
public function verifyPasswordReset( |
| ) |
Checks that a supplied password reset code is valid.
code | String containing the reset code to validate |
True if the code is acceptable, false otherwise.
public function invalidatePasswordReset( |
| ) |
Deletes the record of a particular password reset code. This is intended to be called after a code is used successfully.
code | String containing the code to invalidate. |
Save changes to user data.
True if the changes were successfully saved, false otherwise.
public function password( |
| ) |
Set or return the user's password>
pwd | Optional password to set. |
If pwd is false, return the user's password hash. Otherwise, a new password is set and there is no return value.
public function username( |
| ) |
Set or return the username.
uid | Optional username to set. |
The username if uid is false, otherwise the username is set and there is no return value.
public function name( |
| ) |
Set or return the user's long name.
nm | Optional name to set. |
The user's full name if nm is false, otherwise the name is set and there is no return value.
Returns a name to display. If a full name is defined, it uses that. Otherwise, it reverts to the username.
A string contianing either the username or full name.
public function email( |
| ) |
Set or return the user's e-mail address.
Optional e-mail to set. |
The user's e-mail address if mail is false, otherwise the address is set and there is no return value.
public function homepage( |
| ) |
Set or return the user's homepage.
url | Optional URL to set as the homepage. |
The user's homepage URL if url is false, otherwise the homepage is set and there is no return value.
public function addToGroup( |
| ) |
Adds the user to the specified group.
groupname | The name of the group. |
True on success, false on failure.
public function login( |
| ) |
Logs the user in. Note that there are two login methods available, with the one used being determined by the AUTH_USE_SESSION configuration constant.
pwd | The password used to log in. |
time | Current time, injectable for testing purposes. |
False if the authentication fails, true otherwise.
Logs the user out and destroys login tokens. Note that this is also subject to AUTH_USE_SESSION
public function checkLogin( |
| ) |
Checks tokens to determine if the user is logged in.
uname | Optional username to check. |
True if the user has valid login tokens, false otherwise.
Determines if the user is the system administrator.
True if the username is the same as that of the system administrator, false otherwise. Note that the system administrator's username is controlled by the ADMIN_USER configuration constant.
public function enableCookies( |
| ) |
Used primarily for testing, sets whether cookies actually get set.
Load the user's password and any metadata.