UserService
This service provides methods for managing users and user groups.
Methods¶
assignUserToUserGroup()
¶
Assigns a new user group to the user.
If the user is already in the given user group this method does nothing.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $user | User | - | - |
| $userGroup | UserGroup | - | - |
Tags
checkUserCredentials()
¶
Checks if credentials are valid for provided User.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $user | User | - | - |
| $credentials | string | - | - |
Return values
bool
createUser()
¶
Create a new user. The created user is published by this method.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $userCreateStruct | UserCreateStruct | - |
the data used for creating the user |
| $parentGroups | array<string|int, mixed> | - |
the groups of type UserGroup which are assigned to the user after creation |
Return values
Tags
createUserGroup()
¶
Creates a new user group using the data provided in the ContentCreateStruct parameter.
|
|
|
In 4.x in the content type parameter in the profile is ignored
- the content type is determined via configuration and can be set to null. The returned version is published.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $userGroupCreateStruct | UserGroupCreateStruct | - |
a structure for setting all necessary data to create this user group |
| $parentGroup | UserGroup | - | - |
Return values
Tags
deleteUser()
¶
This method deletes a user.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $user | User | - | - |
Return values
array<string|int, int>
Affected Location Id's (List of Locations of the Content that was deleted)
Tags
deleteUserGroup()
¶
Removes a user group.
|
|
|
the users which are not assigned to other groups will be deleted.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $userGroup | UserGroup | - | - |
Return values
array<string|int, int>
Affected Location Id's (List of Locations of the Content that was deleted)
Tags
expireUserToken()
¶
Expires user token with user hash.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $hash | string | - | - |
findUserGroups()
¶
Finds user groups matching the given filter, using content filtering ({@see ContentService::find()}).
|
|
|
Location criteria of the filter are evaluated on the main Location of a user group, so e.g. ParentLocationId with the main Location of a user group matches its subgroups, consistently with UserGroup::$parentId.
The filter is limited to the user group content type, and the content ID is added as the last sort clause. Only user groups the current user is allowed to read are returned and counted. User groups without a main Location (e.g. trashed ones) are neither returned nor counted. As in ContentService::find(), a filter limit of 0 means no limit.
With a user, only the user groups it is directly assigned to are matched: the content items holding the parent Locations of its Locations the current user is allowed to read, as in loadUserGroupsOfUser().
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $filter | Filter | - | - |
| $user | User|null | null | - |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned objects. User groups not available in any of them (and not always available) are neither returned nor counted. |
Return values
Tags
findUsers()
¶
Finds users matching the given filter, using Location filtering ({@see LocationService::find()}).
|
|
Each user is matched through exactly one of its Locations: the Location directly under the main Location of
the given user group (its direct members, also those assigned through a secondary Location), or the main
Location without a user group. Location criteria of the filter and the content/read permission are evaluated
on that Location, so each user is returned and counted once.
The filter is limited to the user content types, and the content ID is added as the last sort clause. Only users the current user is allowed to read are returned and counted. A user group without a main Location has no members. As in LocationService::find(), a filter limit of 0 means no limit.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $filter | Filter | - | - |
| $userGroup | UserGroup|null | null | - |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned objects. Users not available in any of them (and not always available) are neither returned nor counted. |
Return values
Tags
getPasswordInfo()
¶
Returns information about password for a given user.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $user | User | - | - |
Return values
isUser()
¶
Checks if Content is a user.
|
|
|
@since 7.4
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $content | Content | - | - |
Return values
bool
isUserGroup()
¶
Checks if Content is a user group.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $content | Content | - | - |
Return values
bool
loadSubUserGroups()
¶
Loads the sub groups of a user group.
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $userGroup | UserGroup | - | - |
| $offset | int | 0 |
the start offset for paging |
| $limit | int | 25 |
the number of user groups returned |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned object. |
Return values
array<string|int, UserGroup>
Tags
loadUser()
¶
Loads a user.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $userId | mixed | - | - |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned object. |
Return values
Tags
loadUserByEmail()
¶
Loads a user for the given email.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| string | - | - | |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned object. |
Return values
Tags
loadUserByLogin()
¶
Loads a user for the given login.
|
|
|
Since 6.1 login is case-insensitive across all storage engines and database backends, like was the case with mysql before in Ibexa 3.x/4.x/5.x.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $login | string | - | - |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned object. |
Return values
Tags
loadUserByToken()
¶
Loads a user with user hash key.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $hash | string | - | - |
| $prioritizedLanguages | array<string|int, string> | [] | - |
Return values
loadUserGroup()
¶
Loads a user group for the given id.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $id | int | - | - |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned object. |
Return values
Tags
loadUserGroupByRemoteId()
¶
Loads a user group for the given remote id.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $remoteId | string | - | - |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned object. |
Return values
Tags
loadUserGroupsOfUser()
¶
Loads the user groups the user belongs to.
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $user | User | - | - |
| $offset | int | 0 |
the start offset for paging |
| $limit | int | 25 |
the number of user groups returned |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned object. |
Return values
array<string|int, UserGroup>
Tags
loadUsersByEmail()
¶
Loads a users for the given email.
|
|
|
Note: This method loads user by $email where $email might be case-insensitive on certain storage engines!
Returns an array of Users since Ibexa has under certain circumstances allowed several users having same email in the past (by means of a configuration option).
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| string | - | - | |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned object. |
Return values
array<string|int, User>
Tags
loadUsersOfUserGroup()
¶
Loads the users of a user group.
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $userGroup | UserGroup | - | - |
| $offset | int | 0 |
the start offset for paging |
| $limit | int | 25 |
the number of users returned |
| $prioritizedLanguages | array<string|int, string> | [] |
Used as prioritized language code on translated properties of returned object. |
Return values
array<string|int, User>
Tags
moveUserGroup()
¶
Moves the user group to another parent.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $userGroup | UserGroup | - | - |
| $newParent | UserGroup | - | - |
Tags
newUserCreateStruct()
¶
Instantiate a user create class.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $login | string | - |
the login of the new user |
| string | - |
the email of the new user |
|
| $password | string | - |
the plain password of the new user |
| $mainLanguageCode | string | - |
the main language for the underlying content object |
| $contentType | ContentType|null | null |
content type for the underlying content object. |
Return values
newUserGroupCreateStruct()
¶
Instantiate a user group create class.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $mainLanguageCode | string | - |
The main language for the underlying content object |
| $contentType | ContentType|null | null |
5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration |
Return values
newUserGroupUpdateStruct()
¶
Instantiate a new user group update struct.
|
|
|
Return values
newUserUpdateStruct()
¶
Instantiate a new user update struct.
|
|
|
Return values
unAssignUserFromUserGroup()
¶
Removes a user group from the user.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $user | User | - | - |
| $userGroup | UserGroup | - | - |
Tags
updateUser()
¶
Updates a user.
|
|
|
4.x: If the versionUpdateStruct is set in the user update structure, this method internally creates a content draft, updates ts with the provided data and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $user | User | - | - |
| $userUpdateStruct | UserUpdateStruct | - | - |
Return values
Tags
updateUserGroup()
¶
Updates the group profile with fields and meta data.
|
|
|
4.x: If the versionUpdateStruct is set in $userGroupUpdateStruct, this method internally creates a content draft, updates ts with the provided data and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $userGroup | UserGroup | - | - |
| $userGroupUpdateStruct | UserGroupUpdateStruct | - | - |
Return values
Tags
updateUserPassword()
¶
Validates and updates just the user's password.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $user | User | - | - |
| $newPassword | string | - | - |
Return values
Tags
updateUserToken()
¶
Update the user token information specified by the user token struct.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $user | User | - | - |
| $userTokenUpdateStruct | UserTokenUpdateStruct | - | - |
Return values
validatePassword()
¶
Validates given password.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $password | string | - | - |
| $context | PasswordValidationContext|null | null | - |
Return values
array<string|int, ValidationError>