class UserImport

This class handels the import and update of user data

Constants

MODE_UPDATE

Only updates existing entries

MODE_INSERT

Only inserts non existing entries

MODE_INSERT_UPDATE

Inserts non existing entries and updates existing ones

STATUS_ARRAY_VAR

STATUS_NO_EXISTING_USER_ON_UPDATE

STATUS_EXISTING_USER_ON_INSERT

STATUS_USERLIMIT_REACHED

STATUS_FAILURE_DURING_SAVE

STATUS_SKIPPED_NO_LOGIN_IN_DATA

STATUS_SUCCESS

Properties

protected string $mode
protected bool $autoGeneratePassword
protected bool $allowPasswordChange
protected int $generatedPasswordLength
protected int $generatedPasswordStrength
protected bool $autoGenerateLogin
protected bool $autoGenerateDisplayname
protected string $uniqueIdentifierField
protected null|callable $afterPrepareCallback

A callback to further prepare/change the $userData. First parameter is he $userData array and second parameter is the $user object

protected null|callable $findExistingUserCallback

A callback to find an existing user. $userData is given as first function parameter.

Methods

callable|null
getAfterPrepareCallback()

No description

bool
getAllowPasswordChange()

No description

bool
getAutoGenerateDisplayname()

No description

bool
getAutoGenerateLogin()

No description

bool
getAutoGeneratePassword()

No description

callable|null
getFindExistingUserCallback()

No description

int
getGeneratedPasswordLength()

No description

int
getGeneratedPasswordStrength()

No description

string
getMode()

No description

string
getUniqueIdentifierField()

No description

array
import(array $userData)

No description

init()

Initialize the import

void
setAfterPrepareCallback(callable|null $afterPrepareCallback = null)

Callback to further prepare the $userData. USE: function($userData, $userObj); return $userData;

void
setAllowPasswordChange(bool $allowPasswordChange = false)

If set to true the password of an EXISTING user will be changed if $userData['password'] is set

void
setAutoGenerateDisplayname(bool $autoGenerateDisplayname = true)

If set and $userData['displayname'] is empty, a value for 'displayname' is generated. ("FIRSTNAME LASTANME")

void
setAutoGenerateLogin(bool $autoGenerateLogin = true)

If set and $userData['login'] is empty, a value for 'login' will be generated.

void
setAutoGeneratePassword(bool $autoGeneratePassword = true)

If set to true a password will be autogenerated, if a NEW user has been created and $userData['password'] is empty.

void
setFindExistingUserCallback(callable $findExistingUserCallback)

Callback to find a user object. USE: function($userData); return \XELOS\Framework\XF\System\Model\User

void
setGeneratedPasswordLength(int $generatedPasswordLength = 8)

Only relevant if autoGeneratePassword is active. See parameters: $XF->lib->sec->generate_pronouncable_password()

void
setGeneratedPasswordStrength(int $generatedPasswordStrength = 7)

Only relevant if autoGeneratePassword is active. See parameters: $XF->lib->sec->generate_pronouncable_password()

void
setMode(string $mode = UserImport::MODE_UPDATE)

Set the import mode. Use class constants: UserImport::MODE_*

void
setUniqueIdentifierField(string $uniqueIdentifierField = 'login')

Set the unique identifier field for the default findExistingUserCallback. ['id' || 'email' || 'login' || 'meta_*']

Details

at line 617
callable|null getAfterPrepareCallback()

No description

Return Value

callable|null

at line 527
bool getAllowPasswordChange()

No description

Return Value

bool

at line 587
bool getAutoGenerateDisplayname()

No description

Return Value

bool

at line 572
bool getAutoGenerateLogin()

No description

Return Value

bool

at line 512
bool getAutoGeneratePassword()

No description

Return Value

bool

at line 632
callable|null getFindExistingUserCallback()

No description

Return Value

callable|null

at line 542
int getGeneratedPasswordLength()

No description

Return Value

int

at line 557
int getGeneratedPasswordStrength()

No description

Return Value

int

at line 491
string getMode()

No description

Return Value

string

at line 602
string getUniqueIdentifierField()

No description

Return Value

string

at line 95
array import(array $userData)

No description

Parameters

array $userData

['user_id'=>1,'firstname'=>'john','lastname'=>'doe','login'=>'login','password'=>'new_password','lookbook_field'=>'value','user_config'=>'var1=value1|var2=value2']

Return Value

array

['user_id'=>1,'firstname'=>'john','lastname'=>'doe','login'=>'login','password'=>'new_password','lookbook_field'=>'value','user_config'=>'var1=value1|var2=value2','_status'=>'STATUS']

Exceptions

ModuleException

Is thrown e.g. if some module instance initialization did not work

UserImportException

Is thrown if there are errors during the user import

UserCreationException

Is thrown if a user could not be created (e.g. User limit reached)

at line 80
init()

Initialize the import

at line 625
void setAfterPrepareCallback(callable|null $afterPrepareCallback = null)

Callback to further prepare the $userData. USE: function($userData, $userObj); return $userData;

Parameters

callable|null $afterPrepareCallback

Return Value

void

at line 535
void setAllowPasswordChange(bool $allowPasswordChange = false)

If set to true the password of an EXISTING user will be changed if $userData['password'] is set

Parameters

bool $allowPasswordChange

Return Value

void

at line 595
void setAutoGenerateDisplayname(bool $autoGenerateDisplayname = true)

If set and $userData['displayname'] is empty, a value for 'displayname' is generated. ("FIRSTNAME LASTANME")

Parameters

bool $autoGenerateDisplayname

Return Value

void

at line 580
void setAutoGenerateLogin(bool $autoGenerateLogin = true)

If set and $userData['login'] is empty, a value for 'login' will be generated.

Parameters

bool $autoGenerateLogin

Return Value

void

at line 520
void setAutoGeneratePassword(bool $autoGeneratePassword = true)

If set to true a password will be autogenerated, if a NEW user has been created and $userData['password'] is empty.

Parameters

bool $autoGeneratePassword

Return Value

void

at line 640
void setFindExistingUserCallback(callable $findExistingUserCallback)

Callback to find a user object. USE: function($userData); return \XELOS\Framework\XF\System\Model\User

Parameters

callable $findExistingUserCallback

Return Value

void

at line 550
void setGeneratedPasswordLength(int $generatedPasswordLength = 8)

Only relevant if autoGeneratePassword is active. See parameters: $XF->lib->sec->generate_pronouncable_password()

Parameters

int $generatedPasswordLength

Return Value

void

at line 565
void setGeneratedPasswordStrength(int $generatedPasswordStrength = 7)

Only relevant if autoGeneratePassword is active. See parameters: $XF->lib->sec->generate_pronouncable_password()

Parameters

int $generatedPasswordStrength

Return Value

void

at line 499
void setMode(string $mode = UserImport::MODE_UPDATE)

Set the import mode. Use class constants: UserImport::MODE_*

Parameters

string $mode

Return Value

void

at line 610
void setUniqueIdentifierField(string $uniqueIdentifierField = 'login')

Set the unique identifier field for the default findExistingUserCallback. ['id' || 'email' || 'login' || 'meta_*']

Parameters

string $uniqueIdentifierField

Return Value

void