1
|
|
|
<?php |
2
|
|
|
namespace DERHANSEN\SfEventMgt\ViewHelpers\Be; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please read the |
8
|
|
|
* LICENSE.txt file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Abstract Record viewhelper for backend links |
15
|
|
|
* |
16
|
|
|
* @author Torben Hansen <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
class IsActionEnabledViewHelper extends AbstractViewHelper |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Initialize arguments |
22
|
|
|
*/ |
23
|
|
|
public function initializeArguments() |
24
|
|
|
{ |
25
|
|
|
$this->registerArgument('action', 'string', 'Name of the action', true); |
26
|
|
|
$this->registerArgument('settings', 'array', 'Settings for backend module', true); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Renders a edit link for the given Event UID |
31
|
|
|
* |
32
|
|
|
* @return string |
33
|
|
|
*/ |
34
|
|
|
public function render() |
35
|
|
|
{ |
36
|
|
|
$action = $this->arguments['action']; |
37
|
|
|
$settings = $this->arguments['settings']; |
38
|
|
|
$result = isset($settings['enabledActions'][$action]) && |
39
|
|
|
(int)$settings['enabledActions'][$action] === 1 |
40
|
|
|
&& $this->checkAccess($action); |
41
|
|
|
|
42
|
|
|
return $result; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Checks, if the current backend user has sufficient table permissions to perform the given action |
47
|
|
|
* |
48
|
|
|
* @param string $action |
49
|
|
|
* @return bool |
50
|
|
|
*/ |
51
|
|
|
private function checkAccess(string $action) |
52
|
|
|
{ |
53
|
|
|
$result = false; |
54
|
|
|
switch ($action) { |
55
|
|
|
case 'notify': |
56
|
|
|
$result = $this->getBackendUser()->check( |
57
|
|
|
'tables_select', |
58
|
|
|
'tx_sfeventmgt_domain_model_customnotificationlog' |
59
|
|
|
); |
60
|
|
|
break; |
61
|
|
|
case 'export': |
62
|
|
|
$result = $this->getBackendUser()->check('tables_select', 'tx_sfeventmgt_domain_model_registration') && |
63
|
|
|
$this->getBackendUser()->check( |
64
|
|
|
'tables_select', |
65
|
|
|
'tx_sfeventmgt_domain_model_registration_field' |
66
|
|
|
) && |
67
|
|
|
$this->getBackendUser()->check( |
68
|
|
|
'tables_select', |
69
|
|
|
'tx_sfeventmgt_domain_model_registration_fieldvalue' |
70
|
|
|
); |
71
|
|
|
break; |
72
|
|
|
default: |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
return $result; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return mixed|\TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
80
|
|
|
*/ |
81
|
|
|
private function getBackendUser() |
82
|
|
|
{ |
83
|
|
|
return $GLOBALS['BE_USER']; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|