|
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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; |
|
18
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
19
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
|
20
|
|
|
use EWW\Dpf\Domain\Workflow\DocumentWorkflow; |
|
21
|
|
|
use \EWW\Dpf\Security\Security; |
|
22
|
|
|
use \EWW\Dpf\Domain\Repository\BookmarkRepository; |
|
23
|
|
|
|
|
24
|
|
|
class IsDocumentBookmarkableViewHelper extends AbstractViewHelper |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* |
|
28
|
|
|
* @param string $identifier |
|
29
|
|
|
* @param int $creator |
|
30
|
|
|
* @param string $state |
|
31
|
|
|
* |
|
32
|
|
|
*/ |
|
33
|
|
|
public function render($identifier, $creator, $state) |
|
34
|
|
|
{ |
|
35
|
|
|
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
|
36
|
|
|
/** @var Security $security */ |
|
37
|
|
|
$security = $objectManager->get(Security::class); |
|
38
|
|
|
|
|
39
|
|
|
/** @var BookmarkRepository $bookmarkRepository */ |
|
40
|
|
|
$bookmarkRepository = $objectManager->get(BookmarkRepository::class); |
|
41
|
|
|
|
|
42
|
|
|
if ($bookmarkRepository->findBookmark($security->getUser()->getUid(), $identifier)) { |
|
43
|
|
|
return false; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
if ($security->getUserRole() === Security::ROLE_LIBRARIAN) { |
|
47
|
|
|
return $state !== DocumentWorkflow::STATE_NEW_NONE; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
if ($security->getUserRole() === Security::ROLE_RESEARCHER) { |
|
51
|
|
|
return ( |
|
52
|
|
|
$security->getUser()->getUid() !== $creator && |
|
53
|
|
|
$state !== DocumentWorkflow::STATE_DISCARDED_NONE && |
|
54
|
|
|
$state !== DocumentWorkflow::STATE_NONE_DELETED |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
return false; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|