User
extends Entity
in package
Uses
WithDatabase
User class
This class maps the users and users_openid tables.
It also provides helper methods to check if a login is available, or to retrieve a username from e-mail address.
Table of Contents
Properties
- $active : mixed
- $actkey : string
- $email : mixed
- $hashtable_id : mixed
- $hashtable_name : mixed
- $id : mixed
- $lastError : string
- $name : mixed
- $password : mixed
- $regdate : mixed
- $session : array<string|int, mixed>
- $db : DatabaseEngine
Methods
- __construct() : mixed
- Initializes a new instance
- delete_OpenID() : mixed
- Deletes OpenID for this user
- generate_id() : mixed
- Generates a unique user id
- get() : User
- Initializes a new User instance if needed or get already available one.
- get_username_from_email() : string|bool
- Gets username from specified e-mail
- getDatabase() : DatabaseEngine
- is_available_login() : bool
- Checks if a login is available
- load_from_database() : bool
- Loads the object User (ie fill the properties) from the database
- load_from_form() : mixed
- Loads the object User (ie fill the properties) from the $_POST array
- save_field() : mixed
- Updates the specified field in the database record
- save_to_database() : void
- Saves to database
- set_OpenID() : mixed
- Sets OpenID for this user
- set_password() : mixed
- Fills password field with encrypted version of the specified clear password
- setDatabase() : void
Properties
$active
public
mixed
$active
= 0
$actkey
public
string
$actkey
= ""
public
mixed
$email
$hashtable_id
public
static mixed
$hashtable_id
= []
$hashtable_name
public
static mixed
$hashtable_name
= []
$id
public
mixed
$id
$lastError
public
string
$lastError
= ""
$name
public
mixed
$name
$password
public
mixed
$password
$regdate
public
mixed
$regdate
$session
public
array<string|int, mixed>
$session
= []
$db
private
DatabaseEngine
$db
Methods
__construct()
Initializes a new instance
public
__construct(DatabaseEngine $db[, int $id = null ]) : mixed
Parameters
- $db : DatabaseEngine
- $id : int = null
-
the primary key
delete_OpenID()
Deletes OpenID for this user
public
delete_OpenID() : mixed
generate_id()
Generates a unique user id
public
generate_id() : mixed
get()
Initializes a new User instance if needed or get already available one.
public
static get(DatabaseEngine $db[, mixed $data = null ]) : User
Parameters
- $db : DatabaseEngine
- $data : mixed = null
-
user ID or name
Return values
User —the user instance
get_username_from_email()
Gets username from specified e-mail
public
static get_username_from_email(DatabaseEngine $db, string $mail) : string|bool
Parameters
- $db : DatabaseEngine
- $mail : string
-
the mail to search
Return values
string|bool —the username matching the mail if found ; otherwise, false.
getDatabase()
public
getDatabase() : DatabaseEngine
Return values
DatabaseEngineis_available_login()
Checks if a login is available
public
static is_available_login(DatabaseEngine $db, string $login) : bool
Parameters
- $db : DatabaseEngine
- $login : string
-
the login to check
Return values
bool —true if the specified login is available ; otherwise, false.
load_from_database()
Loads the object User (ie fill the properties) from the database
public
load_from_database() : bool
Return values
boolload_from_form()
Loads the object User (ie fill the properties) from the $_POST array
public
load_from_form() : mixed
save_field()
Updates the specified field in the database record
public
save_field(mixed $field) : mixed
Parameters
- $field : mixed
save_to_database()
Saves to database
public
save_to_database() : void
set_OpenID()
Sets OpenID for this user
public
set_OpenID(string $url) : mixed
Parameters
- $url : string
-
OpenID endpoint URL
set_password()
Fills password field with encrypted version of the specified clear password
public
set_password(string $newpassword) : mixed
Parameters
- $newpassword : string
-
The user's new password
setDatabase()
public
setDatabase(DatabaseEngine $db) : void
Parameters
- $db : DatabaseEngine