|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU General Public License version 3 or later. |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Hooks and helper for the extension manager. |
|
14
|
|
|
* |
|
15
|
|
|
* @author Sebastian Meyer <[email protected]> |
|
16
|
|
|
* @package TYPO3 |
|
17
|
|
|
* @subpackage tx_dlf |
|
18
|
|
|
* @access public |
|
19
|
|
|
*/ |
|
20
|
|
|
class tx_dlf_em { |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* This holds the current configuration |
|
24
|
|
|
* |
|
25
|
|
|
* @var array |
|
26
|
|
|
* @access protected |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $conf = array (); |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* This holds the output ready to return |
|
32
|
|
|
* |
|
33
|
|
|
* @var string |
|
34
|
|
|
* @access protected |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $content = ''; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Check if a connection to a Solr server could be established with the given credentials. |
|
40
|
|
|
* |
|
41
|
|
|
* @access public |
|
42
|
|
|
* |
|
43
|
|
|
* @param array &$params: An array with parameters |
|
44
|
|
|
* @param \TYPO3\CMS\Core\TypoScript\ConfigurationForm &$pObj: The parent object |
|
|
|
|
|
|
45
|
|
|
* |
|
46
|
|
|
* @return string Message informing the user of success or failure |
|
47
|
|
|
*/ |
|
48
|
|
|
public function checkSolrConnection(&$params, &$pObj) { |
|
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
// Prepend username and password to hostname. |
|
51
|
|
|
if (!empty($this->conf['solrUser']) && !empty($this->conf['solrPass'])) { |
|
52
|
|
|
|
|
53
|
|
|
$host = $this->conf['solrUser'].':'.$this->conf['solrPass'].'@'.(!empty($this->conf['solrHost']) ? $this->conf['solrHost'] : 'localhost'); |
|
54
|
|
|
|
|
55
|
|
|
} else { |
|
56
|
|
|
|
|
57
|
|
|
$host = (!empty($this->conf['solrHost']) ? $this->conf['solrHost'] : 'localhost'); |
|
58
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
// Set port if not set. |
|
62
|
|
|
$port = (!empty($this->conf['solrPort']) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->conf['solrPort'], 0, 65535, 8180) : 8180); |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
// Trim path and append trailing slash. |
|
65
|
|
|
$path = (!empty($this->conf['solrPath']) ? trim($this->conf['solrPath'], '/').'/' : ''); |
|
66
|
|
|
|
|
67
|
|
|
// Build request URI. |
|
68
|
|
|
$url = 'http://'.$host.':'.$port.'/'.$path.'admin/cores?wt=xml'; |
|
69
|
|
|
|
|
70
|
|
|
$context = stream_context_create(array ( |
|
71
|
|
|
'http' => array ( |
|
72
|
|
|
'method' => 'GET', |
|
73
|
|
|
'user_agent' => (!empty($this->conf['useragent']) ? $this->conf['useragent'] : ini_get('user_agent')) |
|
74
|
|
|
) |
|
75
|
|
|
)); |
|
76
|
|
|
|
|
77
|
|
|
// Try to connect to Solr server. |
|
78
|
|
|
$response = @simplexml_load_string(file_get_contents($url, FALSE, $context)); |
|
79
|
|
|
|
|
80
|
|
|
// Check status code. |
|
81
|
|
|
if ($response) { |
|
82
|
|
|
|
|
83
|
|
|
$status = $response->xpath('//lst[@name="responseHeader"]/int[@name="status"]'); |
|
84
|
|
|
|
|
85
|
|
|
if (is_array($status)) { |
|
86
|
|
|
|
|
87
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
|
|
|
|
|
88
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
89
|
|
|
sprintf($GLOBALS['LANG']->getLL('solr.status'), (string) $status[0]), |
|
90
|
|
|
$GLOBALS['LANG']->getLL('solr.connected'), |
|
91
|
|
|
($status[0] == 0 ? \TYPO3\CMS\Core\Messaging\FlashMessage::OK : \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING), |
|
|
|
|
|
|
92
|
|
|
FALSE |
|
93
|
|
|
); |
|
94
|
|
|
|
|
95
|
|
|
$this->content .= $message->render(); |
|
96
|
|
|
|
|
97
|
|
|
return $this->content; |
|
98
|
|
|
|
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
104
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
105
|
|
|
sprintf($GLOBALS['LANG']->getLL('solr.error'), $url), |
|
106
|
|
|
$GLOBALS['LANG']->getLL('solr.notConnected'), |
|
107
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, |
|
108
|
|
|
FALSE |
|
109
|
|
|
); |
|
110
|
|
|
|
|
111
|
|
|
$this->content .= $message->render(); |
|
112
|
|
|
|
|
113
|
|
|
return $this->content; |
|
114
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Make sure a backend user exists and is configured properly. |
|
119
|
|
|
* |
|
120
|
|
|
* @access protected |
|
121
|
|
|
* |
|
122
|
|
|
* @param boolean $checkOnly: Just check the user or change it, too? |
|
123
|
|
|
* @param integer $groupUid: UID of the corresponding usergroup |
|
124
|
|
|
* |
|
125
|
|
|
* @return integer UID of user or 0 if something is wrong |
|
126
|
|
|
*/ |
|
127
|
|
|
protected function checkCliUser($checkOnly, $groupUid) { |
|
128
|
|
|
|
|
129
|
|
|
// Set default return value. |
|
130
|
|
|
$usrUid = 0; |
|
131
|
|
|
|
|
132
|
|
|
// Check if user "_cli_dlf" exists, is no admin and is not disabled. |
|
133
|
|
|
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
134
|
|
|
'uid,admin,usergroup', |
|
135
|
|
|
'be_users', |
|
136
|
|
|
'username='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_cli_dlf', 'be_users').\TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('be_users') |
|
|
|
|
|
|
137
|
|
|
); |
|
138
|
|
|
|
|
139
|
|
|
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
140
|
|
|
|
|
141
|
|
|
$resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
142
|
|
|
|
|
143
|
|
|
// Explode comma-separated list. |
|
144
|
|
|
$resArray['usergroup'] = explode(',', $resArray['usergroup']); |
|
145
|
|
|
|
|
146
|
|
|
// Check if user is not disabled. |
|
147
|
|
|
$result2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
148
|
|
|
'1', |
|
149
|
|
|
'be_users', |
|
150
|
|
|
'uid='.intval($resArray['uid']).\TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('be_users') |
|
151
|
|
|
); |
|
152
|
|
|
|
|
153
|
|
|
// Check if user is configured properly. |
|
154
|
|
|
if (count(array_diff(array ($groupUid), $resArray['usergroup'])) == 0 |
|
155
|
|
|
&& !$resArray['admin'] |
|
156
|
|
|
&& $GLOBALS['TYPO3_DB']->sql_num_rows($result2) > 0) { |
|
157
|
|
|
|
|
158
|
|
|
$usrUid = $resArray['uid']; |
|
159
|
|
|
|
|
160
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
161
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
162
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrOkayMsg'), |
|
163
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrOkay'), |
|
164
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::OK, |
|
165
|
|
|
FALSE |
|
166
|
|
|
); |
|
167
|
|
|
|
|
168
|
|
|
} else { |
|
169
|
|
|
|
|
170
|
|
|
if (!$checkOnly && $groupUid) { |
|
171
|
|
|
|
|
172
|
|
|
// Keep exisiting values and add the new ones. |
|
173
|
|
|
$usergroup = array_unique(array_merge(array ($groupUid), $resArray['usergroup'])); |
|
174
|
|
|
|
|
175
|
|
|
// Try to configure user. |
|
176
|
|
|
$data = array (); |
|
177
|
|
|
$data['be_users'][$resArray['uid']] = array ( |
|
178
|
|
|
'admin' => 0, |
|
179
|
|
|
'usergroup' => implode(',', $usergroup), |
|
180
|
|
|
$GLOBALS['TCA']['be_users']['ctrl']['enablecolumns']['disabled'] => 0, |
|
181
|
|
|
$GLOBALS['TCA']['be_users']['ctrl']['enablecolumns']['starttime'] => 0, |
|
182
|
|
|
$GLOBALS['TCA']['be_users']['ctrl']['enablecolumns']['endtime'] => 0 |
|
183
|
|
|
); |
|
184
|
|
|
|
|
185
|
|
|
tx_dlf_helper::processDBasAdmin($data); |
|
186
|
|
|
|
|
187
|
|
|
// Check if configuration was successful. |
|
188
|
|
|
if ($this->checkCliUser(TRUE, $groupUid)) { |
|
189
|
|
|
|
|
190
|
|
|
$usrUid = $resArray['uid']; |
|
191
|
|
|
|
|
192
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
193
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
194
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrConfiguredMsg'), |
|
195
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrConfigured'), |
|
196
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
|
197
|
|
|
FALSE |
|
198
|
|
|
); |
|
199
|
|
|
|
|
200
|
|
|
} else { |
|
201
|
|
|
|
|
202
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
203
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
204
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrNotConfiguredMsg'), |
|
205
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrNotConfigured'), |
|
206
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, |
|
207
|
|
|
FALSE |
|
208
|
|
|
); |
|
209
|
|
|
|
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
} else { |
|
213
|
|
|
|
|
214
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
215
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
216
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrNotConfiguredMsg'), |
|
217
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrNotConfigured'), |
|
218
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, |
|
219
|
|
|
FALSE |
|
220
|
|
|
); |
|
221
|
|
|
|
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
} else { |
|
227
|
|
|
|
|
228
|
|
|
if (!$checkOnly && $groupUid) { |
|
229
|
|
|
|
|
230
|
|
|
// Try to create user. |
|
231
|
|
|
$tempUid = uniqid('NEW'); |
|
232
|
|
|
|
|
233
|
|
|
$data = array (); |
|
234
|
|
|
$data['be_users'][$tempUid] = array ( |
|
235
|
|
|
'pid' => 0, |
|
236
|
|
|
'username' => '_cli_dlf', |
|
237
|
|
|
'password' => md5($tempUid), |
|
238
|
|
|
'realName' => $GLOBALS['LANG']->getLL('cliUserGroup.usrRealName'), |
|
239
|
|
|
'usergroup' => intval($groupUid) |
|
240
|
|
|
); |
|
241
|
|
|
|
|
242
|
|
|
$substUid = tx_dlf_helper::processDBasAdmin($data); |
|
243
|
|
|
|
|
244
|
|
|
// Check if creation was successful. |
|
245
|
|
|
if (!empty($substUid[$tempUid])) { |
|
246
|
|
|
|
|
247
|
|
|
$usrUid = $substUid[$tempUid]; |
|
248
|
|
|
|
|
249
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
250
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
251
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrCreatedMsg'), |
|
252
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrCreated'), |
|
253
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
|
254
|
|
|
FALSE |
|
255
|
|
|
); |
|
256
|
|
|
|
|
257
|
|
|
} else { |
|
258
|
|
|
|
|
259
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
260
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
261
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrNotCreatedMsg'), |
|
262
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrNotCreated'), |
|
263
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, |
|
264
|
|
|
FALSE |
|
265
|
|
|
); |
|
266
|
|
|
|
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
} else { |
|
270
|
|
|
|
|
271
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
272
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
273
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrNotCreatedMsg'), |
|
274
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.usrNotCreated'), |
|
275
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, |
|
276
|
|
|
FALSE |
|
277
|
|
|
); |
|
278
|
|
|
|
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
$this->content = $message->render(); |
|
284
|
|
|
|
|
285
|
|
|
return $usrUid; |
|
286
|
|
|
|
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* Make sure a backend usergroup exists and is configured properly. |
|
291
|
|
|
* |
|
292
|
|
|
* @access protected |
|
293
|
|
|
* |
|
294
|
|
|
* @param boolean $checkOnly: Just check the usergroup or change it, too? |
|
295
|
|
|
* @param array $settings: Array with default settings |
|
296
|
|
|
* |
|
297
|
|
|
* @return integer UID of usergroup or 0 if something is wrong |
|
298
|
|
|
*/ |
|
299
|
|
|
protected function checkCliGroup($checkOnly, $settings = array ()) { |
|
300
|
|
|
|
|
301
|
|
|
// Set default return value. |
|
302
|
|
|
$grpUid = 0; |
|
303
|
|
|
|
|
304
|
|
|
// Set default configuration for usergroup. |
|
305
|
|
|
if (empty($settings)) { |
|
306
|
|
|
|
|
307
|
|
|
$settings = array ( |
|
308
|
|
|
'non_exclude_fields' => array (), |
|
309
|
|
|
'tables_select' => array ( |
|
310
|
|
|
'tx_dlf_documents', |
|
311
|
|
|
'tx_dlf_collections', |
|
312
|
|
|
'tx_dlf_libraries', |
|
313
|
|
|
'tx_dlf_structures', |
|
314
|
|
|
'tx_dlf_metadata', |
|
315
|
|
|
'tx_dlf_metadataformat', |
|
316
|
|
|
'tx_dlf_formats', |
|
317
|
|
|
'tx_dlf_solrcores' |
|
318
|
|
|
), |
|
319
|
|
|
'tables_modify' => array ( |
|
320
|
|
|
'tx_dlf_documents', |
|
321
|
|
|
'tx_dlf_collections', |
|
322
|
|
|
'tx_dlf_libraries' |
|
323
|
|
|
) |
|
324
|
|
|
); |
|
325
|
|
|
|
|
326
|
|
|
// Set allowed exclude fields. |
|
327
|
|
|
foreach ($settings['tables_modify'] as $table) { |
|
328
|
|
|
|
|
329
|
|
|
foreach ($GLOBALS['TCA'][$table]['columns'] as $field => $fieldConf) { |
|
330
|
|
|
|
|
331
|
|
|
if (!empty($fieldConf['exclude'])) { |
|
332
|
|
|
|
|
333
|
|
|
$settings['non_exclude_fields'][] = $table.':'.$field; |
|
334
|
|
|
|
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
} |
|
340
|
|
|
|
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
// Check if group "_cli_dlf" exists and is not disabled. |
|
344
|
|
|
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
345
|
|
|
'uid,non_exclude_fields,tables_select,tables_modify,'. |
|
346
|
|
|
$GLOBALS['TCA']['be_groups']['ctrl']['enablecolumns']['disabled'], |
|
347
|
|
|
'be_groups', |
|
348
|
|
|
'title='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_cli_dlf', 'be_groups'). |
|
349
|
|
|
\TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('be_groups') |
|
350
|
|
|
); |
|
351
|
|
|
|
|
352
|
|
|
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
353
|
|
|
|
|
354
|
|
|
$resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
355
|
|
|
|
|
356
|
|
|
// Explode comma-separated lists. |
|
357
|
|
|
$resArray['non_exclude_fields'] = explode(',', $resArray['non_exclude_fields']); |
|
358
|
|
|
|
|
359
|
|
|
$resArray['tables_select'] = explode(',', $resArray['tables_select']); |
|
360
|
|
|
|
|
361
|
|
|
$resArray['tables_modify'] = explode(',', $resArray['tables_modify']); |
|
362
|
|
|
|
|
363
|
|
|
// Check if usergroup is configured properly. |
|
364
|
|
|
if (count(array_diff($settings['non_exclude_fields'], $resArray['non_exclude_fields'])) == 0 |
|
365
|
|
|
&& count(array_diff($settings['tables_select'], $resArray['tables_select'])) == 0 |
|
366
|
|
|
&& count(array_diff($settings['tables_modify'], $resArray['tables_modify'])) == 0 |
|
367
|
|
|
&& $resArray[$GLOBALS['TCA']['be_groups']['ctrl']['enablecolumns']['disabled']] == 0) { |
|
368
|
|
|
|
|
369
|
|
|
$grpUid = $resArray['uid']; |
|
370
|
|
|
|
|
371
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
372
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
373
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpOkayMsg'), |
|
374
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpOkay'), |
|
375
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::OK, |
|
376
|
|
|
FALSE |
|
377
|
|
|
); |
|
378
|
|
|
|
|
379
|
|
|
} else { |
|
380
|
|
|
|
|
381
|
|
|
if (!$checkOnly) { |
|
382
|
|
|
|
|
383
|
|
|
// Keep exisiting values and add the new ones. |
|
384
|
|
|
$non_exclude_fields = array_unique(array_merge($settings['non_exclude_fields'], $resArray['non_exclude_fields'])); |
|
385
|
|
|
|
|
386
|
|
|
$tables_select = array_unique(array_merge($settings['tables_select'], $resArray['tables_select'])); |
|
387
|
|
|
|
|
388
|
|
|
$tables_modify = array_unique(array_merge($settings['tables_modify'], $resArray['tables_modify'])); |
|
389
|
|
|
|
|
390
|
|
|
// Try to configure usergroup. |
|
391
|
|
|
$data = array (); |
|
392
|
|
|
$data['be_groups'][$resArray['uid']] = array ( |
|
393
|
|
|
'non_exclude_fields' => implode(',', $non_exclude_fields), |
|
394
|
|
|
'tables_select' => implode(',', $tables_select), |
|
395
|
|
|
'tables_modify' => implode(',', $tables_modify), |
|
396
|
|
|
$GLOBALS['TCA']['be_groups']['ctrl']['enablecolumns']['disabled'] => 0 |
|
397
|
|
|
); |
|
398
|
|
|
|
|
399
|
|
|
tx_dlf_helper::processDBasAdmin($data); |
|
400
|
|
|
|
|
401
|
|
|
// Check if configuration was successful. |
|
402
|
|
|
if ($this->checkCliGroup(TRUE, $settings)) { |
|
403
|
|
|
|
|
404
|
|
|
$grpUid = $resArray['uid']; |
|
405
|
|
|
|
|
406
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
407
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
408
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpConfiguredMsg'), |
|
409
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpConfigured'), |
|
410
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
|
411
|
|
|
FALSE |
|
412
|
|
|
); |
|
413
|
|
|
|
|
414
|
|
|
} else { |
|
415
|
|
|
|
|
416
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
417
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
418
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpNotConfiguredMsg'), |
|
419
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpNotConfigured'), |
|
420
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, |
|
421
|
|
|
FALSE |
|
422
|
|
|
); |
|
423
|
|
|
|
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
} else { |
|
427
|
|
|
|
|
428
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
429
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
430
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpNotConfiguredMsg'), |
|
431
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpNotConfigured'), |
|
432
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, |
|
433
|
|
|
FALSE |
|
434
|
|
|
); |
|
435
|
|
|
|
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
} |
|
439
|
|
|
|
|
440
|
|
|
} else { |
|
441
|
|
|
|
|
442
|
|
|
if (!$checkOnly) { |
|
443
|
|
|
|
|
444
|
|
|
// Try to create usergroup. |
|
445
|
|
|
$tempUid = uniqid('NEW'); |
|
446
|
|
|
|
|
447
|
|
|
$data = array (); |
|
448
|
|
|
$data['be_groups'][$tempUid] = array ( |
|
449
|
|
|
'pid' => 0, |
|
450
|
|
|
'title' => '_cli_dlf', |
|
451
|
|
|
'description' => $GLOBALS['LANG']->getLL('cliUserGroup.grpDescription'), |
|
452
|
|
|
'non_exclude_fields' => implode(',', $settings['non_exclude_fields']), |
|
453
|
|
|
'tables_select' => implode(',', $settings['tables_select']), |
|
454
|
|
|
'tables_modify' => implode(',', $settings['tables_modify']) |
|
455
|
|
|
); |
|
456
|
|
|
|
|
457
|
|
|
$substUid = tx_dlf_helper::processDBasAdmin($data); |
|
458
|
|
|
|
|
459
|
|
|
// Check if creation was successful. |
|
460
|
|
|
if (!empty($substUid[$tempUid])) { |
|
461
|
|
|
|
|
462
|
|
|
$grpUid = $substUid[$tempUid]; |
|
463
|
|
|
|
|
464
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
465
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
466
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpCreatedMsg'), |
|
467
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpCreated'), |
|
468
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
|
469
|
|
|
FALSE |
|
470
|
|
|
); |
|
471
|
|
|
|
|
472
|
|
|
} else { |
|
473
|
|
|
|
|
474
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
475
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
476
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpNotCreatedMsg'), |
|
477
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpNotCreated'), |
|
478
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, |
|
479
|
|
|
FALSE |
|
480
|
|
|
); |
|
481
|
|
|
|
|
482
|
|
|
} |
|
483
|
|
|
|
|
484
|
|
|
} else { |
|
485
|
|
|
|
|
486
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
487
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
488
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpNotCreatedMsg'), |
|
489
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.grpNotCreated'), |
|
490
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, |
|
491
|
|
|
FALSE |
|
492
|
|
|
); |
|
493
|
|
|
|
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
} |
|
497
|
|
|
|
|
498
|
|
|
$this->content = $message->render(); |
|
499
|
|
|
|
|
500
|
|
|
return $grpUid; |
|
501
|
|
|
|
|
502
|
|
|
} |
|
503
|
|
|
|
|
504
|
|
|
/** |
|
505
|
|
|
* Make sure a CLI user and group exist. |
|
506
|
|
|
* |
|
507
|
|
|
* @access public |
|
508
|
|
|
* |
|
509
|
|
|
* @param array &$params: An array with parameters |
|
510
|
|
|
* @param \TYPO3\CMS\Core\TypoScript\ConfigurationForm &$pObj: The parent object |
|
511
|
|
|
* |
|
512
|
|
|
* @return string Message informing the user of success or failure |
|
513
|
|
|
*/ |
|
514
|
|
|
public function checkCliUserGroup(&$params, &$pObj) { |
|
|
|
|
|
|
515
|
|
|
|
|
516
|
|
|
// Check if usergroup "_cli_dlf" exists and is configured properly. |
|
517
|
|
|
$groupUid = $this->checkCliGroup(empty($this->conf['makeCliUserGroup'])); |
|
518
|
|
|
|
|
519
|
|
|
// Save output because it will be overwritten by the user check method. |
|
520
|
|
|
$content = $this->content; |
|
521
|
|
|
|
|
522
|
|
|
// Check if user "_cli_dlf" exists and is configured properly. |
|
523
|
|
|
$userUid = $this->checkCliUser(empty($this->conf['makeCliUserGroup']), $groupUid); |
|
|
|
|
|
|
524
|
|
|
|
|
525
|
|
|
// Merge output from usergroup and user checks. |
|
526
|
|
|
$this->content .= $content; |
|
527
|
|
|
|
|
528
|
|
|
// Check if CLI dispatcher is executable. |
|
529
|
|
|
if (is_executable(PATH_typo3.'cli_dispatch.phpsh')) { |
|
|
|
|
|
|
530
|
|
|
|
|
531
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
532
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
533
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.cliOkayMsg'), |
|
534
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.cliOkay'), |
|
535
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::OK, |
|
536
|
|
|
FALSE |
|
537
|
|
|
); |
|
538
|
|
|
|
|
539
|
|
|
} else { |
|
540
|
|
|
|
|
541
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
542
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
543
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.cliNotOkayMsg'), |
|
544
|
|
|
$GLOBALS['LANG']->getLL('cliUserGroup.cliNotOkay'), |
|
545
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, |
|
546
|
|
|
FALSE |
|
547
|
|
|
); |
|
548
|
|
|
|
|
549
|
|
|
} |
|
550
|
|
|
|
|
551
|
|
|
$this->content .= $message->render(); |
|
552
|
|
|
|
|
553
|
|
|
return $this->content; |
|
554
|
|
|
|
|
555
|
|
|
} |
|
556
|
|
|
|
|
557
|
|
|
/** |
|
558
|
|
|
* Make sure the essential namespaces are defined. |
|
559
|
|
|
* |
|
560
|
|
|
* @access public |
|
561
|
|
|
* |
|
562
|
|
|
* @param array &$params: An array with parameters |
|
563
|
|
|
* @param \TYPO3\CMS\Core\TypoScript\ConfigurationForm &$pObj: The parent object |
|
564
|
|
|
* |
|
565
|
|
|
* @return string Message informing the user of success or failure |
|
566
|
|
|
*/ |
|
567
|
|
|
public function checkMetadataFormats(&$params, &$pObj) { |
|
|
|
|
|
|
568
|
|
|
|
|
569
|
|
|
$nsDefined = array ( |
|
570
|
|
|
'MODS' => FALSE, |
|
571
|
|
|
'TEIHDR' => FALSE |
|
572
|
|
|
); |
|
573
|
|
|
|
|
574
|
|
|
// Check if formats "MODS" and "TEIHDR" exist. |
|
575
|
|
|
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
576
|
|
|
'type', |
|
577
|
|
|
'tx_dlf_formats', |
|
578
|
|
|
'(type='.$GLOBALS['TYPO3_DB']->fullQuoteStr('MODS', 'tx_dlf_formats').' OR type='.$GLOBALS['TYPO3_DB']->fullQuoteStr('TEIHDR', 'tx_dlf_formats').')'.tx_dlf_helper::whereClause('tx_dlf_formats') |
|
579
|
|
|
); |
|
580
|
|
|
|
|
581
|
|
|
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
582
|
|
|
|
|
583
|
|
|
$nsDefined[$resArray['type']] = TRUE; |
|
584
|
|
|
|
|
585
|
|
|
} |
|
586
|
|
|
|
|
587
|
|
|
// Build data array. |
|
588
|
|
|
$data = array (); |
|
589
|
|
|
|
|
590
|
|
|
// Add MODS namespace. |
|
591
|
|
|
if (!$nsDefined['MODS']) { |
|
592
|
|
|
|
|
593
|
|
|
$data['tx_dlf_formats'][uniqid('NEW')] = array ( |
|
594
|
|
|
'pid' => 0, |
|
595
|
|
|
'type' => 'MODS', |
|
596
|
|
|
'root' => 'mods', |
|
597
|
|
|
'namespace' => 'http://www.loc.gov/mods/v3', |
|
598
|
|
|
'class' => 'tx_dlf_mods' |
|
599
|
|
|
); |
|
600
|
|
|
|
|
601
|
|
|
} |
|
602
|
|
|
|
|
603
|
|
|
// Add TEIHDR namespace. |
|
604
|
|
|
if (!$nsDefined['TEIHDR']) { |
|
605
|
|
|
|
|
606
|
|
|
$data['tx_dlf_formats'][uniqid('NEW')] = array ( |
|
607
|
|
|
'pid' => 0, |
|
608
|
|
|
'type' => 'TEIHDR', |
|
609
|
|
|
'root' => 'teiHeader', |
|
610
|
|
|
'namespace' => 'http://www.tei-c.org/ns/1.0', |
|
611
|
|
|
'class' => 'tx_dlf_teihdr' |
|
612
|
|
|
); |
|
613
|
|
|
|
|
614
|
|
|
} |
|
615
|
|
|
|
|
616
|
|
|
if (!empty($data)) { |
|
617
|
|
|
|
|
618
|
|
|
// Process changes. |
|
619
|
|
|
$substUid = tx_dlf_helper::processDBasAdmin($data); |
|
620
|
|
|
|
|
621
|
|
|
if (!empty($substUid)) { |
|
622
|
|
|
|
|
623
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
624
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
625
|
|
|
$GLOBALS['LANG']->getLL('metadataFormats.nsCreatedMsg'), |
|
626
|
|
|
$GLOBALS['LANG']->getLL('metadataFormats.nsCreated'), |
|
627
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
|
628
|
|
|
FALSE |
|
629
|
|
|
); |
|
630
|
|
|
|
|
631
|
|
|
} else { |
|
632
|
|
|
|
|
633
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
634
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
635
|
|
|
$GLOBALS['LANG']->getLL('metadataFormats.nsNotCreatedMsg'), |
|
636
|
|
|
$GLOBALS['LANG']->getLL('metadataFormats.nsNotCreated'), |
|
637
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, |
|
638
|
|
|
FALSE |
|
639
|
|
|
); |
|
640
|
|
|
|
|
641
|
|
|
} |
|
642
|
|
|
|
|
643
|
|
|
} else { |
|
644
|
|
|
|
|
645
|
|
|
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
646
|
|
|
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
647
|
|
|
$GLOBALS['LANG']->getLL('metadataFormats.nsOkayMsg'), |
|
648
|
|
|
$GLOBALS['LANG']->getLL('metadataFormats.nsOkay'), |
|
649
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::OK, |
|
650
|
|
|
FALSE |
|
651
|
|
|
); |
|
652
|
|
|
|
|
653
|
|
|
} |
|
654
|
|
|
|
|
655
|
|
|
$this->content .= $message->render(); |
|
656
|
|
|
|
|
657
|
|
|
return $this->content; |
|
658
|
|
|
|
|
659
|
|
|
} |
|
660
|
|
|
|
|
661
|
|
|
/** |
|
662
|
|
|
* This is the constructor. |
|
663
|
|
|
* |
|
664
|
|
|
* @access public |
|
665
|
|
|
* |
|
666
|
|
|
* @return void |
|
667
|
|
|
*/ |
|
668
|
|
|
public function __construct() { |
|
669
|
|
|
|
|
670
|
|
|
// Load localization file. |
|
671
|
|
|
$GLOBALS['LANG']->includeLLFile('EXT:dlf/locallang.xml'); |
|
672
|
|
|
|
|
673
|
|
|
// Get current configuration. |
|
674
|
|
|
$this->conf = array_merge((array) unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']), (array) \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('data')); |
|
675
|
|
|
|
|
676
|
|
|
} |
|
677
|
|
|
|
|
678
|
|
|
} |
|
679
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths