public function loadUserGroupsOfUser(APIUser $user, $offset = 0, $limit = 25)
{
$locationService = $this->repository->getLocationService();
if (!$this->repository->canUser('content', 'read', $user)) {
throw new UnauthorizedException('content', 'read');
}
$userLocations = $locationService->loadLocations($user->getVersionInfo()->getContentInfo());
$parentLocationIds = array();
foreach ($userLocations as $userLocation) {
if ($userLocation->parentLocationId !== null) {
$parentLocationIds[] = $userLocation->parentLocationId;
}
}
$searchQuery = new LocationQuery();
$searchQuery->offset = $offset;
$searchQuery->limit = $limit;
$searchQuery->performCount = false;
$searchQuery->filter = new CriterionLogicalAnd(array(new CriterionContentTypeId($this->settings['userGroupClassID']), new CriterionLocationId($parentLocationIds)));
$searchResult = $this->repository->getSearchService()->findLocations($searchQuery);
$userGroups = array();
foreach ($searchResult->searchHits as $resultItem) {
$userGroups[] = $this->buildDomainUserGroupObject($this->repository->getContentService()->internalLoadContent($resultItem->valueObject->contentInfo->id));
}
return $userGroups;
}