RdbAdmin Module

UsersTrait

Users trait.

Tags
since
0.1

Table of Contents

Methods

addUpdateUserFormValidation()  : array<string|int, mixed>
Form validation for add and update user.
decryptUserFieldsKey()  : string
Decrypt user fields key.
generateUserFieldsKey()  : array<string|int, mixed>
Generate user fields key.
getUserUrlsMethods()  : array<string|int, mixed>
Get URLs and methods about user pages.
logoutUser()  : mixed
Logout target user.

Methods

addUpdateUserFormValidation()

Form validation for add and update user.

protected addUpdateUserFormValidation(array<string|int, mixed> $data[, array<string|int, mixed> $dataField = [] ][, array<string|int, mixed> $dataUsersRoles = [] ][, string $saveType = 'insert' ][, string|int $user_id = '' ]) : array<string|int, mixed>

Validate required and valid form fields.
Validate that selected roles did not have higher priority that the user who add or update them.
Validate username and email must not exists.
This method was called from doAddAction() method.

Parameters
$data : array<string|int, mixed>

The associative array form data.

$dataField : array<string|int, mixed> = []

Associative array for user_fields table.

$dataUsersRoles : array<string|int, mixed> = []

Associative array for users_roles table.

$saveType : string = 'insert'

Type of saving data. It can be 'insert' or 'update'. Default is 'insert'.

$user_id : string|int = ''

The user_id to check where $saveType is 'update' that any user else data must be unique.

Return values
array<string|int, mixed>

Return associative array with keys if contain at least one error:
formResultStatus (if error),
formResultMessage (if error) The result message,
formFieldsValidation (optional) Fields that contain errors,
responseStatus (optional) For HTTP response status,

decryptUserFieldsKey()

Decrypt user fields key.

protected decryptUserFieldsKey(string|object $encryptedKey) : string
Parameters
$encryptedKey : string|object

The encrypted key string. Or you may set user_fields object from PDO query instead.

Return values
string

Return decrypted key string or return empty string if failed to decrypted.

generateUserFieldsKey()

Generate user fields key.

protected generateUserFieldsKey([int $length = 8 ]) : array<string|int, mixed>

Generate keys that can be use in change email confirmation, register confirmation, etc.

Parameters
$length : int = 8

The length of key.

Return values
array<string|int, mixed>

Return associative array with 'readableKey', 'encryptedKey' keys.

getUserUrlsMethods()

Get URLs and methods about user pages.

protected getUserUrlsMethods([string $user_id = '' ]) : array<string|int, mixed>
Parameters
$user_id : string = ''

The user ID.

Return values
array<string|int, mixed>

Return associative array.

logoutUser()

Logout target user.

protected logoutUser([array<string|int, mixed> $cookieData = [] ][, bool $logoutAllDevice = false ]) : mixed
Parameters
$cookieData : array<string|int, mixed> = []

The associative array of cookie data. This value can get from Cookie class. The array keys are:
user_id (required).
sessionKey (optional) For delete specific session key from user_logins table.

$logoutAllDevice : bool = false

Set to true to logout all device, false for specific session key.


        
On this page

Search results