|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\ViewHelpers; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
use \EWW\Dpf\Security\Security; |
|
18
|
|
|
use \EWW\Dpf\Domain\Model\FrontendUser; |
|
19
|
|
|
|
|
20
|
|
|
class CreatorRoleViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* frontendUserRepository |
|
24
|
|
|
* |
|
25
|
|
|
* @var \EWW\Dpf\Domain\Repository\FrontendUserRepository |
|
26
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $frontendUserRepository = null; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* security |
|
32
|
|
|
* |
|
33
|
|
|
* @var \EWW\Dpf\Security\Security |
|
34
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $security = null; |
|
37
|
|
|
|
|
38
|
|
|
public function initializeArguments() |
|
39
|
|
|
{ |
|
40
|
|
|
parent::initializeArguments(); |
|
41
|
|
|
|
|
42
|
|
|
$this->registerArgument('feUserId', 'int', '', true); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Shows the frontend user name of the given frontenduser user id. |
|
47
|
|
|
* |
|
48
|
|
|
* @return string |
|
49
|
|
|
*/ |
|
50
|
|
|
public function render() |
|
51
|
|
|
{ |
|
52
|
|
|
$feUserId = $this->arguments['feUserId']; |
|
53
|
|
|
|
|
54
|
|
|
if ($this->security->getUser()->getUid() == $feUserId) { |
|
55
|
|
|
return "self"; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$userRole = ''; |
|
59
|
|
|
$feUser = $this->frontendUserRepository->findByUid($feUserId); |
|
60
|
|
|
if ($feUser instanceof FrontendUser) { |
|
61
|
|
|
$userRole = $feUser->getUserRole(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
if ($userRole === Security::ROLE_LIBRARIAN) { |
|
65
|
|
|
return "librarian"; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
if ($userRole == Security::ROLE_RESEARCHER) { |
|
69
|
|
|
return "user"; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return null; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|