userThe user class This class managed users. It pre-supposes a particular database structure based on three tables: uuser, ugroup, and uuser_group.
Please see the example schemas for Phplib for further details.
Located in /user-defs.php (line 46)
| Class | Description |
|---|---|
session
|
THE SESSION CLASS A class to manage user sessions. A session is simply a thing which contains information about a user who has logged on to the system, so in fact the session is just an extension of a user. |
authorised_user
|
The Authorised User class This derived class just allows us a different way of defining a new user, when we know their authorisation code. |
void
set_remote_authentication
(mixed $auth_source, [integer $auth_method = "md5"], [string $auth_dbname = ""], [string $auth_tablename = ""], [array $auth_mappings = false])
void
set_security_profile
([string $encryption = "md5"], integer $expiry_days, integer $max_attempts, boolean $history_cycle, integer $delay_ms, integer $min_chars, [boolean $char_uniqueness = "low"], [boolean $alphanum_mixed = false], [boolean $apply_stopwords = false])
mixed
$authentication_method
= "md5" (line 121)
User authentication method
mixed
$auth_code
= "" (line 52)
Optional authorisation hash code
mixed
$email
= "" (line 66)
User e-mail address
mixed
$enabled
= false (line 70)
True of user is active/enabled
mixed
$first_name
= "" (line 58)
First name of the person
mixed
$group_info
(line 80)
Group membership details in full, as associative array
mixed
$group_names
= array() (line 78)
Array of group membership names (strings)
mixed
$hasgroups
= false (line 76)
True if user has a group membership
mixed
$hasIPlist
= false (line 88)
Flag, true if user has auto-login IP addresses
mixed
$honorific_prefix
= "" (line 56)
Honorific prefix Eg. 'Mr.', 'Ms.', 'Mrs.' etc.
mixed
$IP
(line 86)
List of IP addresses this user will be auto-logged-in from.
mixed
$last_name
= "" (line 62)
Last name of the person
mixed
$limit_logins
= 0 (line 74)
Limit of logins allowed (0=unlimited)
mixed
$locked
(line 98)
Flag, true if this user account is locked
mixed
$mid_names
= "" (line 60)
Middle names or initials of the person
mixed
$name
= "" (line 54)
Formatted full display name of the person
mixed
$passwd_alphanum_mixed
= false (line 113)
Security profile: if true, passwords must be mixture of alpha & numeric
mixed
$passwd_apply_stopwords
= false (line 115)
Security profile: if true, passwords must not match built-in stopword list
mixed
$passwd_char_uniqueness
= "medium" (line 111)
Security profile: char uniqueness level - none, low, medium, or high
mixed
$passwd_delay_ms
= 0 (line 107)
Security profile: delay in millisec after a password failure
mixed
$passwd_encryption
= "md5" (line 101)
Security profile: how passwords are encrypted:
'none', 'md5', 'md5salted', 'custom'
mixed
$passwd_expiry_days
= 90 (line 103)
Security profile: no. of days a password lasts
mixed
$passwd_expiry_ts
= 0 (line 92)
Date-time that the password will expire at (Unix timestamp)
mixed
$passwd_failures
= 0 (line 96)
Number of consequetive password failures we have had
mixed
$passwd_forever
= false (line 90)
Flag, true if user password never expires
mixed
$passwd_history
= array() (line 94)
Array of previously used passwords
mixed
$passwd_history_cycle
= 0 (line 117)
Security profile: password history cycle - number of saved passwords
mixed
$passwd_max_attempts
= 5 (line 105)
Security profile: no. of consequetive password failures allowed
mixed
$passwd_min_chars
= 6 (line 109)
Security profile: min characters in a new password
mixed
$password
= "" (line 64)
Text password (encrypted or plain)
mixed
$remote_auth_dbname
= NOT_MAPPED (line 123)
User authentication remote database name
mixed
$remote_auth_fields
= array() (line 127)
User authentication remote table field mapping
mixed
$remote_auth_source
= LOCAL_AUTH (line 119)
User authentication source
mixed
$remote_auth_tablename
= NOT_MAPPED (line 125)
User authentication remote user table
mixed
$total_logins
= 0 (line 72)
Total logins so far
mixed
$userid
= "" (line 48)
Login user id, string
mixed
$user_groups_cnt
= 0 (line 82)
Group membership count
mixed
$user_record
(line 84)
Complete user record as an associative array
mixed
$user_type
= "" (line 68)
User type: arbitrary textual type
mixed
$valid
= false (line 50)
True if user record is valid
Constructor Create a new user object.
Authenticate a user Tries all types of authentication we know about using the parameters passed to it.
Authenticate a user by authorisation ID
Authenticate a user by IP address
Authenticate a password according to the appropriate encryption regime.
The encryption method used depends on whether the user is a normal (local) Axyl user, or one which is being maintained on a remote system.
Authenticate a user by userid/password.
Get friendly name
Make a 'friendly' name from a full one. Good for "Dear... ,"
Generate a new password. Although we take note of whether the user is local or remote, in general we don't expect to be generating passwords for remotely maintained users.
Get user Authorisation Code Return this user's unique authorisation code; generate one if it isn't there yet, from userid and current time.
Get user groups info
For this user, populate the group data for this object. We read the uuser_group and ugroup tables and populate the two variables @see $user_groups and @see $group_info
Get user by Authorisation Code Internal function to return the user record from auth_code. The authorisation code is usually a string containing a complex key generated by something like MD5 or better.
Get user by ID Internal function to return the user record from id.
Get user by IP Internal function to return the user record which has IP address(es) which coincide with the client IP address being used for this access.
Get group IDs list
Return a string with the comma-delimited list of group ids which this user belongs to in it. This is useful for using in an SQL statement like: WHERE group_id IN (group_ids_list()) for example. Note we only access the database to populate $this->group_info when we need to, not every session.
Get group names list
Return a string with the comma-delimited list of group names which this user belongs to in it. Eg. "Editor,Author,Admin"
Is user a member of a named group. The argument passed in must be a single group name string (ie. not a numeric group id) which is defined in the database.
Return true if the user is a member of the named group.
Is user a member of one group of many Check user against a list of groups, return true if member of at least one of them. The list in $groupnames can be either a comma-delimited string of group names, OR an array of group names.
Is user a member of a group with ID Return true if the user is a member of the group with given ID.
Return true if the current user is a valid one. This is false when the user has not been authorised, or the user ID wasn't found etc. It is an error condition for this to be false.
Check whether the password for this user has expired. Returns true if it has, else false.
$return boolean True if this user has an expired password.
Push the current password on the history stack. Trim the history
to the number we are supposed to retain in the cycle. This method only does anything if 'passwd_cycle_history' is non-zero. It also checks and makes sure that the password isn't already in the history array, and if it is, does nothing.
Save the password data as stored in this object, to the user record.
$return boolean True if the data was saved ok.
Set the user login password. Store it according to the encryption mode. We assume a plain text password is being supplied.
NB: Axyl-encrypted passwords always have an 'axenc_' prefix.
Set the password expiry timestamp afresh. We use the settings for how long passwords should last, and add this to the time now to get the expiry datetime.
Set the user authentication method. This determines how we authenticate the user. Normally we just authenticate via the local database, but this method allows that to be varied for remotely maintained account details.
Set the user security profile. This is a bunch of parameters which will are applied to ALL users, including this one, when passwords are being set, created or otherwise checked.
Validate password against all the rules for it. Returns true if the password passed all the tests, else false. Also provides a resulting error message which is either a nullstring "", or an explanation of why the validation failed.
Documentation generated by phpDocumentor 1.3.0RC3