1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the |
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace DERHANSEN\SfEventMgt\Controller; |
13
|
|
|
|
14
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Dto\UserRegistrationDemand; |
15
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Registration; |
16
|
|
|
use Psr\Http\Message\ResponseInterface; |
17
|
|
|
use TYPO3\CMS\Core\Error\Http\PageNotFoundException; |
18
|
|
|
use TYPO3\CMS\Core\Http\PropagateResponseException; |
19
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
20
|
|
|
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication; |
21
|
|
|
use TYPO3\CMS\Frontend\Controller\ErrorController; |
22
|
|
|
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; |
23
|
|
|
|
24
|
|
|
class UserRegistrationController extends AbstractController |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Shows a list of all registration of the current frontend user |
28
|
|
|
*/ |
29
|
|
|
public function listAction(): ResponseInterface |
30
|
|
|
{ |
31
|
|
|
$demand = UserRegistrationDemand::createFromSettings($this->settings); |
32
|
|
|
$demand->setUser($this->registrationService->getCurrentFeUserObject()); |
33
|
|
|
$registrations = $this->registrationRepository->findRegistrationsByUserRegistrationDemand($demand); |
34
|
|
|
$this->view->assign('registrations', $registrations); |
35
|
|
|
|
36
|
|
|
return $this->htmlResponse(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Shows a detail page for the given registration |
41
|
|
|
*/ |
42
|
|
|
public function detailAction(Registration $registration): ResponseInterface |
43
|
|
|
{ |
44
|
|
|
$this->checkRegistrationAccess($registration); |
45
|
|
|
$this->view->assign('registration', $registration); |
46
|
|
|
|
47
|
|
|
return $this->htmlResponse(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Checks, if the given registration belongs to the current logged in frontend user. If not, a |
52
|
|
|
* page not found response is thrown. |
53
|
|
|
* |
54
|
|
|
* @param Registration $registration |
55
|
|
|
* @throws PropagateResponseException |
56
|
|
|
* @throws PageNotFoundException |
57
|
|
|
*/ |
58
|
|
|
public function checkRegistrationAccess(Registration $registration): void |
59
|
|
|
{ |
60
|
|
|
if (!$this->getFrontendUser()->user || |
61
|
|
|
!$registration->getFeUser() || |
62
|
|
|
$this->getFrontendUser()->user['uid'] !== (int)$registration->getFeUser()->getUid()) { |
63
|
|
|
$response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( |
64
|
|
|
$this->request, |
65
|
|
|
'Registration not found.' |
66
|
|
|
); |
67
|
|
|
throw new PropagateResponseException($response, 1671627320); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
protected function getFrontendUser(): FrontendUserAuthentication |
72
|
|
|
{ |
73
|
|
|
return $this->getTypoScriptFrontendController()->fe_user; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController |
77
|
|
|
{ |
78
|
|
|
return $GLOBALS['TSFE'] ?? null; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|