|
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\Domain\Model\DocumentType; |
|
19
|
|
|
use EWW\Dpf\Helper\InternalFormat; |
|
20
|
|
|
use EWW\Dpf\Security\DocumentVoter; |
|
21
|
|
|
use EWW\Dpf\Security\Security; |
|
22
|
|
|
use EWW\Dpf\Services\Transfer\DocumentTransferManager; |
|
23
|
|
|
use EWW\Dpf\Services\Transfer\FedoraRepository; |
|
24
|
|
|
use EWW\Dpf\Services\ProcessNumber\ProcessNumberGenerator; |
|
25
|
|
|
use EWW\Dpf\Services\Email\Notifier; |
|
26
|
|
|
use EWW\Dpf\Exceptions\DPFExceptionInterface; |
|
27
|
|
|
use EWW\Dpf\Domain\Workflow\DocumentWorkflow; |
|
28
|
|
|
use TYPO3\CMS\Core\Messaging\AbstractMessage; |
|
29
|
|
|
use EWW\Dpf\Helper\DocumentMapper; |
|
30
|
|
|
use EWW\Dpf\Domain\Model\File; |
|
31
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
32
|
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; |
|
33
|
|
|
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* DocumentController |
|
38
|
|
|
*/ |
|
39
|
|
|
class DocumentController extends AbstractController |
|
40
|
|
|
{ |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* documentRepository |
|
44
|
|
|
* |
|
45
|
|
|
* @var \EWW\Dpf\Domain\Repository\DocumentRepository |
|
46
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $documentRepository = null; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* documentTypeRepository |
|
52
|
|
|
* |
|
53
|
|
|
* @var \EWW\Dpf\Domain\Repository\DocumentTypeRepository |
|
54
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $documentTypeRepository = null; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* inputOptionListRepository |
|
60
|
|
|
* |
|
61
|
|
|
* @var \EWW\Dpf\Domain\Repository\InputOptionListRepository |
|
62
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
63
|
|
|
*/ |
|
64
|
|
|
protected $inputOptionListRepository = null; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* persistence manager |
|
68
|
|
|
* |
|
69
|
|
|
* @var \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface |
|
70
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
71
|
|
|
*/ |
|
72
|
|
|
protected $persistenceManager; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* editingLockService |
|
76
|
|
|
* |
|
77
|
|
|
* @var \EWW\Dpf\Services\Document\EditingLockService |
|
78
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
79
|
|
|
*/ |
|
80
|
|
|
protected $editingLockService = null; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* documentValidator |
|
84
|
|
|
* |
|
85
|
|
|
* @var \EWW\Dpf\Helper\DocumentValidator |
|
86
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
87
|
|
|
*/ |
|
88
|
|
|
protected $documentValidator; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* depositLicenseLogRepository |
|
92
|
|
|
* |
|
93
|
|
|
* @var \EWW\Dpf\Domain\Repository\DepositLicenseLogRepository |
|
94
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
95
|
|
|
*/ |
|
96
|
|
|
protected $depositLicenseLogRepository = null; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* workflow |
|
100
|
|
|
* |
|
101
|
|
|
* @var \EWW\Dpf\Domain\Workflow\DocumentWorkflow |
|
102
|
|
|
*/ |
|
103
|
|
|
protected $workflow; |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* documentTransferManager |
|
107
|
|
|
* |
|
108
|
|
|
* @var \EWW\Dpf\Services\Transfer\DocumentTransferManager $documentTransferManager |
|
109
|
|
|
*/ |
|
110
|
|
|
protected $documentTransferManager; |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* fedoraRepository |
|
114
|
|
|
* |
|
115
|
|
|
* @var \EWW\Dpf\Services\Transfer\FedoraRepository $fedoraRepository |
|
116
|
|
|
*/ |
|
117
|
|
|
protected $fedoraRepository; |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* fileRepository |
|
121
|
|
|
* |
|
122
|
|
|
* @var \EWW\Dpf\Domain\Repository\FileRepository |
|
123
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
124
|
|
|
*/ |
|
125
|
|
|
protected $fileRepository = null; |
|
126
|
|
|
|
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* frontendUserRepository |
|
130
|
|
|
* |
|
131
|
|
|
* @var \EWW\Dpf\Domain\Repository\FrontendUserRepository |
|
132
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
133
|
|
|
*/ |
|
134
|
|
|
protected $frontendUserRepository = null; |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* documentManager |
|
138
|
|
|
* |
|
139
|
|
|
* @var \EWW\Dpf\Services\Document\DocumentManager |
|
140
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
141
|
|
|
*/ |
|
142
|
|
|
protected $documentManager = null; |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* bookmarkRepository |
|
146
|
|
|
* |
|
147
|
|
|
* @var \EWW\Dpf\Domain\Repository\BookmarkRepository |
|
148
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
149
|
|
|
*/ |
|
150
|
|
|
protected $bookmarkRepository = null; |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* DocumentController constructor. |
|
154
|
|
|
*/ |
|
155
|
|
|
public function __construct() |
|
156
|
|
|
{ |
|
157
|
|
|
parent::__construct(); |
|
158
|
|
|
|
|
159
|
|
|
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
|
160
|
|
|
$this->documentTransferManager = $objectManager->get(DocumentTransferManager::class); |
|
161
|
|
|
$this->fedoraRepository = $objectManager->get(FedoraRepository::class); |
|
162
|
|
|
$this->documentTransferManager->setRemoteRepository($this->fedoraRepository); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* action logout of the backoffice |
|
167
|
|
|
* |
|
168
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
|
169
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
|
170
|
|
|
*/ |
|
171
|
|
|
public function logoutAction() |
|
172
|
|
|
{ |
|
173
|
|
|
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class); |
|
174
|
|
|
$uri = $cObj->typolink_URL([ |
|
175
|
|
|
'parameter' => $this->settings['loginPage'], |
|
176
|
|
|
//'linkAccessRestrictedPages' => 1, |
|
177
|
|
|
'forceAbsoluteUrl' => 1, |
|
178
|
|
|
'additionalParams' => GeneralUtility::implodeArrayForUrl(NULL, ['logintype'=>'logout']) |
|
179
|
|
|
]); |
|
180
|
|
|
|
|
181
|
|
|
$this->redirectToUri($uri); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
public function listSuggestionsAction() { |
|
185
|
|
|
$this->session->setStoredAction($this->getCurrentAction(), $this->getCurrentController()); |
|
186
|
|
|
|
|
187
|
|
|
$documents = NULL; |
|
188
|
|
|
$isWorkspace = $this->security->getUserRole() === Security::ROLE_LIBRARIAN; |
|
189
|
|
|
|
|
190
|
|
|
if ( |
|
191
|
|
|
$this->security->getUserRole() == Security::ROLE_LIBRARIAN |
|
192
|
|
|
) { |
|
193
|
|
|
$documents = $this->documentRepository->findAllDocumentSuggestions( |
|
194
|
|
|
$this->security->getUserRole(), |
|
195
|
|
|
$this->security->getUser()->getUid() |
|
196
|
|
|
); |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
if ($this->request->hasArgument('message')) { |
|
200
|
|
|
$this->view->assign('message', $this->request->getArgument('message')); |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
if ($this->request->hasArgument('errorFiles')) { |
|
204
|
|
|
$this->view->assign('errorFiles', $this->request->getArgument('errorFiles')); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
$this->view->assign('currentUser', $this->security->getUser()); |
|
208
|
|
|
$this->view->assign('isWorkspace', $isWorkspace); |
|
209
|
|
|
$this->view->assign('documents', $documents); |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @param Document $document |
|
214
|
|
|
* @param bool $acceptAll |
|
215
|
|
|
*/ |
|
216
|
|
|
public function acceptSuggestionAction(\EWW\Dpf\Domain\Model\Document $document, bool $acceptAll = true) { |
|
217
|
|
|
|
|
218
|
|
|
/** @var DocumentMapper $documentMapper */ |
|
219
|
|
|
$documentMapper = $this->objectManager->get(DocumentMapper::class); |
|
220
|
|
|
|
|
221
|
|
|
// Existing working copy? |
|
222
|
|
|
/** @var \EWW\Dpf\Domain\Model\Document $originDocument */ |
|
223
|
|
|
$linkedUid = $document->getLinkedUid(); |
|
224
|
|
|
$originDocument = $this->documentRepository->findWorkingCopy($linkedUid); |
|
225
|
|
|
|
|
226
|
|
|
if ($originDocument) { |
|
|
|
|
|
|
227
|
|
|
$linkedDocumentForm = $documentMapper->getDocumentForm($originDocument); |
|
|
|
|
|
|
228
|
|
|
} else { |
|
229
|
|
|
// get remote document |
|
230
|
|
|
$originDocument = $this->documentTransferManager->retrieve($document->getLinkedUid(), $this->security->getUser()->getUid()); |
|
231
|
|
|
$linkedDocumentForm = $documentMapper->getDocumentForm($originDocument); |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
if ($acceptAll) { |
|
235
|
|
|
// all changes are confirmed |
|
236
|
|
|
// copy suggest to origin document |
|
237
|
|
|
$originDocument->copy($document, true); |
|
|
|
|
|
|
238
|
|
|
|
|
239
|
|
|
if ($document->getRemoteState() != DocumentWorkflow::REMOTE_STATE_NONE) { |
|
240
|
|
|
if ($document->getLocalState() != DocumentWorkflow::LOCAL_STATE_IN_PROGRESS) { |
|
241
|
|
|
$originDocument->setState( |
|
242
|
|
|
DocumentWorkflow::constructState(DocumentWorkflow::LOCAL_STATE_IN_PROGRESS, |
|
243
|
|
|
$document->getRemoteState()) |
|
244
|
|
|
); |
|
245
|
|
|
$this->addFlashMessage( |
|
246
|
|
|
LocalizationUtility::translate("message.suggestion_accepted.new_workingcopy_info", "dpf"), |
|
247
|
|
|
'', |
|
248
|
|
|
AbstractMessage::INFO |
|
249
|
|
|
); |
|
250
|
|
|
} |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
if ($originDocument->getTransferStatus() == 'RESTORE') { |
|
254
|
|
|
if ($originDocument->getObjectIdentifier()) { |
|
255
|
|
|
$originDocument->setState(DocumentWorkflow::STATE_IN_PROGRESS_ACTIVE); |
|
256
|
|
|
} else { |
|
257
|
|
|
$originDocument->setState(DocumentWorkflow::STATE_IN_PROGRESS_NONE); |
|
258
|
|
|
} |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
// copy files from suggest document |
|
262
|
|
|
foreach ($document->getFile() as $key => $file) { |
|
263
|
|
|
$newFile = $this->objectManager->get(File::class); |
|
264
|
|
|
$newFile->copy($file); |
|
265
|
|
|
$newFile->setDocument($originDocument); |
|
266
|
|
|
$this->fileRepository->add($newFile); |
|
267
|
|
|
$originDocument->addFile($newFile); |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
$internalFormat = new InternalFormat($document->getXmlData()); |
|
271
|
|
|
$originDocument->setAuthors($internalFormat->getPersons()); |
|
272
|
|
|
$this->documentRepository->update($originDocument); |
|
273
|
|
|
$this->documentRepository->remove($document); |
|
274
|
|
|
|
|
275
|
|
|
// Notify assigned users |
|
276
|
|
|
/** @var Notifier $notifier */ |
|
277
|
|
|
$notifier = $this->objectManager->get(Notifier::class); |
|
278
|
|
|
|
|
279
|
|
|
$recipients = $this->documentManager->getUpdateNotificationRecipients($originDocument); |
|
280
|
|
|
$notifier->sendMyPublicationUpdateNotification($originDocument, $recipients); |
|
281
|
|
|
|
|
282
|
|
|
$recipients = $this->documentManager->getNewPublicationNotificationRecipients($originDocument); |
|
283
|
|
|
$notifier->sendMyPublicationNewNotification($originDocument, $recipients); |
|
284
|
|
|
|
|
285
|
|
|
$notifier->sendChangedDocumentNotification($originDocument); |
|
286
|
|
|
|
|
287
|
|
|
$notifier->sendSuggestionAcceptNotification($originDocument); |
|
288
|
|
|
|
|
289
|
|
|
// index the document |
|
290
|
|
|
$this->signalSlotDispatcher->dispatch( |
|
291
|
|
|
AbstractController::class, 'indexDocument', [$originDocument] |
|
292
|
|
|
); |
|
293
|
|
|
|
|
294
|
|
|
// redirect to document |
|
295
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $originDocument]); |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
$this->redirectToDocumentList(); |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
|
|
302
|
|
|
public function showSuggestionDetailsAction(\EWW\Dpf\Domain\Model\Document $document) { |
|
303
|
|
|
$this->authorizationChecker->denyAccessUnlessGranted(DocumentVoter::SHOW_DETAILS, $document); |
|
304
|
|
|
|
|
305
|
|
|
/** @var DocumentMapper $documentMapper */ |
|
306
|
|
|
$documentMapper = $this->objectManager->get(DocumentMapper::class); |
|
307
|
|
|
|
|
308
|
|
|
$linkedUid = $document->getLinkedUid(); |
|
309
|
|
|
$linkedDocument = $this->documentRepository->findWorkingCopy($linkedUid); |
|
310
|
|
|
|
|
311
|
|
|
if ($linkedDocument) { |
|
312
|
|
|
// Existing working copy |
|
313
|
|
|
$linkedDocumentForm = $documentMapper->getDocumentForm($linkedDocument); |
|
314
|
|
|
} else { |
|
315
|
|
|
// No existing working copy, get remote document from fedora |
|
316
|
|
|
$linkedDocument = $this->documentTransferManager->retrieve($document->getLinkedUid(), $this->security->getUser()->getUid()); |
|
317
|
|
|
$linkedDocumentForm = $documentMapper->getDocumentForm($linkedDocument); |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
$newDocumentForm = $documentMapper->getDocumentForm($document); |
|
321
|
|
|
$diff = $this->documentFormDiff($linkedDocumentForm, $newDocumentForm); |
|
322
|
|
|
|
|
323
|
|
|
//$usernameString = $this->security->getUsername(); |
|
324
|
|
|
$user = $this->frontendUserRepository->findOneByUid($document->getCreator()); |
|
325
|
|
|
|
|
326
|
|
|
if ($user) { |
|
327
|
|
|
$usernameString = $user->getUsername(); |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
$this->view->assign('documentCreator', $usernameString); |
|
|
|
|
|
|
331
|
|
|
$this->view->assign('diff', $diff); |
|
332
|
|
|
$this->view->assign('document', $document); |
|
333
|
|
|
|
|
334
|
|
|
} |
|
335
|
|
|
|
|
336
|
|
|
public function documentFormDiff($docForm1, $docForm2) { |
|
337
|
|
|
$returnArray = ['changed' => ['new' => [], 'old' => []], 'deleted' => [], 'added' => []]; |
|
338
|
|
|
|
|
339
|
|
|
// pages |
|
340
|
|
|
foreach ($docForm1->getItems() as $keyPage => $valuePage) { |
|
341
|
|
|
foreach ($valuePage as $keyRepeatPage => $valueRepeatPage) { |
|
342
|
|
|
|
|
343
|
|
|
// groups |
|
344
|
|
|
foreach ($valueRepeatPage->getItems() as $keyGroup => $valueGroup) { |
|
345
|
|
|
|
|
346
|
|
|
$checkFieldsForAdding = false; |
|
347
|
|
|
$valueGroupCounter = count($valueGroup); |
|
348
|
|
|
|
|
349
|
|
|
if ($valueGroupCounter < count($docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup])) { |
|
350
|
|
|
$checkFieldsForAdding = true; |
|
351
|
|
|
} |
|
352
|
|
|
|
|
353
|
|
|
foreach ($valueGroup as $keyRepeatGroup => $valueRepeatGroup) { |
|
354
|
|
|
|
|
355
|
|
|
// fields |
|
356
|
|
|
foreach ($valueRepeatGroup->getItems() as $keyField => $valueField) { |
|
357
|
|
|
foreach ($valueField as $keyRepeatField => $valueRepeatField) { |
|
358
|
|
|
|
|
359
|
|
|
$fieldCounter = count($docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup]); |
|
360
|
|
|
$valueFieldCounter = count($valueField); |
|
361
|
|
|
|
|
362
|
|
|
// check if group or field is not existing |
|
363
|
|
|
$notExisting = false; |
|
364
|
|
|
try { |
|
365
|
|
|
$flag = 'page'; |
|
366
|
|
|
$value2 = $docForm2->getItems()[$keyPage]; |
|
367
|
|
|
$flag = 'group'; |
|
368
|
|
|
$value2 = $value2[$keyRepeatPage]; |
|
369
|
|
|
$value2 = $value2->getItems()[$keyGroup]; |
|
370
|
|
|
$value2 = $value2[$keyRepeatGroup]->getItems()[$keyField]; |
|
371
|
|
|
$flag = 'field'; |
|
372
|
|
|
} catch (\Throwable $t) { |
|
373
|
|
|
$notExisting = true; |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
$item = NULL; |
|
|
|
|
|
|
377
|
|
|
if ($flag == 'group') { |
|
378
|
|
|
$itemExisting = $valueRepeatGroup; |
|
379
|
|
|
$itemNew = $docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup]; |
|
380
|
|
|
} else if ($flag == 'field') { |
|
381
|
|
|
$itemExisting = $valueRepeatField; |
|
382
|
|
|
$itemNew = $docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup][$keyRepeatGroup]->getItems()[$keyField][$keyRepeatField]; |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
if ($notExisting || ($valueRepeatField->getValue() != $value2[$keyRepeatField]->getValue() && empty($value2[$keyRepeatField]->getValue()))) { |
|
386
|
|
|
// deleted |
|
387
|
|
|
$returnArray['deleted'][] = $itemExisting; |
|
|
|
|
|
|
388
|
|
|
|
|
389
|
|
|
} else if ($this->removeControlCharacterFromString($valueRepeatField->getValue()) != $this->removeControlCharacterFromString($value2[$keyRepeatField]->getValue()) |
|
390
|
|
|
&& !empty($value2[$keyRepeatField]->getValue())) { |
|
391
|
|
|
|
|
392
|
|
|
// changed |
|
393
|
|
|
$returnArray['changed']['old'][] = $itemExisting; |
|
394
|
|
|
$returnArray['changed']['new'][] = $itemNew; |
|
|
|
|
|
|
395
|
|
|
$returnArray['changed']['groupDisplayName'] = $valueRepeatGroup->getDisplayName(); |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
if ($flag == 'group') { |
|
399
|
|
|
break 2; |
|
400
|
|
|
} |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
// check if new document form has more field items as the existing form |
|
404
|
|
|
if ($valueFieldCounter < $fieldCounter && !$checkFieldsForAdding) { |
|
|
|
|
|
|
405
|
|
|
// field added |
|
406
|
|
|
for ($i = count($valueField); $i < $fieldCounter;$i++) { |
|
407
|
|
|
$returnArray['added'][] = $docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup][$keyRepeatGroup]->getItems()[$keyField][$i]; |
|
408
|
|
|
|
|
409
|
|
|
} |
|
410
|
|
|
} |
|
411
|
|
|
} |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
|
|
// check if new document form has more group items as the existing form |
|
415
|
|
|
if ($valueGroupCounter < count($docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup])) { |
|
416
|
|
|
// group added |
|
417
|
|
|
$counter = count($docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup]); |
|
418
|
|
|
for ($i = $valueGroupCounter; $i < $counter;$i++) { |
|
419
|
|
|
$returnArray['added'][] = $docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup][$i]; |
|
420
|
|
|
} |
|
421
|
|
|
} |
|
422
|
|
|
} |
|
423
|
|
|
} |
|
424
|
|
|
|
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
return $returnArray; |
|
428
|
|
|
|
|
429
|
|
|
} |
|
430
|
|
|
|
|
431
|
|
|
public function removeControlCharacterFromString($string) { |
|
432
|
|
|
return preg_replace('/\p{C}+/u', "", $string); |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
/** |
|
436
|
|
|
* action discard |
|
437
|
|
|
* |
|
438
|
|
|
* @param \EWW\Dpf\Domain\Model\Document $document |
|
439
|
|
|
* @param integer $tstamp |
|
440
|
|
|
* @param string $reason |
|
441
|
|
|
* @return void |
|
442
|
|
|
*/ |
|
443
|
|
|
public function discardAction(Document $document, $tstamp, $reason = NULL) |
|
|
|
|
|
|
444
|
|
|
{ |
|
445
|
|
|
if (!$this->authorizationChecker->isGranted(DocumentVoter::DISCARD, $document)) { |
|
446
|
|
|
if ( |
|
447
|
|
|
$this->editingLockService->isLocked( |
|
448
|
|
|
$document->getDocumentIdentifier(), |
|
449
|
|
|
$this->security->getUser()->getUid() |
|
450
|
|
|
) |
|
451
|
|
|
) { |
|
452
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_discard.failureBlocked'; |
|
453
|
|
|
} else { |
|
454
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_discard.accessDenied'; |
|
455
|
|
|
} |
|
456
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
457
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
458
|
|
|
return FALSE; |
|
|
|
|
|
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
$this->updateDocument($document, DocumentWorkflow::TRANSITION_DISCARD, $reason); |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
|
|
/** |
|
465
|
|
|
* action postpone |
|
466
|
|
|
* |
|
467
|
|
|
* @param \EWW\Dpf\Domain\Model\Document $document |
|
468
|
|
|
* @param integer $tstamp |
|
469
|
|
|
* @param string $reason |
|
470
|
|
|
* @return void |
|
471
|
|
|
*/ |
|
472
|
|
|
public function postponeAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp, $reason = NULL) |
|
|
|
|
|
|
473
|
|
|
{ |
|
474
|
|
|
if (!$this->authorizationChecker->isGranted(DocumentVoter::POSTPONE, $document)) { |
|
475
|
|
|
if ( |
|
476
|
|
|
$this->editingLockService->isLocked( |
|
477
|
|
|
$document->getDocumentIdentifier(), |
|
478
|
|
|
$this->security->getUser()->getUid() |
|
479
|
|
|
) |
|
480
|
|
|
) { |
|
481
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_postpone.failureBlocked'; |
|
482
|
|
|
} else { |
|
483
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_postpone.accessDenied'; |
|
484
|
|
|
} |
|
485
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
486
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
487
|
|
|
return FALSE; |
|
|
|
|
|
|
488
|
|
|
} |
|
489
|
|
|
|
|
490
|
|
|
$this->updateDocument($document, DocumentWorkflow::TRANSITION_POSTPONE, $reason); |
|
491
|
|
|
|
|
492
|
|
|
} |
|
493
|
|
|
|
|
494
|
|
|
|
|
495
|
|
|
/** |
|
496
|
|
|
* action change document type |
|
497
|
|
|
* |
|
498
|
|
|
* @param \EWW\Dpf\Domain\Model\Document $document |
|
499
|
|
|
* @param int $documentTypeUid |
|
500
|
|
|
* @return void |
|
501
|
|
|
*/ |
|
502
|
|
|
public function changeDocumentTypeAction(\EWW\Dpf\Domain\Model\Document $document, $documentTypeUid = 0) |
|
503
|
|
|
{ |
|
504
|
|
|
if (!$this->authorizationChecker->isGranted(DocumentVoter::UPDATE, $document)) { |
|
505
|
|
|
if ( |
|
506
|
|
|
$this->editingLockService->isLocked( |
|
507
|
|
|
$document->getDocumentIdentifier(), |
|
508
|
|
|
$this->security->getUser()->getUid() |
|
509
|
|
|
) |
|
510
|
|
|
) { |
|
511
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.failureBlocked'; |
|
512
|
|
|
} else { |
|
513
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.accessDenied'; |
|
514
|
|
|
} |
|
515
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
516
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
517
|
|
|
return FALSE; |
|
|
|
|
|
|
518
|
|
|
} |
|
519
|
|
|
|
|
520
|
|
|
|
|
521
|
|
|
$documentType = $this->documentTypeRepository->findByUid($documentTypeUid); |
|
522
|
|
|
|
|
523
|
|
|
if ($documentType instanceof DocumentType) { |
|
524
|
|
|
$document->setDocumentType($documentType); |
|
525
|
|
|
|
|
526
|
|
|
$internalFormat = new \EWW\Dpf\Helper\InternalFormat($document->getXmlData()); |
|
527
|
|
|
$internalFormat->setDocumentType($documentType->getName()); |
|
528
|
|
|
$document->setXmlData($internalFormat->getXml()); |
|
529
|
|
|
|
|
530
|
|
|
/** @var DocumentMapper $documentMapper */ |
|
531
|
|
|
$documentMapper = $this->objectManager->get(DocumentMapper::class); |
|
532
|
|
|
// Adjusting the document data according to the new document type |
|
533
|
|
|
$documentForm = $documentMapper->getDocumentForm($document); |
|
534
|
|
|
$document = $documentMapper->getDocument($documentForm); |
|
535
|
|
|
|
|
536
|
|
|
$this->updateDocument($document, '', null); |
|
537
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
538
|
|
|
} else { |
|
539
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.failure'; |
|
540
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
541
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
542
|
|
|
return FALSE; |
|
|
|
|
|
|
543
|
|
|
} |
|
544
|
|
|
} |
|
545
|
|
|
|
|
546
|
|
|
/** |
|
547
|
|
|
* action deleteLocallySuggestionAction |
|
548
|
|
|
* |
|
549
|
|
|
* @param Document $document |
|
550
|
|
|
* @param integer $tstamp |
|
551
|
|
|
* @param string $reason |
|
552
|
|
|
* @return void |
|
553
|
|
|
*/ |
|
554
|
|
|
public function deleteLocallySuggestionAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp, $reason = "") |
|
555
|
|
|
{ |
|
556
|
|
|
$this->redirect( |
|
557
|
|
|
'deleteLocally', |
|
558
|
|
|
'Document', |
|
559
|
|
|
null, |
|
560
|
|
|
[ |
|
561
|
|
|
'document' => $document, |
|
562
|
|
|
'tstamp' => $tstamp, |
|
563
|
|
|
'reason' => $reason |
|
564
|
|
|
] |
|
565
|
|
|
); |
|
566
|
|
|
} |
|
567
|
|
|
|
|
568
|
|
|
|
|
569
|
|
|
/** |
|
570
|
|
|
* action deleteLocallyAction |
|
571
|
|
|
* |
|
572
|
|
|
* @param Document $document |
|
573
|
|
|
* @param integer $tstamp |
|
574
|
|
|
* @param string $reason |
|
575
|
|
|
* @return void |
|
576
|
|
|
*/ |
|
577
|
|
|
public function deleteLocallyAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp, $reason = "") |
|
578
|
|
|
{ |
|
579
|
|
|
if (empty($document->getObjectIdentifier()) || $document->isSuggestion()) { |
|
580
|
|
|
$voterAttribute = DocumentVoter::DELETE_LOCALLY; |
|
581
|
|
|
} else { |
|
582
|
|
|
$voterAttribute = DocumentVoter::DELETE_WORKING_COPY; |
|
583
|
|
|
} |
|
584
|
|
|
|
|
585
|
|
|
if (!$this->authorizationChecker->isGranted($voterAttribute, $document)) { |
|
586
|
|
|
if ( |
|
587
|
|
|
$this->editingLockService->isLocked( |
|
588
|
|
|
$document->getDocumentIdentifier(), |
|
589
|
|
|
$this->security->getUser()->getUid() |
|
590
|
|
|
) |
|
591
|
|
|
) { |
|
592
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_deleteLocally.failureBlocked'; |
|
593
|
|
|
} else { |
|
594
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_deleteLocally.accessDenied'; |
|
595
|
|
|
} |
|
596
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
597
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
598
|
|
|
return FALSE; |
|
|
|
|
|
|
599
|
|
|
} |
|
600
|
|
|
|
|
601
|
|
|
if ($tstamp === $document->getTstamp()) { |
|
602
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_deleteLocally.success'; |
|
603
|
|
|
$this->flashMessage($document, $key, AbstractMessage::OK); |
|
604
|
|
|
$this->documentRepository->remove($document); |
|
605
|
|
|
|
|
606
|
|
|
if ($document->isWorkingCopy() || $document->isTemporaryCopy()) { |
|
607
|
|
|
|
|
608
|
|
|
if ($document->isWorkingCopy()) { |
|
609
|
|
|
if ($this->bookmarkRepository->removeBookmark($document, $this->security->getUser()->getUid())) { |
|
610
|
|
|
$this->addFlashMessage( |
|
611
|
|
|
LocalizationUtility::translate("manager.workspace.bookmarkRemoved.singular", "dpf"), '', |
|
612
|
|
|
AbstractMessage::INFO |
|
613
|
|
|
); |
|
614
|
|
|
} |
|
615
|
|
|
} |
|
616
|
|
|
|
|
617
|
|
|
$this->persistenceManager->persistAll(); |
|
618
|
|
|
$document = $this->documentManager->read($document->getDocumentIdentifier()); |
|
619
|
|
|
|
|
620
|
|
|
// index the document |
|
621
|
|
|
$this->signalSlotDispatcher->dispatch( |
|
622
|
|
|
\EWW\Dpf\Controller\AbstractController::class, |
|
623
|
|
|
'indexDocument', [$document] |
|
624
|
|
|
); |
|
625
|
|
|
|
|
626
|
|
|
$this->documentRepository->remove($document); |
|
627
|
|
|
|
|
628
|
|
|
} elseif (!$document->isSuggestion()) { |
|
629
|
|
|
$this->bookmarkRepository->removeBookmark($document, $this->security->getUser()->getUid()); |
|
630
|
|
|
// delete document from index |
|
631
|
|
|
$this->signalSlotDispatcher->dispatch( |
|
632
|
|
|
\EWW\Dpf\Controller\AbstractController::class, |
|
633
|
|
|
'deleteDocumentFromIndex', [$document->getDocumentIdentifier()] |
|
634
|
|
|
); |
|
635
|
|
|
} |
|
636
|
|
|
|
|
637
|
|
|
$suggestions = $this->documentRepository->findByLinkedUid($document->getDocumentIdentifier()); |
|
|
|
|
|
|
638
|
|
|
foreach ($suggestions as $suggestion) { |
|
639
|
|
|
$this->documentRepository->remove($suggestion); |
|
640
|
|
|
} |
|
641
|
|
|
|
|
642
|
|
|
/** @var Notifier $notifier */ |
|
643
|
|
|
$notifier = $this->objectManager->get(Notifier::class); |
|
644
|
|
|
$notifier->sendSuggestionDeclineNotification($document, $reason); |
|
645
|
|
|
|
|
646
|
|
|
$this->redirectToDocumentList(); |
|
647
|
|
|
} else { |
|
648
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_deleteLocally.failureNewVersion'; |
|
649
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
650
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
651
|
|
|
} |
|
652
|
|
|
} |
|
653
|
|
|
|
|
654
|
|
|
|
|
655
|
|
|
/** |
|
656
|
|
|
* @param Document $document |
|
657
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
|
658
|
|
|
*/ |
|
659
|
|
|
public function duplicateAction(\EWW\Dpf\Domain\Model\Document $document) |
|
660
|
|
|
{ |
|
661
|
|
|
if (!$this->authorizationChecker->isGranted(DocumentVoter::DUPLICATE, $document)) { |
|
662
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_duplicate.accessDenied'; |
|
663
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
664
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
665
|
|
|
return FALSE; |
|
666
|
|
|
} |
|
667
|
|
|
|
|
668
|
|
|
/* @var $newDocument \EWW\Dpf\Domain\Model\Document */ |
|
669
|
|
|
$newDocument = $this->objectManager->get(Document::class); |
|
670
|
|
|
|
|
671
|
|
|
$newDocument->setState(DocumentWorkflow::STATE_NEW_NONE); |
|
672
|
|
|
|
|
673
|
|
|
$copyTitle = LocalizationUtility::translate("manager.workspace.title.copy", "dpf").$document->getTitle(); |
|
674
|
|
|
|
|
675
|
|
|
$newDocument->setTitle($copyTitle); |
|
676
|
|
|
|
|
677
|
|
|
$newDocument->setAuthors($document->getAuthors()); |
|
678
|
|
|
|
|
679
|
|
|
$newDocument->setCreator($this->security->getUser()->getUid()); |
|
680
|
|
|
|
|
681
|
|
|
$newDocument->setDocumentType($document->getDocumentType()); |
|
682
|
|
|
|
|
683
|
|
|
$processNumberGenerator = $this->objectManager->get(ProcessNumberGenerator::class); |
|
684
|
|
|
$processNumber = $processNumberGenerator->getProcessNumber(); |
|
685
|
|
|
$newDocument->setProcessNumber($processNumber); |
|
686
|
|
|
|
|
687
|
|
|
$internalFormat = new \EWW\Dpf\Helper\InternalFormat($document->getXmlData()); |
|
688
|
|
|
$internalFormat->clearAllUrn(); |
|
689
|
|
|
$internalFormat->setDateIssued(''); |
|
690
|
|
|
$internalFormat->setTitle($copyTitle); |
|
691
|
|
|
$internalFormat->setProcessNumber($processNumber); |
|
692
|
|
|
|
|
693
|
|
|
$newDocument->setXmlData($internalFormat->getXml()); |
|
694
|
|
|
|
|
695
|
|
|
$documentMapper = $this->objectManager->get(DocumentMapper::class); |
|
696
|
|
|
|
|
697
|
|
|
/** @var $documentForm \EWW\Dpf\Domain\Model\DocumentForm */ |
|
698
|
|
|
$newDocumentForm = $documentMapper->getDocumentForm($newDocument); |
|
699
|
|
|
|
|
700
|
|
|
$this->forward( |
|
701
|
|
|
'new', |
|
702
|
|
|
'DocumentFormBackoffice', |
|
703
|
|
|
NULL, |
|
704
|
|
|
['newDocumentForm' => $newDocumentForm, 'returnDocumentId' => $document->getUid()] |
|
705
|
|
|
); |
|
706
|
|
|
|
|
707
|
|
|
} |
|
708
|
|
|
|
|
709
|
|
|
/** |
|
710
|
|
|
* releasePublishAction |
|
711
|
|
|
* |
|
712
|
|
|
* @param \EWW\Dpf\Domain\Model\Document $document |
|
713
|
|
|
* @param integer $tstamp |
|
714
|
|
|
* @return void |
|
715
|
|
|
*/ |
|
716
|
|
|
public function releasePublishAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp) |
|
|
|
|
|
|
717
|
|
|
{ |
|
718
|
|
|
if (!$this->authorizationChecker->isGranted(DocumentVoter::RELEASE_PUBLISH, $document)) { |
|
719
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_ingest.accessDenied'; |
|
720
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
721
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
722
|
|
|
return FALSE; |
|
|
|
|
|
|
723
|
|
|
} |
|
724
|
|
|
|
|
725
|
|
|
$this->updateDocument($document, DocumentWorkflow::TRANSITION_RELEASE_PUBLISH, null); |
|
726
|
|
|
|
|
727
|
|
|
/** @var Notifier $notifier */ |
|
728
|
|
|
$notifier = $this->objectManager->get(Notifier::class); |
|
729
|
|
|
$notifier->sendReleasePublishNotification($document); |
|
730
|
|
|
} |
|
731
|
|
|
|
|
732
|
|
|
/** |
|
733
|
|
|
* releaseActivateAction |
|
734
|
|
|
* |
|
735
|
|
|
* @param \EWW\Dpf\Domain\Model\Document $document |
|
736
|
|
|
* @param integer $tstamp |
|
737
|
|
|
* @return void |
|
738
|
|
|
*/ |
|
739
|
|
|
public function releaseActivateAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp) |
|
|
|
|
|
|
740
|
|
|
{ |
|
741
|
|
|
if (!$this->authorizationChecker->isGranted(DocumentVoter::RELEASE_ACTIVATE, $document)) { |
|
742
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_activate.accessDenied'; |
|
743
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
744
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
745
|
|
|
return FALSE; |
|
|
|
|
|
|
746
|
|
|
} |
|
747
|
|
|
|
|
748
|
|
|
$this->updateDocument($document, DocumentWorkflow::TRANSITION_RELEASE_ACTIVATE, null); |
|
749
|
|
|
|
|
750
|
|
|
} |
|
751
|
|
|
|
|
752
|
|
|
/** |
|
753
|
|
|
* action register |
|
754
|
|
|
* |
|
755
|
|
|
* @param \EWW\Dpf\Domain\Model\Document $document |
|
756
|
|
|
* @return void |
|
757
|
|
|
*/ |
|
758
|
|
|
public function registerAction(\EWW\Dpf\Domain\Model\Document $document) |
|
759
|
|
|
{ |
|
760
|
|
|
if (!$this->authorizationChecker->isGranted(DocumentVoter::REGISTER, $document)) { |
|
761
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_register.accessDenied'; |
|
762
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
763
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
764
|
|
|
} |
|
765
|
|
|
|
|
766
|
|
|
if (!$this->documentValidator->validate($document, false)) { |
|
767
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_register.missingValues'; |
|
768
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
769
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
770
|
|
|
} |
|
771
|
|
|
|
|
772
|
|
|
$this->workflow->apply($document, \EWW\Dpf\Domain\Workflow\DocumentWorkflow::TRANSITION_REGISTER); |
|
|
|
|
|
|
773
|
|
|
$this->documentRepository->update($document); |
|
774
|
|
|
|
|
775
|
|
|
|
|
776
|
|
|
if ($this->security->getUserRole() === Security::ROLE_LIBRARIAN) { |
|
777
|
|
|
$this->bookmarkRepository->addBookmark($document, $this->security->getUser()->getUid()); |
|
778
|
|
|
} |
|
779
|
|
|
|
|
780
|
|
|
// admin register notification |
|
781
|
|
|
$notifier = $this->objectManager->get(Notifier::class); |
|
782
|
|
|
$notifier->sendRegisterNotification($document); |
|
783
|
|
|
|
|
784
|
|
|
// index the document |
|
785
|
|
|
$this->signalSlotDispatcher->dispatch(\EWW\Dpf\Controller\AbstractController::class, 'indexDocument', [$document]); |
|
786
|
|
|
|
|
787
|
|
|
// document updated notification |
|
788
|
|
|
$recipients = $this->documentManager->getUpdateNotificationRecipients($document); |
|
789
|
|
|
$notifier->sendMyPublicationUpdateNotification($document, $recipients); |
|
790
|
|
|
|
|
791
|
|
|
$recipients = $this->documentManager->getNewPublicationNotificationRecipients($document); |
|
792
|
|
|
$notifier->sendMyPublicationNewNotification($document, $recipients); |
|
793
|
|
|
|
|
794
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_register.success'; |
|
795
|
|
|
$this->flashMessage($document, $key, AbstractMessage::OK); |
|
796
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
797
|
|
|
} |
|
798
|
|
|
|
|
799
|
|
|
/** |
|
800
|
|
|
* action showDetails |
|
801
|
|
|
* |
|
802
|
|
|
* @param \EWW\Dpf\Domain\Model\Document $document |
|
803
|
|
|
* @return void |
|
804
|
|
|
*/ |
|
805
|
|
|
public function showDetailsAction(Document $document) |
|
806
|
|
|
{ |
|
807
|
|
|
if (!$this->authorizationChecker->isGranted(DocumentVoter::SHOW_DETAILS, $document)) { |
|
808
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_showDetails.accessDenied'; |
|
809
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
810
|
|
|
$this->redirectToDocumentList(); |
|
811
|
|
|
} |
|
812
|
|
|
|
|
813
|
|
|
$this->editingLockService->lock( |
|
814
|
|
|
($document->getObjectIdentifier()? $document->getObjectIdentifier() : $document->getUid()), |
|
815
|
|
|
$this->security->getUser()->getUid() |
|
816
|
|
|
); |
|
817
|
|
|
|
|
818
|
|
|
$postponeOptions = $this->inputOptionListRepository->findOneByName($this->settings['postponeOptionListName']); |
|
|
|
|
|
|
819
|
|
|
if ($postponeOptions) { |
|
820
|
|
|
$this->view->assign('postponeOptions', $postponeOptions->getInputOptions()); |
|
|
|
|
|
|
821
|
|
|
} |
|
822
|
|
|
|
|
823
|
|
|
$discardOptions = $this->inputOptionListRepository->findOneByName($this->settings['discardOptionListName']); |
|
824
|
|
|
if ($discardOptions) { |
|
825
|
|
|
$this->view->assign('discardOptions', $discardOptions->getInputOptions()); |
|
826
|
|
|
} |
|
827
|
|
|
|
|
828
|
|
|
$mapper = $this->objectManager->get(DocumentMapper::class); |
|
829
|
|
|
$documentForm = $mapper->getDocumentForm($document, false); |
|
830
|
|
|
|
|
831
|
|
|
$documentTypes = [0 => '']; |
|
832
|
|
|
foreach ($this->documentTypeRepository->getDocumentTypesAlphabetically() as $documentType) { |
|
833
|
|
|
if (!$documentType->isHiddenInList()) { |
|
834
|
|
|
$documentTypes[$documentType->getUid()] = $documentType->getDisplayName(); |
|
835
|
|
|
} |
|
836
|
|
|
} |
|
837
|
|
|
|
|
838
|
|
|
$this->view->assign('documentTypes', $documentTypes); |
|
839
|
|
|
|
|
840
|
|
|
$this->view->assign('documentForm', $documentForm); |
|
841
|
|
|
|
|
842
|
|
|
$this->view->assign('document', $document); |
|
843
|
|
|
} |
|
844
|
|
|
|
|
845
|
|
|
|
|
846
|
|
|
public function cancelListTaskAction() |
|
847
|
|
|
{ |
|
848
|
|
|
$this->redirectToDocumentList(); |
|
849
|
|
|
} |
|
850
|
|
|
|
|
851
|
|
|
/** |
|
852
|
|
|
* action suggest restore |
|
853
|
|
|
* |
|
854
|
|
|
* @param Document $document |
|
855
|
|
|
* @return void |
|
856
|
|
|
*/ |
|
857
|
|
|
public function suggestRestoreAction(\EWW\Dpf\Domain\Model\Document $document) { |
|
858
|
|
|
|
|
859
|
|
|
if (!$this->authorizationChecker->isGranted(DocumentVoter::SUGGEST_RESTORE, $document)) { |
|
860
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_suggestRestore.accessDenied'; |
|
861
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
862
|
|
|
$this->redirect('showDetails', 'Document', null, ['document' => $document]); |
|
863
|
|
|
return FALSE; |
|
|
|
|
|
|
864
|
|
|
} |
|
865
|
|
|
|
|
866
|
|
|
$this->view->assign('document', $document); |
|
867
|
|
|
} |
|
868
|
|
|
|
|
869
|
|
|
/** |
|
870
|
|
|
* @param Document $document |
|
871
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
|
872
|
|
|
*/ |
|
873
|
|
|
public function suggestModificationAction(\EWW\Dpf\Domain\Model\Document $document) { |
|
874
|
|
|
|
|
875
|
|
|
$this->authorizationChecker->denyAccessUnlessGranted(DocumentVoter::SUGGEST_MODIFICATION, $document); |
|
876
|
|
|
|
|
877
|
|
|
$documentMapper = $this->objectManager->get(DocumentMapper::class); |
|
878
|
|
|
|
|
879
|
|
|
/* @var $newDocument \EWW\Dpf\Domain\Model\Document */ |
|
880
|
|
|
$documentForm = $documentMapper->getDocumentForm($document); |
|
881
|
|
|
|
|
882
|
|
|
$this->view->assign('suggestMod', true); |
|
883
|
|
|
$this->forward('edit','DocumentFormBackoffice',NULL, ['documentForm' => $documentForm, 'suggestMod' => true]); |
|
884
|
|
|
} |
|
885
|
|
|
|
|
886
|
|
|
|
|
887
|
|
|
/** |
|
888
|
|
|
* initializeAction |
|
889
|
|
|
*/ |
|
890
|
|
|
public function initializeAction() |
|
891
|
|
|
{ |
|
892
|
|
|
$this->authorizationChecker->denyAccessUnlessLoggedIn(); |
|
893
|
|
|
|
|
894
|
|
|
parent::initializeAction(); |
|
895
|
|
|
|
|
896
|
|
|
$this->workflow = $this->objectManager->get(DocumentWorkflow::class)->getWorkflow(); |
|
897
|
|
|
|
|
898
|
|
|
if ($this->request->hasArgument('document')) { |
|
899
|
|
|
$document = $this->request->getArgument('document'); |
|
900
|
|
|
|
|
901
|
|
|
if (is_array($document) && key_exists("__identity", $document)) { |
|
902
|
|
|
$document = $document["__identity"]; |
|
903
|
|
|
} |
|
904
|
|
|
|
|
905
|
|
|
$document = $this->documentManager->read($document, $this->security->getUser()->getUID()); |
|
906
|
|
|
|
|
907
|
|
|
if (!$document) { |
|
908
|
|
|
$this->redirectToDocumentList(); |
|
909
|
|
|
} |
|
910
|
|
|
|
|
911
|
|
|
$this->request->setArgument('document', $document); |
|
912
|
|
|
} |
|
913
|
|
|
} |
|
914
|
|
|
|
|
915
|
|
|
/** |
|
916
|
|
|
* Redirect to the current document list. |
|
917
|
|
|
* |
|
918
|
|
|
* @param null $message |
|
|
|
|
|
|
919
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
|
920
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
|
921
|
|
|
*/ |
|
922
|
|
|
protected function redirectToDocumentList($message = null) |
|
|
|
|
|
|
923
|
|
|
{ |
|
924
|
|
|
list($action, $controller, $redirectUri) = $this->session->getStoredAction(); |
|
925
|
|
|
|
|
926
|
|
|
if ($redirectUri) { |
|
927
|
|
|
$this->redirectToUri($redirectUri); |
|
928
|
|
|
} else { |
|
929
|
|
|
$this->redirect($action, $controller); |
|
930
|
|
|
} |
|
931
|
|
|
} |
|
932
|
|
|
|
|
933
|
|
|
/** |
|
934
|
|
|
* Gets the storage PID of the current client |
|
935
|
|
|
* |
|
936
|
|
|
* @return mixed |
|
937
|
|
|
*/ |
|
938
|
|
|
protected function getStoragePID() |
|
939
|
|
|
{ |
|
940
|
|
|
return $this->settings['persistence']['classes']['EWW\Dpf\Domain\Model\Document']['newRecordStoragePid']; |
|
941
|
|
|
} |
|
942
|
|
|
|
|
943
|
|
|
/** |
|
944
|
|
|
* |
|
945
|
|
|
* @param \EWW\Dpf\Domain\Model\Document $document |
|
946
|
|
|
* @param string $key |
|
947
|
|
|
* @param string $severity |
|
948
|
|
|
* @param string $defaultMessage |
|
949
|
|
|
*/ |
|
950
|
|
|
protected function flashMessage(\EWW\Dpf\Domain\Model\Document $document, $key, $severity, $defaultMessage = "") |
|
951
|
|
|
{ |
|
952
|
|
|
// Show success or failure of the action in a flash message |
|
953
|
|
|
if ($document) { |
|
|
|
|
|
|
954
|
|
|
$args[] = $document->getTitle(); |
|
|
|
|
|
|
955
|
|
|
$args[] = $document->getObjectIdentifier(); |
|
956
|
|
|
} |
|
957
|
|
|
|
|
958
|
|
|
$message = LocalizationUtility::translate($key, 'dpf', $args); |
|
|
|
|
|
|
959
|
|
|
$message = empty($message) ? $defaultMessage : $message; |
|
960
|
|
|
|
|
961
|
|
|
$this->addFlashMessage( |
|
962
|
|
|
$message, |
|
963
|
|
|
'', |
|
964
|
|
|
$severity, |
|
|
|
|
|
|
965
|
|
|
true |
|
966
|
|
|
); |
|
967
|
|
|
} |
|
968
|
|
|
|
|
969
|
|
|
/** |
|
970
|
|
|
* Updates the document in combination with a state transition. |
|
971
|
|
|
* |
|
972
|
|
|
* @param Document $document |
|
973
|
|
|
* @param $workflowTransition |
|
974
|
|
|
* @param string $reason |
|
975
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
|
976
|
|
|
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
|
977
|
|
|
*/ |
|
978
|
|
|
protected function updateDocument(\EWW\Dpf\Domain\Model\Document $document, $workflowTransition, $reason) |
|
979
|
|
|
{ |
|
980
|
|
|
switch ($workflowTransition) { |
|
981
|
|
|
case DocumentWorkflow::TRANSITION_DISCARD: |
|
982
|
|
|
$messageKeyPart = 'document_discard'; |
|
983
|
|
|
break; |
|
984
|
|
|
case DocumentWorkflow::TRANSITION_POSTPONE: |
|
985
|
|
|
$messageKeyPart = 'document_postpone'; |
|
986
|
|
|
break; |
|
987
|
|
|
case DocumentWorkflow::TRANSITION_RELEASE_ACTIVATE: |
|
988
|
|
|
$messageKeyPart = 'document_activate'; |
|
989
|
|
|
break; |
|
990
|
|
|
case DocumentWorkflow::TRANSITION_RELEASE_PUBLISH: |
|
991
|
|
|
$messageKeyPart = 'document_ingest'; |
|
992
|
|
|
break; |
|
993
|
|
|
default: |
|
994
|
|
|
$messageKeyPart = "document_update"; |
|
995
|
|
|
break; |
|
996
|
|
|
} |
|
997
|
|
|
|
|
998
|
|
|
try { |
|
999
|
|
|
if ($reason) { |
|
1000
|
|
|
$timezone = new \DateTimeZone($this->settings['timezone']); |
|
1001
|
|
|
$timeStamp = (new \DateTime('now', $timezone))->format("d.m.Y H:i:s"); |
|
1002
|
|
|
|
|
1003
|
|
|
if ($workflowTransition == DocumentWorkflow::TRANSITION_DISCARD) { |
|
1004
|
|
|
$note = LocalizationUtility::translate( |
|
1005
|
|
|
"manager.document.discard.note", "dpf", [$timeStamp, $reason] |
|
1006
|
|
|
); |
|
1007
|
|
|
} elseif ($workflowTransition == DocumentWorkflow::TRANSITION_POSTPONE) { |
|
1008
|
|
|
$note = LocalizationUtility::translate( |
|
1009
|
|
|
"manager.document.postpone.note", "dpf", [$timeStamp, $reason] |
|
1010
|
|
|
); |
|
1011
|
|
|
} |
|
1012
|
|
|
|
|
1013
|
|
|
$internalFormat = new \EWW\Dpf\Helper\InternalFormat($document->getXmlData()); |
|
1014
|
|
|
$internalFormat->addNote($note); |
|
|
|
|
|
|
1015
|
|
|
$document->setXmlData($internalFormat->getXml()); |
|
1016
|
|
|
} |
|
1017
|
|
|
|
|
1018
|
|
|
if ($this->documentManager->update($document, $workflowTransition)) { |
|
1019
|
|
|
|
|
1020
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:'.$messageKeyPart.'.success'; |
|
1021
|
|
|
$this->flashMessage($document, $key, AbstractMessage::OK); |
|
1022
|
|
|
|
|
1023
|
|
|
if ($this->security->getUserRole() === Security::ROLE_LIBRARIAN) { |
|
1024
|
|
|
switch ($document->getState()) { |
|
1025
|
|
|
case DocumentWorkflow::STATE_POSTPONED_NONE: |
|
1026
|
|
|
case DocumentWorkflow::STATE_DISCARDED_NONE: |
|
1027
|
|
|
case DocumentWorkflow::STATE_NONE_INACTIVE: |
|
1028
|
|
|
case DocumentWorkflow::STATE_NONE_ACTIVE: |
|
1029
|
|
|
case DocumentWorkflow::STATE_NONE_DELETED: |
|
1030
|
|
|
|
|
1031
|
|
|
if ( |
|
1032
|
|
|
$this->bookmarkRepository->removeBookmark( |
|
1033
|
|
|
$document, |
|
1034
|
|
|
$this->security->getUser()->getUid() |
|
1035
|
|
|
) |
|
1036
|
|
|
) { |
|
1037
|
|
|
$this->addFlashMessage( |
|
1038
|
|
|
LocalizationUtility::translate("manager.workspace.bookmarkRemoved.singular", "dpf"), '', |
|
1039
|
|
|
AbstractMessage::INFO |
|
1040
|
|
|
); |
|
1041
|
|
|
} |
|
1042
|
|
|
|
|
1043
|
|
|
break; |
|
1044
|
|
|
} |
|
1045
|
|
|
} |
|
1046
|
|
|
|
|
1047
|
|
|
$this->redirectToDocumentList(); |
|
1048
|
|
|
} else { |
|
1049
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:'.$messageKeyPart.'.failure'; |
|
1050
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
1051
|
|
|
$this->redirect('showDetails', 'Document', NULL, ['document' => $document]); |
|
1052
|
|
|
} |
|
1053
|
|
|
} catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $e) { |
|
1054
|
|
|
// A redirect always throws this exception, but in this case, however, |
|
1055
|
|
|
// redirection is desired and should not lead to an exception handling |
|
1056
|
|
|
} catch (\Exception $exception) { |
|
1057
|
|
|
if ($exception instanceof DPFExceptionInterface) { |
|
1058
|
|
|
$key = $exception->messageLanguageKey(); |
|
1059
|
|
|
} else { |
|
1060
|
|
|
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:'.$messageKeyPart.'.failure'; |
|
1061
|
|
|
} |
|
1062
|
|
|
$this->flashMessage($document, $key, AbstractMessage::ERROR); |
|
1063
|
|
|
$this->redirectToDocumentList(); |
|
1064
|
|
|
} |
|
1065
|
|
|
|
|
1066
|
|
|
} |
|
1067
|
|
|
} |
|
1068
|
|
|
|