|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Copyright (C) 2018 |
|
5
|
|
|
* Nathan Boiron <[email protected]> |
|
6
|
|
|
* Romain Canon <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This file is part of the TYPO3 NotiZ project. |
|
9
|
|
|
* It is free software; you can redistribute it and/or modify it |
|
10
|
|
|
* under the terms of the GNU General Public License, either |
|
11
|
|
|
* version 3 of the License, or any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* For the full copyright and license information, see: |
|
14
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace CuyZ\Notiz\Service\Hook; |
|
18
|
|
|
|
|
19
|
|
|
use TYPO3\CMS\Core\Database\DatabaseConnection; |
|
20
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
|
21
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Utility class that allows TYPO3 v7 to handle the FlexForm for notifications |
|
25
|
|
|
* fields. |
|
26
|
|
|
* |
|
27
|
|
|
* @deprecated Must be removed when TYPO3 v7 is not supported anymore. |
|
28
|
|
|
*/ |
|
29
|
|
|
class NotificationFlexFormProcessor implements SingletonInterface |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @var array |
|
33
|
|
|
*/ |
|
34
|
|
|
protected static $handledTables = [ |
|
35
|
|
|
'tx_notiz_domain_model_entityemailnotification' => 'event_configuration_flex', |
|
36
|
|
|
'tx_notiz_domain_model_entitylognotification' => 'event_configuration_flex' |
|
37
|
|
|
]; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param array $flexFormArray |
|
41
|
|
|
* @param array $conf |
|
42
|
|
|
* @param array $row |
|
43
|
|
|
* @param string $table |
|
44
|
|
|
* @param string $fieldName |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getFlexFormDS_postProcessDS(&$flexFormArray, $conf, $row, $table, $fieldName) |
|
47
|
|
|
{ |
|
48
|
|
|
$flag = false; |
|
49
|
|
|
|
|
50
|
|
|
foreach (self::$handledTables as $handledTable => $handledField) { |
|
51
|
|
|
if ($handledTable === $table |
|
52
|
|
|
&& $handledField === $fieldName |
|
53
|
|
|
&& 0 !== $row['sys_language_uid'] |
|
54
|
|
|
) { |
|
55
|
|
|
$flag = true; |
|
56
|
|
|
break; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
if (!$flag) { |
|
61
|
|
|
return; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$parent = $this->getDatabaseConnection() |
|
65
|
|
|
->exec_SELECTgetSingleRow( |
|
66
|
|
|
'event', |
|
67
|
|
|
$table, |
|
68
|
|
|
'uid=' . (int)$row['l10n_parent'] |
|
69
|
|
|
); |
|
70
|
|
|
|
|
71
|
|
|
if (!$parent) { |
|
72
|
|
|
return; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
$event = $parent['event']; |
|
76
|
|
|
|
|
77
|
|
|
if (!isset($conf['ds'][$event])) { |
|
78
|
|
|
return; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
$ds = $conf['ds'][$event]; |
|
82
|
|
|
|
|
83
|
|
|
if (substr($ds, 0, 5) == 'FILE:') { |
|
84
|
|
|
$file = GeneralUtility::getFileAbsFileName(substr($ds, 5)); |
|
85
|
|
|
|
|
86
|
|
|
if ($file && @is_file($file)) { |
|
87
|
|
|
$flexFormArray = GeneralUtility::xml2array(GeneralUtility::getUrl($file)); |
|
|
|
|
|
|
88
|
|
|
} else { |
|
89
|
|
|
$flexFormArray = 'The file "' . substr($ds, 5) . '" in ds-array key "' . $event . '" was not found ("' . $file . '")'; |
|
90
|
|
|
} |
|
91
|
|
|
} else { |
|
92
|
|
|
$flexFormArray = GeneralUtility::xml2array($ds); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @return DatabaseConnection |
|
98
|
|
|
*/ |
|
99
|
|
|
protected function getDatabaseConnection() |
|
100
|
|
|
{ |
|
101
|
|
|
return $GLOBALS['TYPO3_DB']; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|