Commit a88c1990 authored by Thomas Löffler's avatar Thomas Löffler

[TASK] First bunch of key management view bootstrapping

parent f4c02571
Pipeline #624 passed with stages
in 3 minutes and 2 seconds
......@@ -56,6 +56,9 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
$this->versionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_VersionRepository');
$this->userRepository = $this->objectManager->get(\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository::class);
$querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface::class);
$querySettings->setRespectStoragePage(false);
$this->userRepository->setDefaultQuerySettings($querySettings);
}
/**
......@@ -68,9 +71,10 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab
public function indexAction($uploaded = FALSE)
{
// get extensions by user if a user is logged in
$this->frontendUser = $this->userRepository->findByUid(1);
if (!empty($this->frontendUser)) {
$extensions = $this->extensionRepository->findByFrontendUser($this->frontendUser['username']);
$expiringExtensions = $this->extensionRepository->findByFrontendUserAndExpiring($this->frontendUser['username']);
$extensions = $this->extensionRepository->findByFrontendUser($this->frontendUser->getUsername());
$expiringExtensions = $this->extensionRepository->findByFrontendUserAndExpiring($this->frontendUser->getUsername());
$this->view->assign('extensions', $extensions);
$this->view->assign('expiringExtensions', $expiringExtensions);
$this->view->assign('uploaded', $uploaded);
......@@ -102,7 +106,7 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab
// Create extension model
$extension = $this->objectManager->get('Tx_TerFe2_Domain_Model_Extension');
$extension->setExtKey($extensionKey);
$extension->setFrontendUser($this->frontendUser['username']);
$extension->setFrontendUser($this->frontendUser->getUsername());
$this->extensionRepository->add($extension);
$this->addFlashMessage(
......@@ -266,10 +270,10 @@ class Tx_TerFe2_Controller_RegisterkeyController extends Tx_TerFe2_Controller_Ab
{
// check if the extension belongs to the current user
if ($this->securityRole->isReviewer() or $extension->getFrontendUser() == $this->userRepository->findCurrent()) {
if ($this->securityRole->isReviewer() || $extension->getFrontendUser() === $this->frontendUser->getUsername()) {
$this->view->assign('extension', $extension);
$this->view->assign('loggedIn', $this->userRepository->findCurrent());
$this->view->assign('loggedIn', $this->frontendUser);
} else {
$this->addFlashMessage($this->translate('registerkey.notyourextension'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
$this->redirect('index', 'Registerkey');
......
......@@ -150,16 +150,16 @@ class Tx_TerFe2_Domain_Repository_ExtensionRepository extends Tx_TerFe2_Domain_R
/**
*
* @param string $frontendUser
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage Objects
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findByFrontendUser($frontendUser)
{
$query = $this->createQuery();
$query->setOrderings(
array('extKey' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING)
['extKey' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING]
);
$query->matching($query->equals('frontendUser', $frontendUser));
$this->match($query, $query->like('frontendUser', $frontendUser));
return $query->execute();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment