\User

User class

OOP based object to control all connected with User

Summary

Methods
Properties
Constants
__construct()
ReInitUser()
getID()
get()
ClassesToIds()
IdsToClasses()
ClassesToData()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
InitUser()
SignUp()
InitByLogin()
$id
$data
N/A

Properties

$id

$id : integer

Type

integer — User ID

$data

$data : array

Type

array — User data

Methods

__construct()

__construct(integer|string  $query, array  $o = array()) 

Router

Get or register User

Parameters

integer|string $query

Query

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

Options

  • GET_MODE [string]
    • login - get by login
    • id - get by id
  • SIGN_UP_MODE [bool] - Register new user

Throws

\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

ReInitUser()

ReInitUser(  $o = array()) : array

Re-Init user

Change options of already inited object

Parameters

$o

New options

Throws

\apiException
  • [105] ID not found

Returns

array —

New data (self::data)

getID()

getID() : integer

Get ID

Get User's ID

Returns

integer —

If === 0 - Undefined user

get()

get() : array

Get User data

Get all inited User's data

Returns

array —

If array length = 0 - init error

ClassesToIds()

ClassesToIds(array<mixed,\User>  $q) : array<mixed,integer>

Classes to IDs

Converts array of classes to array of IDs

Parameters

array<mixed,\User> $q

Users array

Returns

array<mixed,integer> —

Result

IdsToClasses()

IdsToClasses(array<mixed,integer>  $q, boolean  $no_false = true, array  $o = array()) : array<mixed,\User>

IDs to Classes

Converts array of IDs to array of classes

Parameters

array<mixed,integer> $q

IDs array

boolean $no_false

If true - Return errors as false objects

array $o

Options for User object

Returns

array<mixed,\User> —

Result

ClassesToData()

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

Classes to Data

Extracts data from User classes

Parameters

array<mixed,\User> $q

Query

boolean $no_false

If true - Return errors as false objects

Returns

\(array|array<mixed,\bool)>|void —

Result

InitUser()

InitUser(integer  $id, array  $o = array()) : boolean

Init user

Init user by ID

Parameters

integer $id

ID

array $o

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

Throws

\apiException
  • [105] ID not found

Returns

boolean —

If true - success

SignUp()

SignUp(array  $d) : boolean

Sign Up

This function registers REAL user and calls Init method

Parameters

array $d

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)

Throws

\apiException
  • [200] DB error
  • [201] Unfilled required data
  • [202] Incorrect name
  • [203] Password is too long
  • [204] Incorrect login

Returns

boolean —

If true - success

InitByLogin()

InitByLogin(string  $a, array  $o = array()) : boolean

Init By login

Find user in DB by login and inits by ID

Parameters

string $a

Login

array $o

Options

Throws

\apiException
  • [101] Login not found

Returns

boolean —

If true - success