15
15
*/
16
16
17
17
use TYPO3 \CMS \Backend \Utility \BackendUtility ;
18
+ use TYPO3 \CMS \Core \Database \ConnectionPool ;
18
19
use TYPO3 \CMS \Core \Messaging \FlashMessage ;
19
- use TYPO3 \CMS \Scheduler \AdditionalFieldProviderInterface ;
20
+ use TYPO3 \CMS \Core \Utility \GeneralUtility ;
21
+ use TYPO3 \CMS \Scheduler \AbstractAdditionalFieldProvider ;
20
22
use TYPO3 \CMS \Scheduler \Controller \SchedulerModuleController ;
23
+ use TYPO3 \CMS \Scheduler \Task \AbstractTask ;
21
24
22
25
/**
23
26
* Aditional fields provider class for usage with the Scheduler's MailFromDraft task
26
29
* @package TYPO3
27
30
* @subpackage direct_mail
28
31
*/
29
- class MailFromDraftAdditionalFields implements AdditionalFieldProviderInterface
32
+ class MailFromDraftAdditionalFields extends AbstractAdditionalFieldProvider
30
33
{
31
34
32
35
/**
@@ -35,7 +38,7 @@ class MailFromDraftAdditionalFields implements AdditionalFieldProviderInterface
35
38
*
36
39
* @param array $taskInfo reference to the array containing the info used in the add/edit form
37
40
* @param object $task when editing, reference to the current task object. Null when adding.
38
- * @param \TYPO3\CMS\Scheduler\Controller\ SchedulerModuleController $parentObject reference to the calling object (Scheduler's BE module)
41
+ * @param SchedulerModuleController $schedulerModuleController reference to the calling object (Scheduler's BE module)
39
42
*
40
43
* @return array Array containg all the information pertaining to the additional fields
41
44
* The array is multidimensional, keyed to the task class name and each field's id
@@ -45,12 +48,11 @@ class MailFromDraftAdditionalFields implements AdditionalFieldProviderInterface
45
48
* ['cshKey'] => The CSH key for the field
46
49
* ['cshLabel'] => The code of the CSH label
47
50
*/
48
- public function getAdditionalFields (array &$ taskInfo , $ task , SchedulerModuleController $ parentObject )
51
+ public function getAdditionalFields (array &$ taskInfo , $ task , SchedulerModuleController $ schedulerModuleController )
49
52
{
50
-
51
- // Initialize extra field value
53
+ // Initialize extra field value
52
54
if (empty ($ taskInfo ['selecteddraft ' ])) {
53
- if ($ parentObject ->CMD == 'edit ' ) {
55
+ if ($ schedulerModuleController ->CMD = == 'edit ' ) {
54
56
// In case of edit, and editing a test task, set to internal value if not data was submitted already
55
57
$ taskInfo ['selecteddraft ' ] = $ task ->draftUid ;
56
58
} else {
@@ -62,7 +64,7 @@ public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleCont
62
64
// fetch all available drafts
63
65
$ drafts = array ();
64
66
65
- $ queryBuilder = \ TYPO3 \ CMS \ Core \ Utility \ GeneralUtility::makeInstance (\ TYPO3 \ CMS \ Core \ Database \ ConnectionPool::class)
67
+ $ queryBuilder = GeneralUtility::makeInstance (ConnectionPool::class)
66
68
->getQueryBuilderForTable ('sys_dmail ' );
67
69
$ draftsInternal = $ queryBuilder
68
70
->select ('* ' )
@@ -99,13 +101,12 @@ public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleCont
99
101
} else {
100
102
foreach ($ drafts as $ draft ) {
101
103
// see #44577
102
- $ selected = ($ task ->draftUid == $ draft ['uid ' ] ? ' selected="selected" ' : '' );
104
+ $ selected = ($ task ->draftUid === $ draft ['uid ' ] ? ' selected="selected" ' : '' );
103
105
$ fieldHtml .= '<option value=" ' . $ draft ['uid ' ] . '" ' . $ selected . '> ' . $ draft ['subject ' ] . ' [ ' . $ draft ['uid ' ] . ']</option> ' ;
104
106
}
105
107
}
106
108
$ fieldHtml = '<select name="tx_scheduler[selecteddraft]" id=" ' . $ fieldID . '"> ' . $ fieldHtml . '</select> ' ;
107
109
108
-
109
110
$ additionalFields = array ();
110
111
$ additionalFields [$ fieldID ] = array (
111
112
'code ' => $ fieldHtml ,
@@ -124,17 +125,17 @@ public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleCont
124
125
* If the task class is not relevant, the method is expected to return true
125
126
*
126
127
* @param array $submittedData Reference to the array containing the data submitted by the user
127
- * @param \TYPO3\CMS\Scheduler\Controller\ SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
128
+ * @param SchedulerModuleController $schedulerModuleController Reference to the calling object (Scheduler's BE module)
128
129
*
129
130
* @return bool True if validation was ok (or selected class is not relevant), false otherwise
130
131
*/
131
- public function validateAdditionalFields (array &$ submittedData , \ TYPO3 \ CMS \ Scheduler \ Controller \ SchedulerModuleController $ parentObject )
132
+ public function validateAdditionalFields (array &$ submittedData , SchedulerModuleController $ schedulerModuleController )
132
133
{
133
- $ draftUid = $ submittedData ['selecteddraft ' ] = intval ( $ submittedData ['selecteddraft ' ]) ;
134
+ $ draftUid = $ submittedData ['selecteddraft ' ] = ( int ) $ submittedData ['selecteddraft ' ];
134
135
if ($ draftUid > 0 ) {
135
136
$ draftRecord = BackendUtility::getRecord ('sys_dmail ' , $ draftUid );
136
137
137
- $ queryBuilder = \ TYPO3 \ CMS \ Core \ Utility \ GeneralUtility::makeInstance (\ TYPO3 \ CMS \ Core \ Database \ ConnectionPool::class)
138
+ $ queryBuilder = GeneralUtility::makeInstance (ConnectionPool::class)
138
139
->getQueryBuilderForTable ('sys_dmail ' );
139
140
$ draftsInternal = $ queryBuilder
140
141
->select ('* ' )
@@ -145,19 +146,16 @@ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Sched
145
146
->execute ()
146
147
->fetchAll ();
147
148
148
-
149
-
150
-
151
149
if ($ draftRecord ['type ' ] == 2 || $ draftRecord ['type ' ] == 3 ) {
152
150
$ result = true ;
153
151
} else {
154
152
// TODO: localization
155
- $ parentObject ->addMessage ('No draft record selected ' , FlashMessage::ERROR );
153
+ $ this ->addMessage ('No draft record selected ' , FlashMessage::ERROR );
156
154
$ result = false ;
157
155
}
158
156
} else {
159
157
// TODO: localization
160
- $ parentObject ->addMessage ('No drafts found. Please add one first through the direct mail process ' , FlashMessage::ERROR );
158
+ $ this ->addMessage ('No drafts found. Please add one first through the direct mail process ' , FlashMessage::ERROR );
161
159
$ result = false ;
162
160
}
163
161
@@ -169,11 +167,11 @@ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Sched
169
167
* if the task class matches
170
168
*
171
169
* @param array $submittedData Array containing the data submitted by the user
172
- * @param \TYPO3\CMS\Scheduler\Task\ AbstractTask $task Reference to the current task object
170
+ * @param AbstractTask $task Reference to the current task object
173
171
*
174
172
* @return void
175
173
*/
176
- public function saveAdditionalFields (array $ submittedData , \ TYPO3 \ CMS \ Scheduler \ Task \ AbstractTask $ task )
174
+ public function saveAdditionalFields (array $ submittedData , AbstractTask $ task )
177
175
{
178
176
$ task ->setDraft ($ submittedData ['selecteddraft ' ]);
179
177
}
0 commit comments