FileAccess Orion

User extends BaseContent
in package
Uses RangeActive, Extras, DataHash

Implement user object

This class provides general interfaces to handle and store companies.

Tags
category

Content type

author

Tobias Teichner webmaster@teichner.biz

since

File available since v0.5

Table of Contents

$  : mixed|null
$  : string|null
$  : string|null
$  : string|null
$  : string|null
$  : string|null
$  : string|null
$ignore_hash_fields  : array<string|int, mixed>
$companies  : array<string|int, mixed>|null
Buffer for companies
$subscription_baskets  : SubscriptionBaskets|null
The subscription baskets instance
__construct()  : mixed
User constructor.
ActiveSubscriptions()  : array<string|int, string>|array<string|int, BaseLesson>
Load list of active subscriptions
AddMobileDevice()  : Result
Add mobile device
Addresses()  : array<string|int, mixed>
Get/Set the users addresses
AddSubscription()  : Result
Add a certain subscription item
Alias()  : string|null
Get the users alias
AllSubscriptions()  : array<string|int, string>|array<string|int, BaseLesson>
Get the whole subscription list
Bills()  : array<string|int, mixed>
CheckPermissionChangeAssignedGroups()  : Result
Check permission for groups
CreateExtra()  : Result
Create a new extra
Delete()  : Result
Delete a whole user account
DeleteExtra()  : Result
Delete the extra
ExternalReference()  : mixed|null
Get certain external reference
ExternalReferences()  : array<string|int, mixed>
Get the external references
FetchExtras()  : Result
Fetch extra list
GetCompany()  : string|null
Get company Get the company id from content
GetCompanyObject()  : Company
Get company
GetCompanyRoles()  : array<string|int, mixed>
Get resolved roles
GetDateFormat()  : string
Get user configured date format
GetDefaultLanguage()  : string|null
Get default language
GetExtra()  : Result
Fetch single extra
GetGroupIds()  : array<string|int, mixed>
Get groups
GetLinkedEmployees()  : array<string|int, mixed>
Get employee profiles
GetMaximumAccessLevel()  : int
Get access level maximum
GetMobileDevices()  : array<string|int, mixed>
Get list of mobile devices that are connected to this profile
GetSubscriptionBasket()  : Basket|null
Get the main active subscription basket
GetTimeZone()  : string
Get the time zone
GetVisitCard()  : VCard
Create this users visit card
Hash()  : string
Generate hash of current contents
HeartBeat()  : Result
Write and read heart beat of user
IsActive()  : bool
Check is active state
IsRoot()  : bool
User is root
LastLogin()  : MyDateTime|null
LastSession()  : string|null
Get last session
Locations()  : array<string|int, Address>
Get list of index able addresses
Name()  : string
Expose the users personal name
OwnsContent()  : bool
PrimaryAddress()  : array<string|int, mixed>|null|bool
Get/Set primary address of certain type.
Purchases()  : array<string|int, mixed>
RemoveExternalReference()  : Result
Remove the external reference
RemoveSubscription()  : Result
ResolvedSubscriptions()  : array<string|int, mixed>
Get the list of subscription articles
RootFolders()  : array<string|int, Folder>
Get root folders of this user
Salutation()  : string
Save()  : Result
save object entry in file system and git repository store the current payload inside the system storage and commit the changes to the local repository
SearchFields()  : array<string|int, mixed>
Return search indexer fields
SetExternalReference()  : Result
Add or update existing external reference
StoreLastSession()  : bool
Store last session
SubscriptionBaskets()  : SubscriptionBaskets
Reference to subscription baskets handler
Subscriptions()  : array<string|int, mixed>
Load list of subscriptions
ToPlainObject()  : object
Convert to plain data set
UpdateAttributeAlias()  : Result
Called on update the alias attribute
UpdateAttributeEmailaddress()  : Result
Called on update the email attribute
UpdateAttributeGroups()  : Result
Called on update the groups attribute
UpdateExtra()  : Result
Update the extra
extrasPath()  : string
Helper to get the extras path
notifyOnStatusChange()  : Result
Send a status transition email to this user
writeExtra()  : Result
Store extras

Properties

$

public mixed|null $

alias The login alias

$

public string|null $

emailaddress The email address

$

public string|null $

surname The last name

$

public string|null $

firstname The given name

$

public string|null $

datefrom Valid from

$

public string|null $

dateto Valid to

$

public string|null $

country The country of residence

$ignore_hash_fields

protected array<string|int, mixed> $ignore_hash_fields = ['last_changed_by', 'last_changed_at']

$companies

Buffer for companies

private array<string|int, mixed>|null $companies = null

List of users company roles

$subscription_baskets

The subscription baskets instance

private SubscriptionBaskets|null $subscription_baskets = null

?SubscriptionBaskets

Methods

__construct()

User constructor.

public __construct([string|null $id = null ][, string|null $language = null ]) : mixed
Parameters
$id : string|null = null

A user id

$language : string|null = null

The language id

Return values
mixed

ActiveSubscriptions()

Load list of active subscriptions

public ActiveSubscriptions([string|bool $resolved = false ]) : array<string|int, string>|array<string|int, BaseLesson>

Fetches all currently valid and active subscription ids

Parameters
$resolved : string|bool = false

When false, return ids, when set true return the linked lessons, when set to 'raw' return the array items

Return values
array<string|int, string>|array<string|int, BaseLesson>

AddMobileDevice()

Add mobile device

public AddMobileDevice(array<string|int, mixed> $data[, bool $update_existing = false ]) : Result

This function adds a mobile device to the profile When defined it can update existing device with the new data

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

The new device data

$update_existing : bool = false

When true an existing device will be replaced

Return values
Result

A system result object

Addresses()

Get/Set the users addresses

public Addresses([null|array<string|int, mixed> $new = null ]) : array<string|int, mixed>
Parameters
$new : null|array<string|int, mixed> = null

The new addresses

Return values
array<string|int, mixed>

AddSubscription()

Add a certain subscription item

public AddSubscription(string $id, string $type[, string|null $date = null ][, string|null $basket_id = null ]) : Result

When the subscription is present already, do not add but reactivate at current date

Parameters
$id : string

The id of the lesson

$type : string

The type of lesson

$date : string|null = null

When given, the registration date or some parsable string like +30 days

$basket_id : string|null = null

Activated by this basket

Return values
Result

A system result

Alias()

Get the users alias

public Alias() : string|null
Return values
string|null

AllSubscriptions()

Get the whole subscription list

public AllSubscriptions([string|bool $resolved = false ][, bool $only_active = true ]) : array<string|int, string>|array<string|int, BaseLesson>
Parameters
$resolved : string|bool = false

When false, return ids, when set true return the linked lessons, when set to 'raw' return the array items

$only_active : bool = true

When default true, only the currently active subscriptions

Return values
array<string|int, string>|array<string|int, BaseLesson>

Bills()

public Bills() : array<string|int, mixed>
Return values
array<string|int, mixed>

CheckPermissionChangeAssignedGroups()

Check permission for groups

public CheckPermissionChangeAssignedGroups(array<string|int, mixed> $groups) : Result

test if the given groups have a level lower the admins level and deny access when level exceeded

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

A list of user group id's

Return values
Result

True or false when level exceeded

CreateExtra()

Create a new extra

public CreateExtra(string $type, array<string|int, mixed> $data[, bool $individual = true ]) : Result
Parameters
$type : string
$data : array<string|int, mixed>
$individual : bool = true
Return values
Result

Delete()

Delete a whole user account

public Delete([bool $skip = false ]) : Result

this method can delete each user account except the root user

Parameters
$skip : bool = false

Skip hooks on demand

Return values
Result

A default system result set

DeleteExtra()

Delete the extra

public DeleteExtra(string $type[, string|null $id = null ][, bool $individual = true ]) : Result
Parameters
$type : string

The extras type

$id : string|null = null

The id or null to drop all of certain kind

$individual : bool = true

Is individual file or, in all full list?

Return values
Result

ExternalReference()

Get certain external reference

public ExternalReference(string $type) : mixed|null
Parameters
$type : string

The id

Return values
mixed|null

ExternalReferences()

Get the external references

public ExternalReferences() : array<string|int, mixed>

Load the list to external references like facebook

Return values
array<string|int, mixed>

FetchExtras()

Fetch extra list

public FetchExtras(string $type[, bool $individual = true ]) : Result
Parameters
$type : string
$individual : bool = true
Return values
Result

GetCompany()

Get company Get the company id from content

public GetCompany() : string|null
Return values
string|null

The content id

GetCompanyObject()

Get company

public GetCompanyObject() : Company

Get the main company from content

Return values
Company

A company object or null when list is empty

GetCompanyRoles()

Get resolved roles

public GetCompanyRoles() : array<string|int, mixed>

Get a list of resolved company role entries

Return values
array<string|int, mixed>

The resolved role rights

GetDateFormat()

Get user configured date format

public GetDateFormat([bool $php = false ]) : string
Parameters
$php : bool = false

Convert to php format string?

Return values
string

GetDefaultLanguage()

Get default language

public GetDefaultLanguage([bool $as_locale = false ]) : string|null

Get the default language code of the user attribute set

Parameters
$as_locale : bool = false
Return values
string|null

GetExtra()

Fetch single extra

public GetExtra(string $type, string $id) : Result
Parameters
$type : string
$id : string
Return values
Result

GetGroupIds()

Get groups

public GetGroupIds() : array<string|int, mixed>

Get a list of assigned group ids for this user

Return values
array<string|int, mixed>

The available group ids

GetLinkedEmployees()

Get employee profiles

public GetLinkedEmployees() : array<string|int, mixed>

Get the list of linked employee profiles of this customer/user profile

Return values
array<string|int, mixed>

List with profile ids

GetMaximumAccessLevel()

Get access level maximum

public GetMaximumAccessLevel() : int

Parse the groups of this user account and find the maximum access level

Return values
int

the highest found level

GetMobileDevices()

Get list of mobile devices that are connected to this profile

public GetMobileDevices([bool $only_active = false ]) : array<string|int, mixed>
Parameters
$only_active : bool = false

Only the active ones

Return values
array<string|int, mixed>

GetSubscriptionBasket()

Get the main active subscription basket

public GetSubscriptionBasket() : Basket|null

Load the current linked basket for subscription verification. Will return null when no object is linked or could be loaded by version.

Return values
Basket|null

GetTimeZone()

Get the time zone

public GetTimeZone() : string
Return values
string

GetVisitCard()

Create this users visit card

public GetVisitCard() : VCard
Return values
VCard

Hash()

Generate hash of current contents

public Hash() : string
Return values
string

HeartBeat()

Write and read heart beat of user

public HeartBeat(int $action) : Result
Parameters
$action : int
Return values
Result

IsActive()

Check is active state

public IsActive([array<string|int, mixed>|null $row = null ][, string $from = 'datefrom' ][, string $to = 'dateto' ][, int|null $now = null ]) : bool

Check if the element is active and valid at the current time

Parameters
$row : array<string|int, mixed>|null = null
$from : string = 'datefrom'
$to : string = 'dateto'
$now : int|null = null
Return values
bool

Entry is active based on date from and date to property

IsRoot()

User is root

public IsRoot() : bool

Check if this is the absolute root user

Return values
bool

Is?

LastLogin()

public LastLogin([int $offset = 2 ]) : MyDateTime|null
Parameters
$offset : int = 2
Return values
MyDateTime|null

LastSession()

Get last session

public LastSession() : string|null
Return values
string|null

Locations()

Get list of index able addresses

public Locations([bool $all = false ][, array<string|int, mixed>|null $types = null ]) : array<string|int, Address>
Parameters
$all : bool = false

Fetch all even if not filled

$types : array<string|int, mixed>|null = null
Return values
array<string|int, Address>

The list of addresses

Name()

Expose the users personal name

public Name([bool $reverse = false ]) : string
Parameters
$reverse : bool = false

Reverse the name

Return values
string

The name of this user

OwnsContent()

public OwnsContent(string $id, string $type) : bool
Parameters
$id : string
$type : string
Return values
bool

PrimaryAddress()

Get/Set primary address of certain type.

public PrimaryAddress([string|array<string|int, string> $type = 'contact' ][, array<string|int, mixed>|null $data = null ]) : array<string|int, mixed>|null|bool

Function can set a new primary address as well

Parameters
$type : string|array<string|int, string> = 'contact'

The type of the address bill, storage, delivery

$data : array<string|int, mixed>|null = null

New data for the address

Return values
array<string|int, mixed>|null|bool

The found address or null or storage result

Purchases()

public Purchases() : array<string|int, mixed>
Return values
array<string|int, mixed>

RemoveExternalReference()

Remove the external reference

public RemoveExternalReference(string $type) : Result
Parameters
$type : string

The type of the reference, is an id

Return values
Result

RemoveSubscription()

public RemoveSubscription(string $id, string $type) : Result
Parameters
$id : string
$type : string
Return values
Result

ResolvedSubscriptions()

Get the list of subscription articles

public ResolvedSubscriptions([bool $as_array = false ]) : array<string|int, mixed>
Parameters
$as_array : bool = false

Return as key value pair

Return values
array<string|int, mixed>

The list of subscription ids with type

RootFolders()

Get root folders of this user

public RootFolders([string $language = FAA_DEFAULT_LANGUAGE ]) : array<string|int, Folder>
Parameters
$language : string = FAA_DEFAULT_LANGUAGE
Return values
array<string|int, Folder>

Salutation()

public Salutation(string $language) : string
Parameters
$language : string
Return values
string

Save()

save object entry in file system and git repository store the current payload inside the system storage and commit the changes to the local repository

public Save([bool $force_new_id = false ]) : Result
Parameters
$force_new_id : bool = false

Indicate force new id on demand (local id empty)

Return values
Result

A default system result set

SearchFields()

Return search indexer fields

public SearchFields() : array<string|int, mixed>

Convert instance to search indexer values

Return values
array<string|int, mixed>

The search indexer fields

SetExternalReference()

Add or update existing external reference

public SetExternalReference(string $type, string $ext_id[, string|null $ext_account_id = null ]) : Result
Parameters
$type : string

The provider type

$ext_id : string

The external id

$ext_account_id : string|null = null

Additional external id

Return values
Result

A system result

StoreLastSession()

Store last session

public StoreLastSession( $id) : bool
Parameters
$id :
Return values
bool

Subscriptions()

Load list of subscriptions

public Subscriptions() : array<string|int, mixed>

Fetches the value directly from the set of attributes and returns an default empty array on demand

Return values
array<string|int, mixed>

ToPlainObject()

Convert to plain data set

public ToPlainObject([string|null $language = null ][, bool $with_parent = true ]) : object

Translate and expose the current data attribute as plain resolved object

Parameters
$language : string|null = null

A system language code or empty for raw setup

$with_parent : bool = true

When set to true the attributes will be resolved witch parent attributes included

Return values
object

A simple attribute based php object

UpdateAttributeAlias()

Called on update the alias attribute

public UpdateAttributeAlias(object $attr, string|null $value) : Result

Does a check if the alias is in use already and denies update when it is

Parameters
$attr : object

The attribute definition

$value : string|null

The new alias

Return values
Result

A system result object

UpdateAttributeEmailaddress()

Called on update the email attribute

public UpdateAttributeEmailaddress(object $attr, string|null $value) : Result

Does a check if the alias is in use already and denies update when it is

Parameters
$attr : object

The attribute definition

$value : string|null

The new email address

Return values
Result

A system result object

UpdateAttributeGroups()

Called on update the groups attribute

public UpdateAttributeGroups(object $attr, array<string|int, mixed>|null $value) : Result

Does a check if the current user is allowed to do this change

Parameters
$attr : object

The attribute definition

$value : array<string|int, mixed>|null

The new set of groups

Return values
Result

A system result object

UpdateExtra()

Update the extra

public UpdateExtra(string $type, string $id, array<string|int, mixed> $data[, bool $individual = true ]) : Result
Parameters
$type : string

The extras type

$id : string

The item primary key

$data : array<string|int, mixed>

The new data

$individual : bool = true

Is individual file or in all full list?

Return values
Result

extrasPath()

Helper to get the extras path

private extrasPath(string $type) : string
Parameters
$type : string
Return values
string

notifyOnStatusChange()

Send a status transition email to this user

private notifyOnStatusChange( $action) : Result
Parameters
$action :
Return values
Result

writeExtra()

Store extras

private writeExtra(string $file, array<string|int, mixed> $data[, bool $individual = true ]) : Result
Parameters
$file : string

The target file

$data : array<string|int, mixed>

The new row

$individual : bool = true

Save in individual file?

Return values
Result

Search results