User
in package
The User class holds information about the user
Table of Contents
- $execUserId : int
- $fields : array<string|int, mixed>
- $isLoggedIn : bool
- $language : array<string|int, mixed>
- $userId : int
- $booter : z_framework
- $permissions : array<string|int, string>
- $sessionToken : string|null
- __construct() : mixed
- Creates a new user object
- checkPermission() : bool
- Checks if a user has a given permission
- getSessionToken() : string|null
- identify() : mixed
- Checks if the user is registered. Checks by the z_login_token cookie.
- anonymousRequest() : mixed
- chooseNonLoginLanguage() : mixed
Properties
$execUserId
public
int
$execUserId
=
ull
ID of the user that is logged in as this user.
Null represents an anonymous user
$fields
public
array<string|int, mixed>
$fields
= []
Holds the dataset from the database of this user
$isLoggedIn
public
bool
$isLoggedIn
= alse
Holds if the user is logged in
$language
public
array<string|int, mixed>
$language
= []
Holds information about the language of the user.
Array with the keys "id" and "value".
$userId
public
int
$userId
=
ull
ID of the user in the database.
Null represents an anonymous user
$booter
private
z_framework
$booter
Holds a reference to the booter
$permissions
private
array<string|int, string>
$permissions
Array of permissions the user has.
$sessionToken
private
string|null
$sessionToken
=
ull
The token used to authenticate the current session
Methods
__construct()
Creates a new user object
public
__construct(z_framework $booter) : mixed
Parameters
- $booter : z_framework
-
The booter object
Return values
mixed —checkPermission()
Checks if a user has a given permission
public
checkPermission(string $permission) : bool
Parameters
- $permission : string
-
Name of the permission
Return values
bool —True when the permission is given
getSessionToken()
public
getSessionToken() : string|null
Return values
string|null —identify()
Checks if the user is registered. Checks by the z_login_token cookie.
public
identify() : mixed
The properties $isLoggedIn, $userId, and $execUserId will be set after calling this function.
Return values
mixed —anonymousRequest()
private
anonymousRequest() : mixed
Return values
mixed —chooseNonLoginLanguage()
private
chooseNonLoginLanguage() : mixed