eZPublishCommunityProject  2013.5
eZ\Publish\Core\Repository\UserService Class Reference
+ Inheritance diagram for eZ\Publish\Core\Repository\UserService:
+ Collaboration diagram for eZ\Publish\Core\Repository\UserService:

Public Member Functions

 __construct (RepositoryInterface $repository, Handler $userHandler, array $settings=array())
 Setups service with reference to repository object that created it & corresponding handler. More...
 
 assignUserToUserGroup (APIUser $user, APIUserGroup $userGroup)
 Assigns a new user group to the user. More...
 
 createUser (APIUserCreateStruct $userCreateStruct, array $parentGroups)
 Create a new user. More...
 
 createUserGroup (APIUserGroupCreateStruct $userGroupCreateStruct, APIUserGroup $parentGroup)
 Creates a new user group using the data provided in the ContentCreateStruct parameter. More...
 
 deleteUser (APIUser $user)
 This method deletes a user. More...
 
 deleteUserGroup (APIUserGroup $userGroup)
 Removes a user group. More...
 
 loadAnonymousUser ()
 Loads anonymous user. More...
 
 loadSubUserGroups (APIUserGroup $userGroup)
 Loads the sub groups of a user group. More...
 
 loadUserByCredentials ($login, $password)
 Loads a user for the given login and password. More...
 
 loadUserGroup ($id)
 Loads a user group for the given id. More...
 
 loadUserGroupsOfUser (APIUser $user)
 Loads the user groups the user belongs to. More...
 
 loadUsersOfUserGroup (APIUserGroup $userGroup, $offset=0, $limit=-1)
 Loads the users of a user group. More...
 
 moveUserGroup (APIUserGroup $userGroup, APIUserGroup $newParent)
 Moves the user group to another parent. More...
 
 newUserCreateStruct ($login, $email, $password, $mainLanguageCode, $contentType=null)
 Instantiate a user create class. More...
 
 newUserGroupCreateStruct ($mainLanguageCode, $contentType=null)
 Instantiate a user group create class. More...
 
 newUserGroupUpdateStruct ()
 Instantiate a new user group update struct. More...
 
 newUserUpdateStruct ()
 Instantiate a new user update struct. More...
 
 unAssignUserFromUserGroup (APIUser $user, APIUserGroup $userGroup)
 Removes a user group from the user. More...
 
 updateUser (APIUser $user, UserUpdateStruct $userUpdateStruct)
 Updates a user. More...
 
 updateUserGroup (APIUserGroup $userGroup, UserGroupUpdateStruct $userGroupUpdateStruct)
 Updates the group profile with fields and meta data. More...
 
- Public Member Functions inherited from eZ\Publish\API\Repository\UserService
 assignUserToUserGroup (User $user, UserGroup $userGroup)
 Assigns a new user group to the user. More...
 
 createUser (UserCreateStruct $userCreateStruct, array $parentGroups)
 Create a new user. More...
 
 createUserGroup (UserGroupCreateStruct $userGroupCreateStruct, UserGroup $parentGroup)
 Creates a new user group using the data provided in the ContentCreateStruct parameter. More...
 
 deleteUser (User $user)
 This method deletes a user. More...
 
 deleteUserGroup (UserGroup $userGroup)
 Removes a user group. More...
 
 loadSubUserGroups (UserGroup $userGroup)
 Loads the sub groups of a user group. More...
 
 loadUser ($userId)
 Loads a user. More...
 
 loadUserGroupsOfUser (User $user)
 Loads the user groups the user belongs to. More...
 
 loadUsersOfUserGroup (UserGroup $userGroup, $offset=0, $limit=-1)
 Loads the users of a user group. More...
 
 moveUserGroup (UserGroup $userGroup, UserGroup $newParent)
 Moves the user group to another parent. More...
 
 unAssignUserFromUserGroup (User $user, UserGroup $userGroup)
 Removes a user group from the user. More...
 
 updateUser (User $user, UserUpdateStruct $userUpdateStruct)
 Updates a user. More...
 
 updateUserGroup (UserGroup $userGroup, UserGroupUpdateStruct $userGroupUpdateStruct)
 Updates the group profile with fields and meta data. More...
 

Protected Member Functions

 buildDomainUserGroupObject (APIContent $content)
 Builds the domain UserGroup object from provided Content object. More...
 
 buildDomainUserObject (SPIUser $spiUser, APIContent $content=null)
 Builds the domain user object from provided persistence user object. More...
 
 createPasswordHash ($login, $password, $site, $type)
 Returns password hash based on user data and site settings. More...
 
 getSortClauseBySortField ($sortField, $sortOrder=Location::SORT_ORDER_ASC)
 Instantiates a correct sort clause object based on provided location sort field and sort order. More...
 
 searchSubGroups ($locationId, $sortField=null, $sortOrder=Location::SORT_ORDER_ASC, $offset=0, $limit=-1)
 Returns (searches) subgroups of a user group described by its main location. More...
 

Protected Attributes

 $repository
 
 $settings
 
 $userHandler
 

Constructor & Destructor Documentation

eZ\Publish\Core\Repository\UserService::__construct ( RepositoryInterface  $repository,
Handler  $userHandler,
array  $settings = array() 
)

Setups service with reference to repository object that created it & corresponding handler.

Parameters
\eZ\Publish\API\Repository\Repository$repository
\eZ\Publish\SPI\Persistence\User\Handler$userHandler
array$settings

Member Function Documentation

eZ\Publish\Core\Repository\UserService::assignUserToUserGroup ( APIUser  $user,
APIUserGroup  $userGroup 
)

Assigns a new user group to the user.

Parameters
\eZ\Publish\API\Repository\Values\User\User$user
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to assign the user group to the user
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentExceptionif the user is already in the given user group
eZ\Publish\Core\Repository\UserService::buildDomainUserGroupObject ( APIContent  $content)
protected
eZ\Publish\Core\Repository\UserService::buildDomainUserObject ( SPIUser  $spiUser,
APIContent  $content = null 
)
protected

Builds the domain user object from provided persistence user object.

Parameters
\eZ\Publish\SPI\Persistence\User$spiUser
\eZ\Publish\API\Repository\Values\Content\Content | null$content
Returns

Referenced by eZ\Publish\Core\Repository\UserService\createUser(), eZ\Publish\Core\Repository\UserService\loadUserByCredentials(), and eZ\Publish\Core\Repository\UserService\loadUsersOfUserGroup().

eZ\Publish\Core\Repository\UserService::createPasswordHash (   $login,
  $password,
  $site,
  $type 
)
protected

Returns password hash based on user data and site settings.

Parameters
string$loginUser login
string$passwordUser password
string$siteThe name of the site
int$typeType of password to generate
Returns
string Generated password hash

Referenced by eZ\Publish\Core\Repository\UserService\loadUserByCredentials().

eZ\Publish\Core\Repository\UserService::createUser ( APIUserCreateStruct  $userCreateStruct,
array  $parentGroups 
)

Create a new user.

The created user is published by this method

Parameters
\eZ\Publish\API\Repository\Values\User\UserCreateStruct$userCreateStructthe data used for creating the user
\eZ\Publish\API\Repository\Values\User\UserGroup[]$parentGroups the groups which are assigned to the user after creation
Returns
Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to move the user group
\eZ\Publish\API\Repository\Exceptions\ContentFieldValidationExceptionif a field in the $userCreateStruct is not valid
\eZ\Publish\API\Repository\Exceptions\ContentValidationExceptionif a required field is missing or set to an empty value
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentExceptionif a user with provided login already exists
eZ\Publish\Core\Repository\UserService::createUserGroup ( APIUserGroupCreateStruct  $userGroupCreateStruct,
APIUserGroup  $parentGroup 
)

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
\eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct$userGroupCreateStructa structure for setting all necessary data to create this user group
\eZ\Publish\API\Repository\Values\User\UserGroup$parentGroup
Returns
Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to create a user group
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentExceptionif the input structure has invalid data
\eZ\Publish\API\Repository\Exceptions\ContentFieldValidationExceptionif a field in the $userGroupCreateStruct is not valid
\eZ\Publish\API\Repository\Exceptions\ContentValidationExceptionif a required field is missing or set to an empty value
eZ\Publish\Core\Repository\UserService::deleteUser ( APIUser  $user)

This method deletes a user.

Parameters
\eZ\Publish\API\Repository\Values\User\User$user
Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to delete the user
eZ\Publish\Core\Repository\UserService::deleteUserGroup ( APIUserGroup  $userGroup)

Removes a user group.

the users which are not assigned to other groups will be deleted.

Parameters
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to create a user group
eZ\Publish\Core\Repository\UserService::getSortClauseBySortField (   $sortField,
  $sortOrder = Location::SORT_ORDER_ASC 
)
protected

Instantiates a correct sort clause object based on provided location sort field and sort order.

Parameters
int$sortField
int$sortOrder
Returns

Referenced by eZ\Publish\Core\Repository\UserService\loadUsersOfUserGroup(), and eZ\Publish\Core\Repository\UserService\searchSubGroups().

eZ\Publish\Core\Repository\UserService::loadAnonymousUser ( )

Loads anonymous user.

loadUser()

Returns

Implements eZ\Publish\API\Repository\UserService.

eZ\Publish\Core\Repository\UserService::loadSubUserGroups ( APIUserGroup  $userGroup)

Loads the sub groups of a user group.

Parameters
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
Returns
[]
Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to read the user group
eZ\Publish\Core\Repository\UserService::loadUserByCredentials (   $login,
  $password 
)

Loads a user for the given login and password.

Parameters
string$login
string$passwordthe plain password
Returns
Exceptions
\eZ\Publish\API\Repository\Exceptions\NotFoundExceptionif a user with the given credentials was not found
\eZ\Publish\API\Repository\Exceptions\BadStateExceptionif multiple users with same login were found

Implements eZ\Publish\API\Repository\UserService.

eZ\Publish\Core\Repository\UserService::loadUserGroup (   $id)
eZ\Publish\Core\Repository\UserService::loadUserGroupsOfUser ( APIUser  $user)

Loads the user groups the user belongs to.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed read the user or user group
Parameters
\eZ\Publish\API\Repository\Values\User\User$user
Returns
[]
eZ\Publish\Core\Repository\UserService::loadUsersOfUserGroup ( APIUserGroup  $userGroup,
  $offset = 0,
  $limit = -1 
)

Loads the users of a user group.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to read the users or user group
Parameters
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
int$offset
int$limit
Returns
[]
eZ\Publish\Core\Repository\UserService::moveUserGroup ( APIUserGroup  $userGroup,
APIUserGroup  $newParent 
)

Moves the user group to another parent.

Parameters
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
\eZ\Publish\API\Repository\Values\User\UserGroup$newParent
Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to move the user group
eZ\Publish\Core\Repository\UserService::newUserCreateStruct (   $login,
  $email,
  $password,
  $mainLanguageCode,
  $contentType = null 
)

Instantiate a user create class.

Parameters
string$loginthe login of the new user
string$emailthe email of the new user
string$passwordthe plain password of the new user
string$mainLanguageCodethe main language for the underlying content object
\eZ\Publish\API\Repository\Values\ContentType\ContentType$contentType5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration
Returns

Implements eZ\Publish\API\Repository\UserService.

eZ\Publish\Core\Repository\UserService::newUserGroupCreateStruct (   $mainLanguageCode,
  $contentType = null 
)

Instantiate a user group create class.

Parameters
string$mainLanguageCodeThe main language for the underlying content object
null | \eZ\Publish\API\Repository\Values\ContentType\ContentType$contentType5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration
Returns

Implements eZ\Publish\API\Repository\UserService.

eZ\Publish\Core\Repository\UserService::newUserGroupUpdateStruct ( )

Instantiate a new user group update struct.

Returns

Implements eZ\Publish\API\Repository\UserService.

eZ\Publish\Core\Repository\UserService::newUserUpdateStruct ( )

Instantiate a new user update struct.

Returns

Implements eZ\Publish\API\Repository\UserService.

eZ\Publish\Core\Repository\UserService::searchSubGroups (   $locationId,
  $sortField = null,
  $sortOrder = Location::SORT_ORDER_ASC,
  $offset = 0,
  $limit = -1 
)
protected

Returns (searches) subgroups of a user group described by its main location.

Parameters
int$locationId
int | null$sortField
int$sortOrder
int$offset
int$limit
Returns

Referenced by eZ\Publish\Core\Repository\UserService\buildDomainUserGroupObject(), and eZ\Publish\Core\Repository\UserService\loadSubUserGroups().

eZ\Publish\Core\Repository\UserService::unAssignUserFromUserGroup ( APIUser  $user,
APIUserGroup  $userGroup 
)

Removes a user group from the user.

Parameters
\eZ\Publish\API\Repository\Values\User\User$user
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to remove the user group from the user
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentExceptionif the user is not in the given user group
\eZ\Publish\API\Repository\Exceptions\BadStateExceptionIf $userGroup is the last assigned user group
eZ\Publish\Core\Repository\UserService::updateUser ( APIUser  $user,
UserUpdateStruct  $userUpdateStruct 
)

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
\eZ\Publish\API\Repository\Values\User\User$user
\eZ\Publish\API\Repository\Values\User\UserUpdateStruct$userUpdateStruct
Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to update the user
\eZ\Publish\API\Repository\Exceptions\ContentFieldValidationExceptionif a field in the $userUpdateStruct is not valid
\eZ\Publish\API\Repository\Exceptions\ContentValidationExceptionif a required field is set empty
Returns
eZ\Publish\Core\Repository\UserService::updateUserGroup ( APIUserGroup  $userGroup,
UserGroupUpdateStruct  $userGroupUpdateStruct 
)

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
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
\eZ\Publish\API\Repository\Values\User\UserGroupUpdateStruct$userGroupUpdateStruct
Returns
Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to update the user group
\eZ\Publish\API\Repository\Exceptions\ContentFieldValidationExceptionif a field in the $userGroupUpdateStruct is not valid
\eZ\Publish\API\Repository\Exceptions\ContentValidationExceptionif a required field is set empty

Member Data Documentation

eZ\Publish\Core\Repository\UserService::$repository
protected
eZ\Publish\Core\Repository\UserService::$settings
protected
eZ\Publish\Core\Repository\UserService::$userHandler
protected

The documentation for this class was generated from the following file: