Class user

Description

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 36)


	
			
Direct descendents
Class Description
 class 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.
 class 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.
Variable Summary
 mixed $auth_code
 mixed $email
 mixed $enabled
 mixed $group_info
 mixed $group_names
 mixed $hasgroups
 mixed $hasIPlist
 mixed $IP
 mixed $name
 mixed $password
 mixed $userid
 mixed $user_record
 mixed $user_type
 mixed $valid
Method Summary
 user user ([string $userid = ""])
 integer authenticate (string $authid, [string $password = ""])
 integer authenticate_authid (string $authid)
 integer authenticate_ipaddress (string $ip)
 integer authenticate_userid (string $userid, [string $password = ""])
 string friendlyName ()
 string get_auth_code ()
 string get_groups ()
 bool get_user_by_auth_code (string $auth_code)
 bool get_user_by_id (string $userid)
 bool get_user_by_ip (string $ip)
 string group_ids_list ([string $delim = ","])
 string group_names_list ([string $delim = ","])
 bool ismemberof_group (string $groupname)
 bool ismemberof_group_in (mixed $groupnames_list)
 bool ismemberof_group_with_id (string $groupid)
 bool isvalid ()
 void set_encrypted_passwords ([string $mode = true])
 void set_password (string $plainpass)
Variables
mixed $auth_code = "" (line 42)

Optional authorisation hash code

mixed $email = "" (line 50)

User e-mail address

mixed $enabled = false (line 54)

True of user is active/enabled

mixed $encrypted_passwords = false (line 48)

Password encryption flag

mixed $group_info (line 64)

Group membership details in full, as associative array

mixed $group_names = array() (line 62)

Array of group membership names (strings)

mixed $hasgroups = false (line 60)

True if user has a group membership

mixed $hasIPlist = false (line 72)

Flag, true if user has auto-login IP addresses

mixed $IP (line 70)

List of IP addresses this user will be auto-logged-in from.

mixed $limit_logins = 0 (line 58)

Limit of logins allowed (0=unlimited)

mixed $name = "" (line 44)

Full name

mixed $password = "" (line 46)

Text password (encrypted or plain)

mixed $total_logins = 0 (line 56)

Total logins so far

mixed $userid = "" (line 38)

Login user id, string

mixed $user_groups_cnt = 0 (line 66)

Group membership count

mixed $user_record (line 68)

Complete user record as an associative array

mixed $user_type = "" (line 52)

User type: arbitrary textual type

mixed $valid = false (line 40)

True if user record is valid

Methods
Constructor user (line 79)

Constructor Create a new user object.

user user ([string $userid = ""])
  • string $userid: User ID of the user
authenticate (line 138)

Authenticate a user Tries all types of authentication we know about using the parameters passed to it.

  • return: Login type code
integer authenticate (string $authid, [string $password = ""])
  • string $authid: Unique user ID, authorization code or IP
  • string $password: Password for the user
authenticate_authid (line 223)

Authenticate a user by authorisation ID

  • return: Login type code
integer authenticate_authid (string $authid)
  • string $authid: Authorisation code/id of the user
authenticate_ipaddress (line 201)

Authenticate a user by IP address

  • return: Login type code
integer authenticate_ipaddress (string $ip)
  • string $ip: IP address of remote host accessing this site
authenticate_userid (line 155)

Authenticate a user by userid/password.

  • return: Login type code
integer authenticate_userid (string $userid, [string $password = ""])
  • string $userid: Unique user ID of the user
  • string $password: Password for the user
friendlyName (line 550)

Get friendly name

Make a 'friendly' name from a full one. Good for "Dear... ,"

  • return: Friendly name for the current user
string friendlyName ()
get_auth_code (line 343)

Get user Authorisation Code Return this user's unique authorisation code; generate one if it isn't there yet, from userid and current time.

  • return: The authorisation code for the current user
string get_auth_code ()
get_groups (line 367)

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

  • return: The groups list for the user, delimited by pipe ("|")
string get_groups ()
get_user_by_auth_code (line 268)

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.

  • return: True if the user was found with the given authorisation code
bool get_user_by_auth_code (string $auth_code)
  • string $auth_code: Authorisation code to match for this user
get_user_by_id (line 246)

Get user by ID Internal function to return the user record from id.

  • return: True if the user was found with the given user ID
bool get_user_by_id (string $userid)
  • string $userid: Unique user ID
get_user_by_ip (line 289)

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.

  • return: True if a user was found with matching IP address
bool get_user_by_ip (string $ip)
  • string $ip: Allowed IP host or network to allow logins from
group_ids_list (line 512)

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.

  • return: List of group ID's comma-delimited
string group_ids_list ([string $delim = ","])
  • string $delim: Delimiter character (defaults to comma)
group_names_list (line 532)

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"

  • return: List of group name's comma-delimited
string group_names_list ([string $delim = ","])
  • string $delim: Delimiter character (defaults to comma)
ismemberof_group (line 439)

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.

  • return: True if the user is a member of the group, else false
bool ismemberof_group (string $groupname)
  • string $groupname: Name of the group we are checking user membership of
ismemberof_group_in (line 458)

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.

  • return: True if user is member of at least one of the groups, else false
bool ismemberof_group_in (mixed $groupnames_list)
  • mixed $groupnames_list: Comma-delimited list OR array of group names
ismemberof_group_with_id (line 485)

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 user is a member of the group, else false
bool ismemberof_group_with_id (string $groupid)
  • string $groupid: ID of the group we are checking user membership of
isvalid (line 498)

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.

  • return: True if the current user object is valid
bool isvalid ()
set_encrypted_passwords (line 110)

Set the password encryption flag. If passed in true, then we will be assuming that new passwords should be encrypted, and password checks will try encryption first, then fall back to basic.

void set_encrypted_passwords ([string $mode = true])
  • string $mode: True if we are encrypting passwords, else false
set_password (line 121)

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.

void set_password (string $plainpass)
  • string $plainpass: Plain text password to set for this user $return string The password which is going to be stored

Documentation generated by phpDocumentor 1.3.0RC3