The 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 |
---|---|
![]() |
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. |
![]() |
The Authorised User class This derived class just allows us a different way of defining a new user, when we know their authorisation code. |
User authentication method
Optional authorisation hash code
User e-mail address
True of user is active/enabled
First name of the person
Group membership details in full, as associative array
Array of group membership names (strings)
True if user has a group membership
Flag, true if user has auto-login IP addresses
Honorific prefix Eg. 'Mr.', 'Ms.', 'Mrs.' etc.
List of IP addresses this user will be auto-logged-in from.
Last name of the person
Limit of logins allowed (0=unlimited)
Flag, true if this user account is locked
Middle names or initials of the person
Formatted full display name of the person
Security profile: if true, passwords must be mixture of alpha & numeric
Security profile: if true, passwords must not match built-in stopword list
Security profile: char uniqueness level - none, low, medium, or high
Security profile: delay in millisec after a password failure
Security profile: how passwords are encrypted:
'none', 'md5', 'md5salted', 'custom'
Security profile: no. of days a password lasts
Date-time that the password will expire at (Unix timestamp)
Number of consequetive password failures we have had
Flag, true if user password never expires
Array of previously used passwords
Security profile: password history cycle - number of saved passwords
Security profile: no. of consequetive password failures allowed
Security profile: min characters in a new password
Text password (encrypted or plain)
User authentication remote database name
User authentication remote table field mapping
User authentication source
User authentication remote user table
Total logins so far
Login user id, string
Group membership count
Complete user record as an associative array
User type: arbitrary textual type
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