\Orpheus\EntityDescriptor\UserUser

A basic user class

The user class represents a basic user, you should never use this class, it was make for documentation.

Summary

Methods
Properties
Constants
__toString()
__wakeup()
onConnected()
isLogin()
login()
logout()
checkPerm()
checkAccess()
checkPermissions()
canAlter()
canDo()
userLogin()
listLoginFields()
userLogout()
httpLogin()
httpCreate()
httpAuthenticate()
hashPassword()
isLogged()
getLoggedUserID()
getLoggedUser()
load()
isAdmin()
loggedCanAccessToRoute()
loggedHasDeveloperAccess()
getAppRoles()
getUserRoles()
getRoleAccesslevel()
loggedCanDo()
checkForObject()
generatePassword()
getCreateTime()
validateValue()
putValue()
loadEntity()
init()
getEntityObject()
getEntityWhereclause()
getField()
getEntity()
registerEntity()
listKnownEntities()
selfInit()
set2Array()
setTo()
__construct()
__destruct()
__get()
__set()
__isset()
id()
uid()
update()
getUpdateOperation()
onValidUpdate()
extractUpdateQuery()
getDeleteOperation()
runForUpdate()
onEdit()
onValidateInput()
onSaved()
save()
checkIntegrity()
remove()
free()
reload()
isDeleted()
isValid()
markAsDeleted()
getValue()
setValue()
equals()
logEvent()
fillLogEvent()
getLogEvent()
object()
isFieldEditable()
get()
cacheObjects()
getCacheStats()
delete()
clearDeletedInstances()
clearInstances()
clearAllInstances()
escapeIdentifier()
ei()
formatValue()
fv()
formatValueList()
create()
getCreateOperation()
onValidCreate()
extractCreateQuery()
createAndGet()
completeFields()
getFields()
getClass()
getTable()
getIDField()
getDomain()
getValidator()
runForObject()
applyToObject()
checkUserInput()
testUserInput()
getClassData()
getSQLAdapter()
throwException()
throwNotFound()
text()
_text()
reportException()
No public properties found
NOT_LOGGED
IS_LOGGED
LOGGED_FORCED
parseFieldValue()
formatFieldValue()
addModFields()
listModifiedFields()
clearModifiedFields()
checkCache()
$table
$fields
$validator
$domain
$login
$editableFields
$entityClasses
$knownEntities
$IDFIELD
$instances
$DBInstance
$modFields
$data
$isDeleted
$onSavedInProgress
$knownClassData
N/A
No private methods found
No private properties found
N/A

Constants

NOT_LOGGED

NOT_LOGGED

IS_LOGGED

IS_LOGGED

LOGGED_FORCED

LOGGED_FORCED

Properties

$table

$table : string

The table

Type

string

$fields

$fields : array

The fields of this object

Type

array

$validator

$validator : array

The validator The default one is an array system.

Type

array

$domain

$domain : \Orpheus\EntityDescriptor\User\unknown

The domain of this class Used as default for translations.

Type

\Orpheus\EntityDescriptor\User\unknown

$login

$login : boolean

Is user logged ?

Type

boolean

$editableFields

$editableFields : array

Editable fields

Type

array

$entityClasses

$entityClasses : array

Entity classes

Type

array

$knownEntities

$knownEntities : array

Known entities

Type

array

$IDFIELD

$IDFIELD : string

The ID field

Type

string

$instances

$instances : array

Cache of all object instances

Type

array

$DBInstance

$DBInstance : string

DB instance

Use only to get SQL Adapter

Type

string

$modFields

$modFields : array

Currently modified fields

Type

array

$data

$data : array

The object's data

Type

array

$isDeleted

$isDeleted : boolean

Is this object deleted ?

Type

boolean

$onSavedInProgress

$onSavedInProgress : boolean

Is this object called onSaved ? It prevents recursive calls

Type

boolean

$knownClassData

$knownClassData : array

Store data about known classes

Type

array

Methods

__toString()

__toString() : \Orpheus\Publisher\PermanentObject\The

Magic toString

Returns

\Orpheus\Publisher\PermanentObject\The —

string value of the object.

The object's value when casting to string.

__wakeup()

__wakeup() 

Magic method when this object is unserialized

onConnected()

onConnected() 

Callback when user is connected

isLogin()

isLogin(string  $f = self::IS_LOGGED) : boolean

Gets the Log in status of this user in the current session.

Parameters

string $f

Returns

boolean —

True

login()

login(string  $force = false) 

Log in this user to the current session.

Parameters

string $force

logout()

logout(string  $reason = null) : boolean

Log out this user from the current session.

Parameters

string $reason

Returns

boolean

checkPerm()

checkPerm(integer|string  $right) : boolean

Check permissions

Parameters

integer|string $right

The right to compare, can be the right string to look for or an integer.

Returns

boolean —

True if this user has enough acess level.

Compare the accesslevel of this user to the incoming right. $right could be an int (accesslevel) or a string (right)

checkAccess()

checkAccess(string  $module) : boolean

Check access permissions

Parameters

string $module

The module to check

Returns

boolean —

True if this user has enough acess level to access to this module

checkPermissions()

checkPermissions(array  $input) 

Check if current logged user can edit this one

Parameters

array $input

The input

canAlter()

canAlter(\Orpheus\EntityDescriptor\User\AbstractUser  $user) : boolean

Check if this user can alter data on the given user

Parameters

\Orpheus\EntityDescriptor\User\AbstractUser $user

The user we want to edit

Returns

boolean —

True if this user has enough acess level to edit $user or he is altering himself

canDo()

canDo(string  $action, object  $object = null) : boolean

Check if this user can affect data on the given user

Parameters

string $action

The action to look for

object $object

The object we want to edit

Returns

boolean —

True if this user has enough access level to alter $object (or he is altering himself)

userLogin()

userLogin(array  $data, string  $loginField = 'email') : \Orpheus\SQLRequest\SQLSelectRequest|\Orpheus\EntityDescriptor\User\AbstractUser|array<mixed,\Orpheus\Publisher\PermanentObject\static>

Logs in an user using data

Parameters

array $data
string $loginField

Returns

\Orpheus\SQLRequest\SQLSelectRequest|\Orpheus\EntityDescriptor\User\AbstractUser|array<mixed,\Orpheus\Publisher\PermanentObject\static>

listLoginFields()

listLoginFields() : array<mixed,string>

List all available login fields

Returns

array<mixed,string>

userLogout()

userLogout() 

Log out current user

httpLogin()

httpLogin() 

Log in an user from HTTP authentication according to server variables PHP_AUTH_USER and PHP_AUTH_PW

httpAuthenticate()

httpAuthenticate() : boolean

Login from HTTP authentication, create user if not existing

Returns

boolean

hashPassword()

hashPassword(  $str) : \Orpheus\EntityDescriptor\User\The

Hash a password

Parameters

$str

The clear password.

Returns

\Orpheus\EntityDescriptor\User\The —

hashed string.

isLogged()

isLogged() : True

Check if the client is logged in

Returns

True —

if the current client is logged in

getLoggedUserID()

getLoggedUserID() : integer|string

Get ID if user is logged

Returns

integer|string —

The id of the current client logged in

Get the ID of the current user or 0.

getLoggedUser()

getLoggedUser() : \Orpheus\EntityDescriptor\User\AbstractUser

Get logged user object

Returns

\Orpheus\EntityDescriptor\User\AbstractUser

The user of the current client logged in

Get the user objectof the current logged client, or null.

load()

load(mixed|array<mixed,mixed>  $in, boolean  $nullable = true, boolean  $usingCache = true) : \Orpheus\Publisher\PermanentObject\PermanentObject

Load a permanent object

Parameters

mixed|array<mixed,mixed> $in

The object ID to load or a valid array of the object's data

boolean $nullable

True to silent errors row and return null

boolean $usingCache

True to cache load and set cache, false to not cache

Returns

\Orpheus\Publisher\PermanentObject\PermanentObject

The object

isAdmin()

isAdmin() : boolean

Check if this user has admin right

Returns

boolean —

True if this user is logged and is admin.

Checks if this user has admin access level. This is often used to determine if the current user can access to the admin panel.

loggedCanAccessToRoute()

loggedCanAccessToRoute(string  $route, integer  $accesslevel) : boolean

Check if this user can access to a module

Parameters

string $route

The route to look for

integer $accesslevel

The access level

Returns

boolean —

True if this user can access to $module

loggedHasDeveloperAccess()

loggedHasDeveloperAccess() : boolean

Check if this user has developer access

Returns

boolean —

True if this user has developer access

getAppRoles()

getAppRoles() : array

Get application roles

Returns

array

getUserRoles()

getUserRoles() : array

Get all user roles

Returns

array

getRoleAccesslevel()

getRoleAccesslevel(string  $role) : integer

Get acesslevel of a role

Parameters

string $role

Returns

integer

loggedCanDo()

loggedCanDo(string  $action, \Orpheus\EntityDescriptor\User\AbstractUser  $object = null) : boolean

Check if this user can do a restricted action

Parameters

string $action

The action to look for

\Orpheus\EntityDescriptor\User\AbstractUser $object

The object to edit if editing one or null. Default value is null

Returns

boolean —

True if this user can do this $action

checkForObject()

checkForObject(  $data,   $ref = null) 

Check for object

Parameters

$data

The new data to process.

$ref

The referenced object (update only). Default value is null.

generatePassword()

generatePassword() : string

Generate password

Returns

string

getCreateTime()

getCreateTime() : integer

Get unix timestamp from the create_date field

Returns

integer

validateValue()

validateValue(string  $field, mixed  $value) 

Validate field value from the validator using this entity

Parameters

string $field
mixed $value

putValue()

putValue(string  $field, mixed  $value) 

Validate field value and set it

Parameters

string $field
mixed $value

loadEntity()

loadEntity(string  $entity, integer  $id) 

Try to load entity from an entity string and an id integer

Parameters

string $entity
integer $id

init()

init(string  $isFinal = true) 

Initialize the class

Parameters

string $isFinal

Call this function only once after declaring it

getEntityObject()

getEntityObject(string  $objType, string  $objID = null) : \Orpheus\EntityDescriptor\PermanentEntity

Get entity instance by type and id

Parameters

string $objType
string $objID

Returns

\Orpheus\EntityDescriptor\PermanentEntity

getEntityWhereclause()

getEntityWhereclause(string  $prefix = '') : string

Helper method to get whereclause string from an entity

Parameters

string $prefix

The prefix for fields, e.g "table." (with dot)

Returns

string —

Helper method to get whereclause string from an entity. The related entity should have entity_type and entity_id fields.

getEntity()

getEntity() : string

Get this entity name

Returns

string

registerEntity()

registerEntity(string  $class) 

Register an entity

Parameters

string $class

listKnownEntities()

listKnownEntities() : array<mixed,string>

List all known entities

Returns

array<mixed,string>

selfInit()

selfInit() 

Internal static initialization

set2Array()

set2Array(array  $array) : array

Get the object as array

Parameters

array $array

Returns

array —

The resulting array

setTo()

setTo(array  $array) 

Insert this object in the given array using its ID as key

Parameters

array $array

__construct()

__construct(  $data) 

Constructor

Parameters

$data

An array of the object's data to construct

__destruct()

__destruct() 

Destructor

If something was modified, it saves the new data.

__get()

__get(string  $name) : \Orpheus\Publisher\PermanentObject\The

Magic getter

Parameters

string $name

Name of the property to get

Returns

\Orpheus\Publisher\PermanentObject\The —

value of field $name

Get the value of field $name. 'all' returns all fields.

__set()

__set(  $name,   $value) 

Magic setter

Parameters

$name

Name of the property to set

$value

New value of the property

Sets the value of field $name.

__isset()

__isset(  $name) 

Magic isset

Parameters

$name

Name of the property to check is set

Checks if the field $name is set.

id()

id() : \Orpheus\Publisher\PermanentObject\The

Get this permanent object's ID

Returns

\Orpheus\Publisher\PermanentObject\The —

id of this object.

Get this object ID according to the IDFIELD attribute.

uid()

uid() : \Orpheus\Publisher\PermanentObject\The

Get this permanent object's unique ID

Returns

\Orpheus\Publisher\PermanentObject\The —

uid of this object.

Get this object ID according to the table and id.

update()

update(array  $input, array<mixed,string>  $fields, boolean  $noEmptyWarning = true, \Orpheus\Publisher\PermanentObject\&int  $errCount, \Orpheus\Publisher\PermanentObject\&int  $successCount) : \Orpheus\Publisher\PermanentObject\1

Update this permanent object from input data array

Parameters

array $input

The input data we will check and extract, used by children

array<mixed,string> $fields

The array of fields to check

boolean $noEmptyWarning

True to do not report warning for empty data (instead return 0). Default value is true.

\Orpheus\Publisher\PermanentObject\&int $errCount

Output parameter for the number of occurred errors validating fields.

\Orpheus\Publisher\PermanentObject\&int $successCount

Output parameter for the number of successes updating fields.

Returns

\Orpheus\Publisher\PermanentObject\1 —

in case of success, else 0.

getUpdateOperation()

getUpdateOperation(array  $input, array<mixed,string>  $fields) : \Orpheus\Publisher\Transaction\UpdateTransactionOperation

Get the update operation

Parameters

array $input

The input data we will check and extract, used by children

array<mixed,string> $fields

The array of fields to check

Returns

\Orpheus\Publisher\Transaction\UpdateTransactionOperation

onValidUpdate()

onValidUpdate(array  $input, integer  $newErrors) : boolean

Callback when validating update

Parameters

array $input
integer $newErrors

Returns

boolean

extractUpdateQuery()

extractUpdateQuery(array  $input, \Orpheus\Publisher\PermanentObject\PermanentObject  $object) : array

Extract an update query from this object

Parameters

array $input
\Orpheus\Publisher\PermanentObject\PermanentObject $object

Returns

array

runForUpdate()

runForUpdate(  $data,   $oldData) 

Run for Update

Parameters

$data

the new data

$oldData

the old data

onValidateInput()

onValidateInput(array  $input, array  $fields, \Orpheus\Publisher\PermanentObject\PermanentObject  $object) 

Callback when validating input

Parameters

array $input
array $fields
\Orpheus\Publisher\PermanentObject\PermanentObject $object

save()

save() : boolean

Save this permanent object

Returns

boolean —

True in case of success

If some fields was modified, it saves these fields using the SQL Adapter.

checkIntegrity()

checkIntegrity() 

Check object integrity & validity

remove()

remove() : integer

What do you think it does ?

Returns

integer

free()

free() : boolean

Free the object (remove)

Returns

boolean

reload()

reload(string  $field = null) : boolean

Reload fields from database

Parameters

string $field

The field to reload, default is null (all fields).

Returns

boolean —

True if done

Update the current object's fields from database. If $field is not set, it reloads only one field else all fields. Also it removes the reloaded fields from the modified ones list.

isDeleted()

isDeleted() : boolean

Check if this object is deleted

Returns

boolean —

True if this object is deleted

Checks if this object is known as deleted.

isValid()

isValid() : boolean

Check if this object is valid

Returns

boolean —

True if this object is valid

Check if this object is not deleted. May be used for others cases.

markAsDeleted()

markAsDeleted() 

Mark this object as deleted

getValue()

getValue(  $key = null) : mixed

Get one value or all values

Parameters

$key

Name of the field to get.

Returns

mixed —

Get the value of field $key or all data values if $key is null.

setValue()

setValue(string  $key, mixed  $value) : \Orpheus\Publisher\PermanentObject\PermanentObject

Set the value of a field

Parameters

string $key

Name of the field to set

mixed $value

New value of the field

Returns

\Orpheus\Publisher\PermanentObject\PermanentObject

Set the field $key with the new $value.

equals()

equals(object  $o) : boolean

Verify equality with another object

Parameters

object $o

The object to compare.

Returns

boolean —

True if this object represents the same data, else False.

Compare the class and the ID field value of the 2 objects.

logEvent()

logEvent(string  $event, integer  $time = null, string  $ipAdd = null) 

Log an event

Parameters

string $event

The event to log in this object

integer $time

A specified time to use for logging event

string $ipAdd

A specified IP Adress to use for logging event

fillLogEvent()

fillLogEvent(array  $array, string  $event) 

Add an $event log in this $array

Parameters

array $array
string $event

getLogEvent()

getLogEvent(string  $event, integer  $time = null, string  $ipAdd = null) 

Get the log of an event

Parameters

string $event

The event to log in this object

integer $time

A specified time to use for logging event

string $ipAdd

A specified IP Adress to use for logging event

isFieldEditable()

isFieldEditable(string  $fieldname) : boolean

Test if $fieldname is editable

Parameters

string $fieldname

Returns

boolean

get()

get(array  $options = NULL) : \Orpheus\SQLRequest\SQLSelectRequest|static|array<mixed,static>

Get some permanent objects

Parameters

array $options

The options used to get the permanents object

Returns

\Orpheus\SQLRequest\SQLSelectRequest|static|array<mixed,static> —

An array of array containing object's data

cacheObjects()

cacheObjects(array  $objects) : array

Cache an array of objects

Parameters

array $objects

Returns

array

delete()

delete(integer  $in) : integer

Delete a permanent object

Parameters

integer $in

The object ID to delete or the delete array.

Returns

integer —

The number of deleted rows.

clearDeletedInstances()

clearDeletedInstances() 

Remove deleted instances from cache

clearInstances()

clearInstances() 

Remove deleted instances

clearAllInstances()

clearAllInstances() 

Remove all instances

escapeIdentifier()

escapeIdentifier(string  $identifier = null) : string

Escape identifier through instance

Parameters

string $identifier

The identifier to escape. Default is table name.

Returns

string —

The escaped identifier

ei()

ei(string  $identifier = null) : string

Escape identifier through instance

Parameters

string $identifier

The identifier to escape. Default is table name.

Returns

string —

The escaped identifier

formatValue()

formatValue(scalar  $value) : string

Escape value through instance

Parameters

scalar $value

The value to format

Returns

string —

The formatted $Value

fv()

fv(scalar  $value) : string

Escape value through instance

Parameters

scalar $value

The value to format

Returns

string —

The formatted $Value

formatValueList()

formatValueList(array  $list) : string

Escape values through instance and return as list string

Parameters

array $list

The list of values

Returns

string —

The formatted list string

create()

create(array  $input = array(), array  $fields = null, integer  $errCount) : integer

Create a new permanent object

Parameters

array $input

The input data we will check, extract and create the new object.

array $fields

The array of fields to check. Default value is null.

integer $errCount

Output parameter to get the number of found errors. Default value is 0

Returns

integer —

The ID of the new permanent object.

getCreateOperation()

getCreateOperation(array  $input, array<mixed,string>  $fields) : \Orpheus\Publisher\Transaction\CreateTransactionOperation

Get the create operation

Parameters

array $input

The input data we will check and extract, used by children

array<mixed,string> $fields

The array of fields to check

Returns

\Orpheus\Publisher\Transaction\CreateTransactionOperation

onValidCreate()

onValidCreate(array  $input, integer  $newErrors) : boolean

Callback when validating create

Parameters

array $input
integer $newErrors

Returns

boolean

extractCreateQuery()

extractCreateQuery(array  $input) : array

Extract a create query from this class

Parameters

array $input

Returns

array

createAndGet()

createAndGet(array  $input = array(), array|null  $fields = null, integer  $errCount) : \Orpheus\Publisher\PermanentObject\PermanentObject

Create a new permanent object

Parameters

array $input

The input data we will check, extract and create the new object.

array|null $fields

The array of fields to check. Default value is null.

integer $errCount

Output parameter to get the number of found errors. Default value is 0

Returns

\Orpheus\Publisher\PermanentObject\PermanentObject

The new permanent object

completeFields()

completeFields(array  $data) : array

Complete missing fields

Parameters

array $data

The data array to complete.

Returns

array —

The completed data array.

Complete an array of data of an object of this class by setting missing fields with empty string.

getFields()

getFields() : array

Get known fields

Returns

array

getClass()

getClass() : string

Get the name of this class

Returns

string —

The name of this class.

getTable()

getTable() : \Orpheus\Publisher\PermanentObject\The

Get the table of this class

Returns

\Orpheus\Publisher\PermanentObject\The —

table of this class.

getIDField()

getIDField() : \Orpheus\Publisher\PermanentObject\The

Get the ID field name of this class

Returns

\Orpheus\Publisher\PermanentObject\The —

ID field of this class.

getDomain()

getDomain() : \Orpheus\Publisher\PermanentObject\The

Get the domain of this class

Returns

\Orpheus\Publisher\PermanentObject\The —

domain of this class.

Get the domain of this class, can be guessed from $table or specified in $domain.

getValidator()

getValidator() : \Orpheus\Publisher\PermanentObject\The

Get the validator of this class

Returns

\Orpheus\Publisher\PermanentObject\The —

validator of this class.

Get the validator of this class.

runForObject()

runForObject(  $data) 

Run for object

Parameters

$data

The new data to process.

applyToObject()

applyToObject(  $data,   $id) 

Apply for new object

Parameters

$data

The new data to process.

$id

The ID of the new object.

checkUserInput()

checkUserInput(array  $input, array<mixed,string>  $fields = null, \Orpheus\Publisher\PermanentObject\PermanentObject  $ref = null, integer  $errCount) : \Orpheus\Publisher\PermanentObject\The

Check user input

Parameters

array $input

The user input data to check.

array<mixed,string> $fields

The array of fields to check. Default value is null.

\Orpheus\Publisher\PermanentObject\PermanentObject $ref

The referenced object (update only). Default value is null.

integer $errCount

The resulting error count, as pointer. Output parameter.

Returns

\Orpheus\Publisher\PermanentObject\The —

valid data.

Check if the class could generate a valid object from $input. The method could modify the user input to fix them but it must return the data. The data are passed through the validator, for different cases:

  • If empty, this function return an empty array.
  • If an array, it uses an field => checkMethod association.

testUserInput()

testUserInput(  $input,   $fields = null,   $ref = null,   $errCount) 

Test user input

Parameters

$input

The new data to process.

$fields

The array of fields to check. Default value is null.

$ref

The referenced object (update only). Default value is null.

$errCount

The resulting error count, as pointer. Output parameter.

getClassData()

getClassData(array  $classData = null) : array

Get all gathered data about this class

Parameters

array $classData

Returns

array

throwException()

throwException(string  $message) 

Throw an UserException

Parameters

string $message

the text message, may be a translation string

throwNotFound()

throwNotFound(string  $message = null) 

Throw a NotFoundException

Parameters

string $message

the text message, may be a translation string

text()

text(string  $text, array|string  $values = array()) : string

Translate text according to the object domain

Parameters

string $text

The text to translate

array|string $values

The values array to replace in text. Could be used as second parameter.

Returns

string —

The translated text

_text()

_text(\Orpheus\Publisher\PermanentObject\sting  $text, array|string  $values = array()) 

Translate text according to the object domain

Parameters

\Orpheus\Publisher\PermanentObject\sting $text

The text to translate

array|string $values

The values array to replace in text. Could be used as second parameter.

reportException()

reportException(  $e) 

Report an UserException

Parameters

$e

the UserException

parseFieldValue()

parseFieldValue(string  $name, string  $value) : string

Parse the value from SQL scalar to PHP type

Parameters

string $name

The field name to parse

string $value

The field value to parse

Returns

string —

The parse $value

formatFieldValue()

formatFieldValue(string  $name, mixed  $value) : string

Format the value

Parameters

string $name

The field name to format

mixed $value

The field value to format

Returns

string —

The formatted $Value

addModFields()

addModFields(  $field) 

Mark the field as modified

Parameters

$field

The field to mark as modified.

Adds the $field to the modified fields array.

listModifiedFields()

listModifiedFields() : array<mixed,string>

List all modified fields

Returns

array<mixed,string>

clearModifiedFields()

clearModifiedFields() 

Clear modified fields