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 615
callable|null getAfterPrepareCallback()

No description

Return Value

callable|null

at line 525
bool getAllowPasswordChange()

No description

Return Value

bool

at line 585
bool getAutoGenerateDisplayname()

No description

Return Value

bool

at line 570
bool getAutoGenerateLogin()

No description

Return Value

bool

at line 510
bool getAutoGeneratePassword()

No description

Return Value

bool

at line 630
callable|null getFindExistingUserCallback()

No description

Return Value

callable|null

at line 540
int getGeneratedPasswordLength()

No description

Return Value

int

at line 555
int getGeneratedPasswordStrength()

No description

Return Value

int

at line 489
string getMode()

No description

Return Value

string

at line 600
string getUniqueIdentifierField()

No description

Return Value

string

at line 92
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
UserImportException

at line 78
init()

Initialize the import

at line 623
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 533
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 593
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 578
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 518
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 638
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 548
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 563
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 497
void setMode(string $mode = UserImport::MODE_UPDATE)

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

Parameters

string $mode

Return Value

void

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

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

Parameters

string $uniqueIdentifierField

Return Value

void