inc\classes\User.phpView Source

Show: PublicProtectedPrivateinherited
Table of Contents
User object

Getting, registrating

Author
Sergey Dilong  
License
GPL-2.0  
Package
Temply-Account\Objects  

\User

Package: Temply-Account\Objects
User class

OOP based object to control all connected with User

Author
Sergey Dilong  
License
GPL-2.0  

Properties

>VPropertyprivatearray $data = array()

User data

Default valuearray()Details
Type
array
See
Access this field outside the class  
>VPropertyprivateinteger $id = 0

User ID

Default value0Details
Type
integer
See
Access this field outside the class  

Methods

methodpublicClassesToData(array<mixed,\User> $q, boolean $no_false = true) : \(array | array<mixed,\bool)> | void
static

Classes to Data

Extracts data from User classes

Parameters
NameTypeDescription
$qarray<mixed,\User>

Query

$no_falseboolean

If true - Return errors as false objects

Returns
TypeDescription
\(array | array<mixed,\bool)> | voidResult
Details
See
How data generates  
methodpublicClassesToIds(array<mixed,\User> $q) : array<mixed,integer>
static

Classes to IDs

Converts array of classes to array of IDs

Parameters
NameTypeDescription
$qarray<mixed,\User>

Users array

Returns
TypeDescription
array<mixed,integer>Result
methodpublicIdsToClasses(array<mixed,integer> $q, boolean $no_false = true, array $o = array()) : array<mixed,\User>
static

IDs to Classes

Converts array of IDs to array of classes

Parameters
NameTypeDescription
$qarray<mixed,integer>

IDs array

$no_falseboolean

If true - Return errors as false objects

$oarray

Options for User object

Returns
TypeDescription
array<mixed,\User>Result
Details
See
How user inits  
methodprivateInitByLogin(string $a, array $o = array()) : boolean

Init By login

Find user in DB by login and inits by ID

Parameters
NameTypeDescription
$astring

Login

$oarray

Options

Returns
TypeDescription
booleanIf `true` - success
Throws
ExceptionDescription
\apiException* [101] Login not found
Details
See
How user inits  
methodprivateInitUser(integer $id, array $o = array()) : boolean

Init user

Init user by ID

Parameters
NameTypeDescription
$idinteger

ID

$oarray

Options

  • U_GET [bool] - apply user-defined rules for displaying User object
  • CUSTOM_FIELDS [string] - force own rules to display the object
  • GET_UNSECURE_DATA [bool] - Gets data such as user password in __protect key
Returns
TypeDescription
booleanIf `true` - success
Throws
ExceptionDescription
\apiException* [105] ID not found
Details
See
Call this function outside the class  
See
Change options of already inited instance  
methodpublicReInitUser( $o = array()) : array

Re-Init user

Change options of already inited object

Parameters
NameTypeDescription
$o

New options

Returns
TypeDescription
arrayNew data (self::data)
Throws
ExceptionDescription
\apiException* [105] ID not found
methodprivateSignUp(array $d) : boolean

Sign Up

This function registers REAL user and calls Init method

Parameters
NameTypeDescription
$darray

Data

  • signup_data [array]
    • name* - User's name (Length MIN/MAX: 1/15)
    • login* - User's login. It must start with a letter, contain only English letters and numbers of any register. (Length MIN/MAX: 5/16)
    • password* - User's password (Length MIN/MAX: 8/200)
    • surname - User's surname (Length MIN/MAX: 0/15)
Returns
TypeDescription
booleanIf `true` - success
Throws
ExceptionDescription
\apiException* [200] DB error * [201] Unfilled required data * [202] Incorrect name * [203] Password is too long * [204] Incorrect login
Details
See
Call this method outside the class  
methodpublic__construct(integer | string $query = 0, array $o = array()) : void

Router

Get or register User

Parameters
NameTypeDescription
$queryinteger | string

Query

  • string - new user (If === SIGN_UP_MODE && $o[signup_proof])
  • integer - get a message
$oarray

Options

  • GET_MODE [string]
    • login - get by login
    • id - get by id
  • SIGN_UP_MODE [bool] - Register new user
Throws
ExceptionDescription
\apiException* [101] Login not found * [105] ID not found * [200] DB error * [201] Unfilled required data * [202] Incorrect name * [203] Password is too long * [204] Incorrect login
Details
See
Change options of already inited instance  
methodpublicget() : array

Get User data

Get all inited User's data

Returns
TypeDescription
arrayIf array length = 0 - init error
Details
See
Update or set new fields in data  
Uses
to get all the data  
methodpublicgetID() : integer

Get ID

Get User's ID

Returns
TypeDescription
integerIf === `0` - Undefined user
Details
Uses
to get ID  
Documentation was generated by phpDocumentor v2.9.0.