|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\Controller; |
|
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 EWW\Dpf\Domain\Model\Document; |
|
18
|
|
|
use EWW\Dpf\Helper\DocumentMapper; |
|
19
|
|
|
use EWW\Dpf\Exceptions\AccessDeniedExcepion; |
|
|
|
|
|
|
20
|
|
|
use EWW\Dpf\Security\DocumentVoter; |
|
21
|
|
|
use EWW\Dpf\Security\Security; |
|
22
|
|
|
use EWW\Dpf\Exceptions\DPFExceptionInterface; |
|
23
|
|
|
use EWW\Dpf\Domain\Workflow\DocumentWorkflow; |
|
24
|
|
|
use EWW\Dpf\Services\Email\Notifier; |
|
25
|
|
|
use EWW\Dpf\Services\Transfer\DocumentTransferManager; |
|
26
|
|
|
use EWW\Dpf\Services\Transfer\FedoraRepository; |
|
27
|
|
|
use EWW\Dpf\Domain\Model\DepositLicenseLog; |
|
28
|
|
|
use TYPO3\CMS\Core\Messaging\AbstractMessage; |
|
29
|
|
|
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; |
|
30
|
|
|
|
|
31
|
|
|
use TYPO3\CMS\Extbase\Persistence\ObjectStorage; |
|
32
|
|
|
|
|
33
|
|
|
class DocumentFormBackofficeController extends AbstractDocumentFormController |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* documentTransferManager |
|
37
|
|
|
* |
|
38
|
|
|
* @var \EWW\Dpf\Services\Transfer\DocumentTransferManager $documentTransferManager |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $documentTransferManager; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* fedoraRepository |
|
44
|
|
|
* |
|
45
|
|
|
* @var \EWW\Dpf\Services\Transfer\FedoraRepository $fedoraRepository |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $fedoraRepository; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* editingLockService |
|
51
|
|
|
* |
|
52
|
|
|
* @var \EWW\Dpf\Services\Document\EditingLockService |
|
53
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $editingLockService = null; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* documentManager |
|
59
|
|
|
* |
|
60
|
|
|
* @var \EWW\Dpf\Services\Document\DocumentManager |
|
61
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $documentManager = null; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* bookmarkRepository |
|
67
|
|
|
* |
|
68
|
|
|
* @var \EWW\Dpf\Domain\Repository\BookmarkRepository |
|
69
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
70
|
|
|
*/ |
|
71
|
|
|
protected $bookmarkRepository = null; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* clientConfigurationManager |
|
75
|
|
|
* |
|
76
|
|
|
* @var \EWW\Dpf\Configuration\ClientConfigurationManager |
|
77
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
78
|
|
|
*/ |
|
79
|
|
|
protected $clientConfigurationManager; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* DocumentController constructor. |
|
83
|
|
|
*/ |
|
84
|
|
|
public function __construct() |
|
85
|
|
|
{ |
|
86
|
|
|
parent::__construct(); |
|
87
|
|
|
|
|
88
|
|
|
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
|
89
|
|
|
$this->documentTransferManager = $objectManager->get(DocumentTransferManager::class); |
|
90
|
|
|
$this->fedoraRepository = $objectManager->get(FedoraRepository::class); |
|
91
|
|
|
$this->documentTransferManager->setRemoteRepository($this->fedoraRepository); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function arrayRecursiveDiff($aArray1, $aArray2) { |
|
95
|
|
|
$aReturn = array(); |
|
96
|
|
|
|
|
97
|
|
|
foreach ($aArray1 as $mKey => $mValue) { |
|
98
|
|
|
if (array_key_exists($mKey, $aArray2)) { |
|
99
|
|
|
if (is_array($mValue)) { |
|
100
|
|
|
$aRecursiveDiff = $this->arrayRecursiveDiff($mValue, $aArray2[$mKey]); |
|
101
|
|
|
if (count($aRecursiveDiff)) { $aReturn[$mKey] = $aRecursiveDiff; } |
|
102
|
|
|
} else { |
|
103
|
|
|
if ($mValue != $aArray2[$mKey]) { |
|
104
|
|
|
$aReturn[$mKey] = $mValue; |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
} else { |
|
108
|
|
|
$aReturn[$mKey] = $mValue; |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
return $aReturn; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* action edit |
|
117
|
|
|
* |
|
118
|
|
|
* @param \EWW\Dpf\Domain\Model\DocumentForm $documentForm |
|
119
|
|
|
* @param bool $suggestMod |
|
120
|
|
|
* @param string activeGroup |
|
|
|
|
|
|
121
|
|
|
* @param int activeGroupIndex |
|
|
|
|
|
|
122
|
|
|
* @param bool $addCurrentFeUser |
|
123
|
|
|
* @TYPO3\CMS\Extbase\Annotation\IgnoreValidation("documentForm") |
|
124
|
|
|
* @return void |
|
125
|
|
|
*/ |
|
126
|
|
|
public function editAction( |
|
127
|
|
|
\EWW\Dpf\Domain\Model\DocumentForm $documentForm, |
|
128
|
|
|
bool $suggestMod = false, |
|
129
|
|
|
$activeGroup = '', |
|
130
|
|
|
$activeGroupIndex = 0, |
|
131
|
|
|
$addCurrentFeUser = true |
|
132
|
|
|
) |
|
133
|
|
|
{ |
|
134
|
|
|
/** @var \EWW\Dpf\Domain\Model\Document $document */ |
|
135
|
|
|
$document = $this->documentRepository->findByUid($documentForm->getDocumentUid()); |
|
136
|
|
|
|
|
137
|
|
|
if ($suggestMod) { |
|
138
|
|
|
$documentVoterAttribute = DocumentVoter::SUGGEST_MODIFICATION; |
|
139
|
|
|
} else { |
|
140
|
|
|
$documentVoterAttribute = DocumentVoter::EDIT; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
if (!$this->authorizationChecker->isGranted($documentVoterAttribute, $document)) { |
|
144
|
|
|
|
|
145
|
|
|
if ($document->getCreator() !== $this->security->getUser()->getUid()) { |
|
146
|
|
|
$message = LocalizationUtility::translate( |
|
147
|
|
|
'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_edit.accessDenied', |
|
148
|
|
|
'dpf', |
|
149
|
|
|
array($document->getTitle()) |
|
150
|
|
|
); |
|
151
|
|
|
} else { |
|
152
|
|
|
$message = LocalizationUtility::translate( |
|
153
|
|
|
'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_edit.failureBlocked', |
|
154
|
|
|
'dpf', |
|
155
|
|
|
array($document->getTitle()) |
|
156
|
|
|
); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
$this->addFlashMessage($message, '', AbstractMessage::ERROR); |
|
160
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
161
|
|
|
return FALSE; |
|
|
|
|
|
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
$this->view->assign('document', $document); |
|
165
|
|
|
$this->view->assign('suggestMod', $suggestMod); |
|
166
|
|
|
|
|
167
|
|
|
$this->editingLockService->lock( |
|
168
|
|
|
($document->getObjectIdentifier()? $document->getObjectIdentifier() : $document->getUid()), |
|
169
|
|
|
$this->security->getUser()->getUid() |
|
170
|
|
|
); |
|
171
|
|
|
|
|
172
|
|
|
$this->view->assign('activeGroup', $activeGroup); |
|
173
|
|
|
$this->view->assign('activeGroupIndex', $activeGroupIndex); |
|
174
|
|
|
$this->view->assign('addCurrentFeUser', $addCurrentFeUser); |
|
175
|
|
|
parent::editAction($documentForm); |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @param \EWW\Dpf\Domain\Model\DocumentForm $documentForm |
|
180
|
|
|
* @param bool $restore |
|
181
|
|
|
*/ |
|
182
|
|
|
public function createSuggestionDocumentAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm, $restore = FALSE) |
|
183
|
|
|
{ |
|
184
|
|
|
$documentMapper = $this->objectManager->get(DocumentMapper::class); |
|
185
|
|
|
|
|
186
|
|
|
$workingCopy = $this->documentRepository->findByUid($documentForm->getDocumentUid()); |
|
187
|
|
|
|
|
188
|
|
|
if ($workingCopy->isTemporary()) { |
|
189
|
|
|
$workingCopy->setTemporary(false); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
$newDocument = $this->objectManager->get(Document::class); |
|
193
|
|
|
|
|
194
|
|
|
$this->documentRepository->add($newDocument); |
|
195
|
|
|
$this->persistenceManager->persistAll(); |
|
196
|
|
|
|
|
197
|
|
|
/* @var $document \EWW\Dpf\Domain\Model\Document */ |
|
198
|
|
|
$document = $documentMapper->getDocument($documentForm); |
|
199
|
|
|
|
|
200
|
|
|
/* @var $newDocument \EWW\Dpf\Domain\Model\Document */ |
|
201
|
|
|
$newDocument = $newDocument->copy($document); |
|
202
|
|
|
|
|
203
|
|
|
if ($document->getObjectIdentifier()) { |
|
204
|
|
|
$newDocument->setLinkedUid($document->getObjectIdentifier()); |
|
205
|
|
|
} else { |
|
206
|
|
|
$newDocument->setLinkedUid($document->getUid()); |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
$newDocument->setSuggestion(true); |
|
210
|
|
|
$newDocument->setComment($document->getComment()); |
|
211
|
|
|
|
|
212
|
|
|
if ($restore) { |
|
213
|
|
|
$newDocument->setTransferStatus("RESTORE"); |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
if ($workingCopy->hasFiles()) { |
|
217
|
|
|
// Add or update files |
|
218
|
|
|
// TODO: Is this still necessary? |
|
219
|
|
|
foreach ($documentForm->getFiles() as $file) { |
|
220
|
|
|
// TODO: Is this still necessary? |
|
221
|
|
|
if ($file->getUID()) { |
|
222
|
|
|
$this->fileRepository->update($file); |
|
223
|
|
|
} else { |
|
224
|
|
|
$file->setDocument($newDocument); |
|
225
|
|
|
$this->fileRepository->add($file); |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
$newDocument->addFile($file); |
|
229
|
|
|
} |
|
230
|
|
|
} else { |
|
231
|
|
|
// remove files for suggest object |
|
232
|
|
|
$newDocument->setFile($this->objectManager->get(ObjectStorage::class)); |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
|
|
236
|
|
|
try { |
|
237
|
|
|
$newDocument->setCreator($this->security->getUser()->getUid()); |
|
238
|
|
|
$this->documentRepository->add($newDocument); |
|
239
|
|
|
|
|
240
|
|
|
$flashMessage = $this->clientConfigurationManager->getSuggestionFlashMessage(); |
|
241
|
|
|
if (!$flashMessage) { |
|
242
|
|
|
$flashMessage = LocalizationUtility::translate( |
|
243
|
|
|
'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:message.suggestion_flashmessage', |
|
244
|
|
|
'dpf', |
|
245
|
|
|
'' |
|
|
|
|
|
|
246
|
|
|
); |
|
247
|
|
|
} |
|
248
|
|
|
$this->addFlashMessage($flashMessage, '', AbstractMessage::OK, true); |
|
249
|
|
|
|
|
250
|
|
|
$notifier = $this->objectManager->get(Notifier::class); |
|
251
|
|
|
$notifier->sendAdminNewSuggestionNotification($newDocument); |
|
252
|
|
|
|
|
253
|
|
|
$depositLicenseLog = $this->depositLicenseLogRepository->findOneByProcessNumber($newDocument->getProcessNumber()); |
|
|
|
|
|
|
254
|
|
|
if (empty($depositLicenseLog) && $newDocument->getDepositLicense()) { |
|
255
|
|
|
// Only if there was no deposit license a notification may be sent |
|
256
|
|
|
|
|
257
|
|
|
/** @var DepositLicenseLog $depositLicenseLog */ |
|
258
|
|
|
$depositLicenseLog = $this->objectManager->get(DepositLicenseLog::class); |
|
259
|
|
|
$depositLicenseLog->setUsername($this->security->getUsername()); |
|
260
|
|
|
$depositLicenseLog->setObjectIdentifier($newDocument->getObjectIdentifier()); |
|
261
|
|
|
$depositLicenseLog->setProcessNumber($newDocument->getProcessNumber()); |
|
262
|
|
|
$depositLicenseLog->setTitle($newDocument->getTitle()); |
|
263
|
|
|
$depositLicenseLog->setUrn($newDocument->getPrimaryUrn()); |
|
264
|
|
|
$depositLicenseLog->setLicenceUri($newDocument->getDepositLicense()); |
|
265
|
|
|
|
|
266
|
|
|
if ($newDocument->hasFiles()) { |
|
267
|
|
|
$fileList = []; |
|
268
|
|
|
foreach ($newDocument->getFile() as $file) { |
|
269
|
|
|
$fileList[] = $file->getTitle(); |
|
270
|
|
|
} |
|
271
|
|
|
$depositLicenseLog->setFileNames(implode(", ", $fileList)); |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
|
|
275
|
|
|
$this->depositLicenseLogRepository->add($depositLicenseLog); |
|
276
|
|
|
|
|
277
|
|
|
/** @var Notifier $notifier */ |
|
278
|
|
|
$notifier = $this->objectManager->get(Notifier::class); |
|
279
|
|
|
$notifier->sendDepositLicenseNotification($newDocument); |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
} catch (\Throwable $t) { |
|
283
|
|
|
$severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR; |
|
284
|
|
|
$this->addFlashMessage("Failed", '', $severity,false); |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
$this->redirectToDocumentList(); |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
|
|
|
291
|
|
|
public function updateAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm) |
|
292
|
|
|
{ |
|
293
|
|
|
if ($this->request->getArgument('documentData')['suggestMod']) { |
|
294
|
|
|
$restore = $this->request->getArgument('documentData')['suggestRestore']; |
|
295
|
|
|
$this->forward('createSuggestionDocument', null, null, ['documentForm' => $documentForm, 'restore' => $restore]); |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
$backToList = $this->request->getArgument('documentData')['backToList']; |
|
299
|
|
|
|
|
300
|
|
|
if ($this->request->hasArgument('saveAndUpdate')) { |
|
301
|
|
|
$saveMode = 'saveAndUpdate'; |
|
302
|
|
|
} elseif ($this->request->hasArgument('saveWorkingCopy')) { |
|
303
|
|
|
$saveMode = 'saveWorkingCopy'; |
|
304
|
|
|
} else { |
|
305
|
|
|
$saveMode = null; |
|
306
|
|
|
} |
|
307
|
|
|
|
|
308
|
|
|
$this->forward( |
|
309
|
|
|
|
|
310
|
|
|
'updateDocument', |
|
311
|
|
|
NULL, |
|
312
|
|
|
NULL, |
|
313
|
|
|
[ |
|
314
|
|
|
'documentForm' => $documentForm, |
|
315
|
|
|
'saveMode' => $saveMode, |
|
316
|
|
|
'backToList' => $backToList |
|
317
|
|
|
] |
|
318
|
|
|
); |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
|
|
322
|
|
|
/** |
|
323
|
|
|
* @param \EWW\Dpf\Domain\Model\DocumentForm $documentForm |
|
324
|
|
|
* @param string $saveMode |
|
325
|
|
|
* @param bool $backToList |
|
326
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
|
327
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
|
328
|
|
|
*/ |
|
329
|
|
|
public function updateDocumentAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm, $saveMode = null, $backToList = false) |
|
330
|
|
|
{ |
|
331
|
|
|
try { |
|
332
|
|
|
/** @var \EWW\Dpf\Domain\Model\Document $document */ |
|
333
|
|
|
$document = $this->documentRepository->findByUid($documentForm->getDocumentUid()); |
|
334
|
|
|
$depositLicense = $document->getDepositLicense(); |
|
|
|
|
|
|
335
|
|
|
|
|
336
|
|
|
if ( |
|
337
|
|
|
!$this->authorizationChecker->isGranted(DocumentVoter::UPDATE, $document) || |
|
338
|
|
|
( |
|
339
|
|
|
$saveMode == 'saveWorkingCopy' && |
|
340
|
|
|
$this->security->getUserRole() !== Security::ROLE_LIBRARIAN |
|
341
|
|
|
) |
|
342
|
|
|
) { |
|
343
|
|
|
$message = LocalizationUtility::translate( |
|
344
|
|
|
'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.accessDenied', |
|
345
|
|
|
'dpf', |
|
346
|
|
|
array($document->getTitle()) |
|
347
|
|
|
); |
|
348
|
|
|
$this->addFlashMessage($message, '', AbstractMessage::ERROR); |
|
349
|
|
|
|
|
350
|
|
|
$this->redirect('cancelEdit', |
|
351
|
|
|
null, |
|
352
|
|
|
null, |
|
353
|
|
|
['documentUid' => $document->getUid(), 'backToList' => $backToList] |
|
354
|
|
|
); |
|
355
|
|
|
/* |
|
356
|
|
|
$this->redirect( |
|
357
|
|
|
'showDetails', 'Document', |
|
358
|
|
|
null, ['document' => $document] |
|
359
|
|
|
); |
|
360
|
|
|
*/ |
|
361
|
|
|
|
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
/** @var \EWW\Dpf\Helper\DocumentMapper $documentMapper */ |
|
365
|
|
|
$documentMapper = $this->objectManager->get(DocumentMapper::class); |
|
366
|
|
|
|
|
367
|
|
|
/** @var \EWW\Dpf\Domain\Model\Document $updateDocument */ |
|
368
|
|
|
$updateDocument = $documentMapper->getDocument($documentForm); |
|
369
|
|
|
|
|
370
|
|
|
$saveWorkingCopy = false; |
|
371
|
|
|
$workflowTransition = null; |
|
372
|
|
|
|
|
373
|
|
|
// Convert the temporary copy into a local working copy if needed. |
|
374
|
|
|
if ( $updateDocument->isTemporaryCopy() && $saveMode == 'saveWorkingCopy') { |
|
375
|
|
|
$saveWorkingCopy = true; |
|
376
|
|
|
$updateDocument->setTemporary(false); |
|
377
|
|
|
$workflowTransition = DocumentWorkflow::TRANSITION_IN_PROGRESS; |
|
378
|
|
|
} elseif ($updateDocument->isTemporaryCopy() && $saveMode == 'saveAndUpdate') { |
|
379
|
|
|
$workflowTransition = DocumentWorkflow::TRANSITION_REMOTE_UPDATE; |
|
380
|
|
|
} elseif ( |
|
381
|
|
|
$this->security->getUserRole() === Security::ROLE_LIBRARIAN && |
|
382
|
|
|
$updateDocument->getState() === DocumentWorkflow::STATE_REGISTERED_NONE |
|
383
|
|
|
) { |
|
384
|
|
|
$workflowTransition = DocumentWorkflow::TRANSITION_IN_PROGRESS; |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
if ($this->documentManager->update($updateDocument, $workflowTransition)) { |
|
388
|
|
|
|
|
389
|
|
|
$depositLicenseLog = $this->depositLicenseLogRepository->findOneByProcessNumber($document->getProcessNumber()); |
|
390
|
|
|
if (empty($depositLicenseLog) && $updateDocument->getDepositLicense()) { |
|
391
|
|
|
// Only if there was no deposit license a notification may be sent |
|
392
|
|
|
|
|
393
|
|
|
/** @var DepositLicenseLog $depositLicenseLog */ |
|
394
|
|
|
$depositLicenseLog = $this->objectManager->get(DepositLicenseLog::class); |
|
395
|
|
|
$depositLicenseLog->setUsername($this->security->getUsername()); |
|
396
|
|
|
$depositLicenseLog->setObjectIdentifier($document->getObjectIdentifier()); |
|
397
|
|
|
$depositLicenseLog->setProcessNumber($document->getProcessNumber()); |
|
398
|
|
|
$depositLicenseLog->setTitle($document->getTitle()); |
|
399
|
|
|
$depositLicenseLog->setUrn($document->getPrimaryUrn()); |
|
400
|
|
|
$depositLicenseLog->setLicenceUri($document->getDepositLicense()); |
|
401
|
|
|
|
|
402
|
|
|
if ($document->hasFiles()) { |
|
403
|
|
|
$fileList = []; |
|
404
|
|
|
foreach ($document->getFile() as $file) { |
|
405
|
|
|
$fileList[] = $file->getTitle(); |
|
406
|
|
|
} |
|
407
|
|
|
$depositLicenseLog->setFileNames(implode(", ", $fileList)); |
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
|
|
|
|
411
|
|
|
$this->depositLicenseLogRepository->add($depositLicenseLog); |
|
412
|
|
|
|
|
413
|
|
|
/** @var Notifier $notifier */ |
|
414
|
|
|
$notifier = $this->objectManager->get(Notifier::class); |
|
415
|
|
|
$notifier->sendDepositLicenseNotification($updateDocument); |
|
416
|
|
|
} |
|
417
|
|
|
|
|
418
|
|
|
$message = LocalizationUtility::translate( |
|
419
|
|
|
'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.success', |
|
420
|
|
|
'dpf', |
|
421
|
|
|
array($updateDocument->getTitle()) |
|
422
|
|
|
); |
|
423
|
|
|
$this->addFlashMessage($message, '', AbstractMessage::OK); |
|
424
|
|
|
|
|
425
|
|
|
if ($this->security->getUserRole() === Security::ROLE_LIBRARIAN) { |
|
426
|
|
|
if ($saveWorkingCopy) { |
|
427
|
|
|
if ( |
|
428
|
|
|
$this->bookmarkRepository->addBookmark( |
|
429
|
|
|
$updateDocument, |
|
430
|
|
|
$this->security->getUser()->getUid() |
|
431
|
|
|
) |
|
432
|
|
|
) { |
|
433
|
|
|
$this->addFlashMessage( |
|
434
|
|
|
LocalizationUtility::translate( |
|
435
|
|
|
"manager.workspace.bookmarkAdded", "dpf" |
|
436
|
|
|
), |
|
437
|
|
|
'', |
|
438
|
|
|
AbstractMessage::INFO |
|
439
|
|
|
); |
|
440
|
|
|
} |
|
441
|
|
|
} else { |
|
442
|
|
|
switch ($document->getState()) { |
|
443
|
|
|
case DocumentWorkflow::STATE_POSTPONED_NONE: |
|
444
|
|
|
case DocumentWorkflow::STATE_DISCARDED_NONE: |
|
445
|
|
|
case DocumentWorkflow::STATE_NONE_INACTIVE: |
|
446
|
|
|
case DocumentWorkflow::STATE_NONE_ACTIVE: |
|
447
|
|
|
case DocumentWorkflow::STATE_NONE_DELETED: |
|
448
|
|
|
|
|
449
|
|
|
if ( |
|
450
|
|
|
$this->bookmarkRepository->removeBookmark( |
|
451
|
|
|
$updateDocument, |
|
452
|
|
|
$this->security->getUser()->getUid() |
|
453
|
|
|
) |
|
454
|
|
|
) { |
|
455
|
|
|
$this->addFlashMessage( |
|
456
|
|
|
LocalizationUtility::translate( |
|
457
|
|
|
"manager.workspace.bookmarkRemoved.singular", "dpf" |
|
458
|
|
|
), |
|
459
|
|
|
'', |
|
460
|
|
|
AbstractMessage::INFO |
|
461
|
|
|
); |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
|
|
$this->redirectToDocumentList(); |
|
465
|
|
|
|
|
466
|
|
|
break; |
|
467
|
|
|
} |
|
468
|
|
|
} |
|
469
|
|
|
} |
|
470
|
|
|
|
|
471
|
|
|
} else { |
|
472
|
|
|
$message = LocalizationUtility::translate( |
|
473
|
|
|
'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.failure', |
|
474
|
|
|
'dpf', |
|
475
|
|
|
array($updateDocument->getTitle()) |
|
476
|
|
|
); |
|
477
|
|
|
$this->addFlashMessage($message, '', AbstractMessage::ERROR); |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
if ($workflowTransition && $workflowTransition === DocumentWorkflow::TRANSITION_REMOTE_UPDATE) { |
|
481
|
|
|
$this->redirectToDocumentList(); |
|
482
|
|
|
} else { |
|
483
|
|
|
$this->redirect('cancelEdit', |
|
484
|
|
|
null, |
|
485
|
|
|
null, |
|
486
|
|
|
['documentUid' => $updateDocument->getUid(), 'backToList' => $backToList] |
|
487
|
|
|
); |
|
488
|
|
|
// $this->redirect('showDetails', 'Document', null, ['document' => $updateDocument]); |
|
489
|
|
|
} |
|
490
|
|
|
} catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $e) { |
|
491
|
|
|
// A redirect always throws this exception, but in this case, however, |
|
492
|
|
|
// redirection is desired and should not lead to an exception handling |
|
493
|
|
|
} catch (\Exception $exception) { |
|
494
|
|
|
$severity = AbstractMessage::ERROR; |
|
495
|
|
|
|
|
496
|
|
|
if ($exception instanceof DPFExceptionInterface) { |
|
497
|
|
|
$key = $exception->messageLanguageKey(); |
|
498
|
|
|
} else { |
|
499
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:error.unexpected'; |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
$exceptionMsg[] = LocalizationUtility::translate( |
|
|
|
|
|
|
503
|
|
|
'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.failure', |
|
504
|
|
|
'dpf', |
|
505
|
|
|
array($updateDocument->getTitle()) |
|
506
|
|
|
); |
|
507
|
|
|
|
|
508
|
|
|
$exceptionMsg[] = LocalizationUtility::translate($key, 'dpf'); |
|
509
|
|
|
|
|
510
|
|
|
$this->addFlashMessage(implode(" ", $exceptionMsg), '', $severity, true); |
|
511
|
|
|
$this->redirect('cancelEdit', |
|
512
|
|
|
null, |
|
513
|
|
|
null, |
|
514
|
|
|
['documentUid' => $updateDocument->getUid(), 'backToList' => $backToList] |
|
515
|
|
|
); |
|
516
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $updateDocument]); |
|
517
|
|
|
} |
|
518
|
|
|
} |
|
519
|
|
|
|
|
520
|
|
|
public function createAction(\EWW\Dpf\Domain\Model\DocumentForm $newDocumentForm) |
|
521
|
|
|
{ |
|
522
|
|
|
/** @var \EWW\Dpf\Helper\DocumentMapper $documentMapper */ |
|
523
|
|
|
$documentMapper = $this->objectManager->get(DocumentMapper::class); |
|
524
|
|
|
|
|
525
|
|
|
/** @var \EWW\Dpf\Domain\Model\Document $document */ |
|
526
|
|
|
$document = $documentMapper->getDocument($newDocumentForm); |
|
527
|
|
|
|
|
528
|
|
|
if (!$this->authorizationChecker->isGranted(DocumentVoter::CREATE, $document)) { |
|
529
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:documentForm.create.accessDenied'; |
|
530
|
|
|
$args[] = $document->getTitle(); |
|
|
|
|
|
|
531
|
|
|
$message = LocalizationUtility::translate($key, 'dpf', $args); |
|
532
|
|
|
$this->addFlashMessage($message, '', AbstractMessage::ERROR); |
|
533
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
534
|
|
|
return FALSE; |
|
535
|
|
|
} |
|
536
|
|
|
|
|
537
|
|
|
try { |
|
538
|
|
|
parent::createAction($newDocumentForm); |
|
539
|
|
|
|
|
540
|
|
|
$severity = AbstractMessage::OK; |
|
541
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:documentForm.create.ok'; |
|
542
|
|
|
$message = LocalizationUtility::translate($key, 'dpf'); |
|
543
|
|
|
$this->addFlashMessage( |
|
544
|
|
|
$message, |
|
545
|
|
|
'', |
|
546
|
|
|
$severity, |
|
547
|
|
|
true |
|
548
|
|
|
); |
|
549
|
|
|
|
|
550
|
|
|
} catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $e) { |
|
551
|
|
|
// A redirect always throws this exception, but in this case, however, |
|
552
|
|
|
// redirection is desired and should not lead to an exception handling |
|
553
|
|
|
} catch (\Exception $exception) { |
|
554
|
|
|
|
|
555
|
|
|
$severity = AbstractMessage::ERROR; |
|
556
|
|
|
|
|
557
|
|
|
if ($exception instanceof DPFExceptionInterface) { |
|
558
|
|
|
$key = $exception->messageLanguageKey(); |
|
559
|
|
|
} else { |
|
560
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:error.unexpected'; |
|
561
|
|
|
} |
|
562
|
|
|
|
|
563
|
|
|
$message[] = LocalizationUtility::translate($key, 'dpf'); |
|
564
|
|
|
|
|
565
|
|
|
$this->addFlashMessage( |
|
566
|
|
|
implode(" ", $message), |
|
567
|
|
|
'', |
|
568
|
|
|
$severity, |
|
569
|
|
|
true |
|
570
|
|
|
); |
|
571
|
|
|
} |
|
572
|
|
|
|
|
573
|
|
|
$this->redirect('listWorkspace', 'Workspace'); |
|
574
|
|
|
} |
|
575
|
|
|
|
|
576
|
|
|
|
|
577
|
|
|
/** |
|
578
|
|
|
* action cancel edit |
|
579
|
|
|
* |
|
580
|
|
|
* @param integer $documentUid |
|
581
|
|
|
* @param bool $backToList |
|
582
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
|
583
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
|
584
|
|
|
* |
|
585
|
|
|
* @return void |
|
586
|
|
|
*/ |
|
587
|
|
|
public function cancelEditAction($documentUid = 0, $backToList = false) |
|
588
|
|
|
{ |
|
589
|
|
|
if (empty($documentUid) || $backToList) { |
|
590
|
|
|
$this->redirectToDocumentList(); |
|
591
|
|
|
} |
|
592
|
|
|
|
|
593
|
|
|
/** @var $document \EWW\Dpf\Domain\Model\Document */ |
|
594
|
|
|
$document = $this->documentRepository->findByUid($documentUid); |
|
595
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
596
|
|
|
} |
|
597
|
|
|
|
|
598
|
|
|
/** |
|
599
|
|
|
* action cancel new |
|
600
|
|
|
* |
|
601
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
|
602
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
|
603
|
|
|
* |
|
604
|
|
|
* @return void |
|
605
|
|
|
*/ |
|
606
|
|
|
public function cancelNewAction() |
|
607
|
|
|
{ |
|
608
|
|
|
$this->redirect('list'); |
|
609
|
|
|
} |
|
610
|
|
|
|
|
611
|
|
|
|
|
612
|
|
|
public function initializeAction() |
|
613
|
|
|
{ |
|
614
|
|
|
$this->authorizationChecker->denyAccessUnlessLoggedIn(); |
|
615
|
|
|
|
|
616
|
|
|
parent::initializeAction(); |
|
617
|
|
|
|
|
618
|
|
|
} |
|
619
|
|
|
|
|
620
|
|
|
/** |
|
621
|
|
|
* Redirect to the current document list. |
|
622
|
|
|
* |
|
623
|
|
|
* @param null $message |
|
|
|
|
|
|
624
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
|
625
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
|
626
|
|
|
*/ |
|
627
|
|
|
protected function redirectToDocumentList($message = null) |
|
628
|
|
|
{ |
|
629
|
|
|
list($action, $controller, $redirectUri) = $this->session->getStoredAction(); |
|
630
|
|
|
|
|
631
|
|
|
if ($redirectUri) { |
|
632
|
|
|
$this->redirectToUri($redirectUri); |
|
633
|
|
|
} else { |
|
634
|
|
|
$this->redirect($action, $controller, null, array('message' => $message)); |
|
635
|
|
|
} |
|
636
|
|
|
} |
|
637
|
|
|
} |
|
638
|
|
|
|
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