Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added backend users #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions Classes/Provider/BackendUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

use TYPO3\CMS\Beuser\Domain\Model\BackendUser;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Service\ImageService;

class BackendUserProvider implements DataProviderInterface
{
Expand All @@ -28,20 +30,44 @@ public function get(array $data)
{

$this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$this->backendUserRepository = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\BackendUserRepository');
$this->backendUserRepository = $this->objectManager->get('TYPO3\\CMS\\Beuser\\Domain\\Repository\\BackendUserRepository');

/** @var BackendUser[] $backendUsers */
$backendUsers = $this->backendUserRepository->findAll();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please just use TYPO3_DB and not extbase

foreach($backendUsers as $backendUser)
{
$data['users']['backend'][] = array(
$backendUserData = array(
'userName' => $backendUser->getUserName(),
'realName' => $backendUser->getRealName(),
'emailAddress' => $backendUser->getEmail(),
'description' => $backendUser->getDescription(),
'lastLogin' => $backendUser->getLastLoginDateAndTime()
'lastLogin' => $backendUser->getLastLoginDateAndTime(),
'avatar' => ''
);
if (GeneralUtility::compat_version('7.5')) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the avatar, I don't see any need for that and it requires a lot of code to get all this info in an eID call which should be fast

$backendUserData['avatar'] = $this->getAvatarUrl($backendUser->getUid());
}
$data['users']['backend'][] = $backendUserData;
}

return $data;
}

protected function getAvatarUrl($beUserUid)
{
$fileRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
$fileObjects = $fileRepository->findByRelation('be_users', 'avatar', $beUserUid);
if(count($fileObjects) > 0)
{
$fileObject = $fileObjects[0];
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$imageService = $objectManager->get(ImageService::class);
$processingInstructions = array(
'width' => '32c',
'height' => '32',
);
$processedImage = $imageService->applyProcessingInstructions($fileObject, $processingInstructions);
return $imageService->getImageUri($processedImage);
}
return NULL;
}
}