| Total Complexity | 130 |
| Total Lines | 1050 |
| Duplicated Lines | 0 % |
| Changes | 7 | ||
| Bugs | 1 | Features | 0 |
Complex classes like DocumentController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DocumentController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 39 | class DocumentController extends \EWW\Dpf\Controller\AbstractController |
||
| 40 | { |
||
| 41 | |||
| 42 | /** |
||
| 43 | * documentRepository |
||
| 44 | * |
||
| 45 | * @var \EWW\Dpf\Domain\Repository\DocumentRepository |
||
| 46 | * @inject |
||
| 47 | */ |
||
| 48 | protected $documentRepository = null; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * inputOptionListRepository |
||
| 52 | * |
||
| 53 | * @var \EWW\Dpf\Domain\Repository\InputOptionListRepository |
||
| 54 | * @inject |
||
| 55 | */ |
||
| 56 | protected $inputOptionListRepository = null; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * persistence manager |
||
| 60 | * |
||
| 61 | * @var \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface |
||
| 62 | * @inject |
||
| 63 | */ |
||
| 64 | protected $persistenceManager; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * documentValidator |
||
| 68 | * |
||
| 69 | * @var \EWW\Dpf\Helper\DocumentValidator |
||
| 70 | * @inject |
||
| 71 | */ |
||
| 72 | protected $documentValidator; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * workflow |
||
| 76 | * |
||
| 77 | * @var \EWW\Dpf\Domain\Workflow\DocumentWorkflow |
||
| 78 | */ |
||
| 79 | protected $workflow; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * documentTransferManager |
||
| 83 | * |
||
| 84 | * @var \EWW\Dpf\Services\Transfer\DocumentTransferManager $documentTransferManager |
||
| 85 | */ |
||
| 86 | protected $documentTransferManager; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * fedoraRepository |
||
| 90 | * |
||
| 91 | * @var \EWW\Dpf\Services\Transfer\FedoraRepository $fedoraRepository |
||
| 92 | */ |
||
| 93 | protected $fedoraRepository; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * fileRepository |
||
| 97 | * |
||
| 98 | * @var \EWW\Dpf\Domain\Repository\FileRepository |
||
| 99 | * @inject |
||
| 100 | */ |
||
| 101 | protected $fileRepository = null; |
||
| 102 | |||
| 103 | |||
| 104 | /** |
||
| 105 | * frontendUserRepository |
||
| 106 | * |
||
| 107 | * @var \EWW\Dpf\Domain\Repository\FrontendUserRepository |
||
| 108 | * @inject |
||
| 109 | */ |
||
| 110 | protected $frontendUserRepository = null; |
||
| 111 | |||
| 112 | |||
| 113 | /** |
||
| 114 | * DocumentController constructor. |
||
| 115 | */ |
||
| 116 | public function __construct() |
||
| 117 | { |
||
| 118 | parent::__construct(); |
||
| 119 | |||
| 120 | $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
||
| 121 | $this->documentTransferManager = $objectManager->get(DocumentTransferManager::class); |
||
| 122 | $this->fedoraRepository = $objectManager->get(FedoraRepository::class); |
||
| 123 | $this->documentTransferManager->setRemoteRepository($this->fedoraRepository); |
||
| 124 | } |
||
| 125 | |||
| 126 | /** |
||
| 127 | * action logout of the backoffice |
||
| 128 | * |
||
| 129 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
||
| 130 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
||
| 131 | */ |
||
| 132 | public function logoutAction() |
||
| 133 | { |
||
| 134 | $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class); |
||
| 135 | $uri = $cObj->typolink_URL([ |
||
| 136 | 'parameter' => $this->settings['loginPage'], |
||
| 137 | //'linkAccessRestrictedPages' => 1, |
||
| 138 | 'forceAbsoluteUrl' => 1, |
||
| 139 | 'additionalParams' => GeneralUtility::implodeArrayForUrl(NULL, ['logintype'=>'logout']) |
||
| 140 | ]); |
||
| 141 | |||
| 142 | $this->redirectToUri($uri); |
||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * action list |
||
| 147 | * |
||
| 148 | * @param array $stateFilters |
||
| 149 | * |
||
| 150 | * @return void |
||
| 151 | */ |
||
| 152 | public function listAction($stateFilters = array()) |
||
| 153 | { |
||
| 154 | $this->setSessionData('redirectToDocumentListAction','list'); |
||
| 155 | $this->setSessionData('redirectToDocumentListController','Document'); |
||
| 156 | |||
| 157 | list($isWorkspace, $documents) = $this->getListViewData($stateFilters); |
||
| 158 | |||
| 159 | if ($this->request->hasArgument('message')) { |
||
| 160 | $this->view->assign('message', $this->request->getArgument('message')); |
||
| 161 | } |
||
| 162 | |||
| 163 | if ($this->request->hasArgument('errorFiles')) { |
||
| 164 | $this->view->assign('errorFiles', $this->request->getArgument('errorFiles')); |
||
| 165 | } |
||
| 166 | |||
| 167 | $this->view->assign('currentUser', $this->security->getUser()); |
||
| 168 | $this->view->assign('isWorkspace', $isWorkspace); |
||
| 169 | $this->view->assign('documents', $documents); |
||
| 170 | } |
||
| 171 | |||
| 172 | public function listSuggestionsAction() { |
||
| 173 | $this->setSessionData('redirectToDocumentListAction','listSuggestions'); |
||
| 174 | $this->setSessionData('redirectToDocumentListController','Document'); |
||
| 175 | |||
| 176 | list($isWorkspace, $documents) = $this->getListViewData([], true); |
||
| 177 | |||
| 178 | if ($this->request->hasArgument('message')) { |
||
| 179 | $this->view->assign('message', $this->request->getArgument('message')); |
||
| 180 | } |
||
| 181 | |||
| 182 | if ($this->request->hasArgument('errorFiles')) { |
||
| 183 | $this->view->assign('errorFiles', $this->request->getArgument('errorFiles')); |
||
| 184 | } |
||
| 185 | |||
| 186 | $this->view->assign('currentUser', $this->security->getUser()); |
||
| 187 | $this->view->assign('isWorkspace', $isWorkspace); |
||
| 188 | $this->view->assign('documents', $documents); |
||
| 189 | } |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @param Document $document |
||
| 193 | * @param bool $acceptAll |
||
| 194 | */ |
||
| 195 | public function acceptSuggestionAction(\EWW\Dpf\Domain\Model\Document $document, bool $acceptAll = true) { |
||
| 196 | |||
| 197 | $args = $this->request->getArguments(); |
||
|
|
|||
| 198 | |||
| 199 | /** @var DocumentMapper $documentMapper */ |
||
| 200 | $documentMapper = $this->objectManager->get(DocumentMapper::class); |
||
| 201 | |||
| 202 | // Existing working copy? |
||
| 203 | /** @var \EWW\Dpf\Domain\Model\Document $originDocument */ |
||
| 204 | $linkedUid = $document->getLinkedUid(); |
||
| 205 | $originDocument = $this->documentRepository->findWorkingCopy($linkedUid); |
||
| 206 | |||
| 207 | if ($originDocument) { |
||
| 208 | $linkedDocumentForm = $documentMapper->getDocumentForm($originDocument); |
||
| 209 | } else { |
||
| 210 | // get remote document |
||
| 211 | $originDocument = $this->documentTransferManager->retrieve($document->getLinkedUid(), $this->security->getUser()->getUid()); |
||
| 212 | $linkedDocumentForm = $documentMapper->getDocumentForm($originDocument); |
||
| 213 | } |
||
| 214 | |||
| 215 | if ($acceptAll) { |
||
| 216 | // all changes are confirmed |
||
| 217 | // copy suggest to origin document |
||
| 218 | $originDocument->copy($document, true); |
||
| 219 | |||
| 220 | if ($originDocument->getTransferStatus() == 'RESTORE') { |
||
| 221 | if ($originDocument->getObjectIdentifier()) { |
||
| 222 | $originDocument->setState(DocumentWorkflow::STATE_IN_PROGRESS_ACTIVE); |
||
| 223 | } else { |
||
| 224 | $originDocument->setState(DocumentWorkflow::STATE_IN_PROGRESS_NONE); |
||
| 225 | } |
||
| 226 | } |
||
| 227 | |||
| 228 | // copy files from suggest document |
||
| 229 | foreach ($document->getFile() as $key => $file) { |
||
| 230 | $newFile = $this->objectManager->get(File::class); |
||
| 231 | $newFile->copy($file); |
||
| 232 | $newFile->setDocument($originDocument); |
||
| 233 | $this->fileRepository->add($newFile); |
||
| 234 | $originDocument->addFile($newFile); |
||
| 235 | |||
| 236 | } |
||
| 237 | |||
| 238 | $this->documentRepository->update($originDocument); |
||
| 239 | $this->documentRepository->remove($document); |
||
| 240 | |||
| 241 | // redirect to document |
||
| 242 | $this->redirect('showDetails', 'Document', null, ['document' => $originDocument]); |
||
| 243 | } |
||
| 244 | |||
| 245 | $this->redirectToDocumentList(); |
||
| 246 | } |
||
| 247 | |||
| 248 | |||
| 249 | public function showSuggestionDetailsAction(\EWW\Dpf\Domain\Model\Document $document) { |
||
| 250 | $this->authorizationChecker->denyAccessUnlessGranted(DocumentVoter::SHOW_DETAILS, $document); |
||
| 251 | |||
| 252 | /** @var DocumentMapper $documentMapper */ |
||
| 253 | $documentMapper = $this->objectManager->get(DocumentMapper::class); |
||
| 254 | |||
| 255 | $linkedUid = $document->getLinkedUid(); |
||
| 256 | $linkedDocument = $this->documentRepository->findWorkingCopy($linkedUid); |
||
| 257 | |||
| 258 | if ($linkedDocument) { |
||
| 259 | // Existing working copy |
||
| 260 | $linkedDocumentForm = $documentMapper->getDocumentForm($linkedDocument); |
||
| 261 | } else { |
||
| 262 | // No existing working copy, get remote document from fedora |
||
| 263 | $linkedDocument = $this->documentTransferManager->retrieve($document->getLinkedUid(), $this->security->getUser()->getUid()); |
||
| 264 | $linkedDocumentForm = $documentMapper->getDocumentForm($linkedDocument); |
||
| 265 | } |
||
| 266 | |||
| 267 | $newDocumentForm = $documentMapper->getDocumentForm($document); |
||
| 268 | $diff = $this->documentFormDiff($linkedDocumentForm, $newDocumentForm); |
||
| 269 | |||
| 270 | //$usernameString = $this->security->getUser()->getUsername(); |
||
| 271 | $user = $this->frontendUserRepository->findOneByUid($document->getOwner()); |
||
| 272 | |||
| 273 | if ($user) { |
||
| 274 | $usernameString = $user->getUsername(); |
||
| 275 | } |
||
| 276 | |||
| 277 | $this->view->assign('documentOwner', $usernameString); |
||
| 278 | $this->view->assign('diff', $diff); |
||
| 279 | $this->view->assign('document', $document); |
||
| 280 | |||
| 281 | } |
||
| 282 | |||
| 283 | public function documentFormDiff($docForm1, $docForm2) { |
||
| 284 | $returnArray = ['changed' => ['new' => [], 'old' => []], 'deleted' => [], 'added' => []]; |
||
| 285 | |||
| 286 | // pages |
||
| 287 | foreach ($docForm1->getItems() as $keyPage => $valuePage) { |
||
| 288 | foreach ($valuePage as $keyRepeatPage => $valueRepeatPage) { |
||
| 289 | |||
| 290 | // groups |
||
| 291 | foreach ($valueRepeatPage->getItems() as $keyGroup => $valueGroup) { |
||
| 292 | |||
| 293 | $checkFieldsForAdding = false; |
||
| 294 | $valueGroupCounter = count($valueGroup); |
||
| 295 | |||
| 296 | if ($valueGroupCounter < count($docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup])) { |
||
| 297 | $checkFieldsForAdding = true; |
||
| 298 | } |
||
| 299 | |||
| 300 | foreach ($valueGroup as $keyRepeatGroup => $valueRepeatGroup) { |
||
| 301 | |||
| 302 | // fields |
||
| 303 | foreach ($valueRepeatGroup->getItems() as $keyField => $valueField) { |
||
| 304 | foreach ($valueField as $keyRepeatField => $valueRepeatField) { |
||
| 305 | |||
| 306 | $fieldCounter = count($docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup]); |
||
| 307 | $valueFieldCounter = count($valueField); |
||
| 308 | |||
| 309 | // check if group or field is not existing |
||
| 310 | $notExisting = false; |
||
| 311 | try { |
||
| 312 | $flag = 'page'; |
||
| 313 | $value2 = $docForm2->getItems()[$keyPage]; |
||
| 314 | $flag = 'group'; |
||
| 315 | $value2 = $value2[$keyRepeatPage]; |
||
| 316 | $value2 = $value2->getItems()[$keyGroup]; |
||
| 317 | $value2 = $value2[$keyRepeatGroup]->getItems()[$keyField]; |
||
| 318 | $flag = 'field'; |
||
| 319 | } catch (\Throwable $t) { |
||
| 320 | $notExisting = true; |
||
| 321 | } |
||
| 322 | |||
| 323 | $item = NULL; |
||
| 324 | if ($flag == 'group') { |
||
| 325 | $itemExisting = $valueRepeatGroup; |
||
| 326 | $itemNew = $docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup]; |
||
| 327 | } else if ($flag == 'field') { |
||
| 328 | $itemExisting = $valueRepeatField; |
||
| 329 | $itemNew = $docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup][$keyRepeatGroup]->getItems()[$keyField][$keyRepeatField]; |
||
| 330 | } |
||
| 331 | |||
| 332 | if ($notExisting || ($valueRepeatField->getValue() != $value2[$keyRepeatField]->getValue() && empty($value2[$keyRepeatField]->getValue()))) { |
||
| 333 | // deleted |
||
| 334 | $returnArray['deleted'][] = $itemExisting; |
||
| 335 | |||
| 336 | } else if ($this->removeControlCharacterFromString($valueRepeatField->getValue()) != $this->removeControlCharacterFromString($value2[$keyRepeatField]->getValue()) |
||
| 337 | && !empty($value2[$keyRepeatField]->getValue())) { |
||
| 338 | |||
| 339 | // changed |
||
| 340 | $returnArray['changed']['old'][] = $itemExisting; |
||
| 341 | $returnArray['changed']['new'][] = $itemNew; |
||
| 342 | } |
||
| 343 | |||
| 344 | if ($flag == 'group') { |
||
| 345 | break 2; |
||
| 346 | } |
||
| 347 | } |
||
| 348 | |||
| 349 | // check if new document form has more field items as the existing form |
||
| 350 | if ($valueFieldCounter < $fieldCounter && !$checkFieldsForAdding) { |
||
| 351 | // field added |
||
| 352 | for ($i = count($valueField); $i < $fieldCounter;$i++) { |
||
| 353 | $returnArray['added'][] = $docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup][$keyRepeatGroup]->getItems()[$keyField][$i]; |
||
| 354 | |||
| 355 | } |
||
| 356 | } |
||
| 357 | } |
||
| 358 | } |
||
| 359 | |||
| 360 | // check if new document form has more group items as the existing form |
||
| 361 | if ($valueGroupCounter < count($docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup])) { |
||
| 362 | // group added |
||
| 363 | $counter = count($docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup]); |
||
| 364 | for ($i = $valueGroupCounter; $i < $counter;$i++) { |
||
| 365 | $returnArray['added'][] = $docForm2->getItems()[$keyPage][$keyRepeatPage]->getItems()[$keyGroup][$i]; |
||
| 366 | } |
||
| 367 | } |
||
| 368 | } |
||
| 369 | } |
||
| 370 | |||
| 371 | } |
||
| 372 | |||
| 373 | return $returnArray; |
||
| 374 | |||
| 375 | } |
||
| 376 | |||
| 377 | public function removeControlCharacterFromString($string) { |
||
| 378 | return preg_replace('/\p{C}+/u', "", $string); |
||
| 379 | } |
||
| 380 | |||
| 381 | public function listRegisteredAction() |
||
| 382 | { |
||
| 383 | $this->setSessionData('redirectToDocumentListAction','listRegistered'); |
||
| 384 | $this->setSessionData('redirectToDocumentListController','Document'); |
||
| 385 | |||
| 386 | list($isWorkspace, $documents) = $this->getListViewData([DocumentWorkflow::STATE_REGISTERED_NONE]); |
||
| 387 | |||
| 388 | if ($this->request->hasArgument('message')) { |
||
| 389 | $this->view->assign('message', $this->request->getArgument('message')); |
||
| 390 | } |
||
| 391 | |||
| 392 | if ($this->request->hasArgument('errorFiles')) { |
||
| 393 | $this->view->assign('errorFiles', $this->request->getArgument('errorFiles')); |
||
| 394 | } |
||
| 395 | |||
| 396 | $this->view->assign('isWorkspace', $isWorkspace); |
||
| 397 | $this->view->assign('documents', $documents); |
||
| 398 | } |
||
| 399 | |||
| 400 | public function listInProgressAction() |
||
| 401 | { |
||
| 402 | $this->setSessionData('redirectToDocumentListAction','listInProgress'); |
||
| 403 | $this->setSessionData('redirectToDocumentListController','Document'); |
||
| 404 | |||
| 405 | if ($this->request->hasArgument('message')) { |
||
| 406 | $this->view->assign('message', $this->request->getArgument('message')); |
||
| 407 | } |
||
| 408 | |||
| 409 | if ($this->request->hasArgument('errorFiles')) { |
||
| 410 | $this->view->assign('errorFiles', $this->request->getArgument('errorFiles')); |
||
| 411 | } |
||
| 412 | |||
| 413 | list($isWorkspace, $documents) = $this->getListViewData( |
||
| 414 | [ |
||
| 415 | DocumentWorkflow::STATE_IN_PROGRESS_NONE, |
||
| 416 | DocumentWorkflow::STATE_IN_PROGRESS_ACTIVE, |
||
| 417 | DocumentWorkflow::STATE_IN_PROGRESS_INACTIVE, |
||
| 418 | DocumentWorkflow::STATE_IN_PROGRESS_DELETED, |
||
| 419 | ] |
||
| 420 | ); |
||
| 421 | |||
| 422 | $this->view->assign('isWorkspace', $isWorkspace); |
||
| 423 | $this->view->assign('documents', $documents); |
||
| 424 | } |
||
| 425 | |||
| 426 | |||
| 427 | /** |
||
| 428 | * action discard |
||
| 429 | * |
||
| 430 | * @param \EWW\Dpf\Domain\Model\Document $document |
||
| 431 | * @param integer $tstamp |
||
| 432 | * @param string $reason |
||
| 433 | * @return void |
||
| 434 | */ |
||
| 435 | public function discardAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp, $reason = NULL) |
||
| 436 | { |
||
| 437 | if (!$this->authorizationChecker->isGranted(DocumentVoter::DISCARD, $document)) { |
||
| 438 | if ($document->getEditorUid()) { |
||
| 439 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_discard.failureBlocked'; |
||
| 440 | } else { |
||
| 441 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_discard.accessDenied'; |
||
| 442 | } |
||
| 443 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 444 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 445 | return FALSE; |
||
| 446 | } |
||
| 447 | |||
| 448 | $document->setEditorUid($this->security->getUser()->getUid()); |
||
| 449 | |||
| 450 | if ($reason) { |
||
| 451 | $timeStamp = (new \DateTime)->format("d.m.Y H:i:s"); |
||
| 452 | $note = "Das Dokument wurde verworfen: ".$timeStamp."\n"."Kommentar: ".$reason; |
||
| 453 | $slub = new \EWW\Dpf\Helper\Slub($document->getSlubInfoData()); |
||
| 454 | $slub->addNote($note); |
||
| 455 | $document->setSlubInfoData($slub->getSlubXml()); |
||
| 456 | } |
||
| 457 | |||
| 458 | try { |
||
| 459 | if ( |
||
| 460 | in_array( |
||
| 461 | $document->getState(), |
||
| 462 | [ |
||
| 463 | DocumentWorkflow::STATE_IN_PROGRESS_DELETED, |
||
| 464 | DocumentWorkflow::STATE_IN_PROGRESS_INACTIVE, |
||
| 465 | DocumentWorkflow::STATE_IN_PROGRESS_ACTIVE |
||
| 466 | ] |
||
| 467 | ) |
||
| 468 | ) { |
||
| 469 | if ($document->getTemporary()) { |
||
| 470 | $noNewerVersion = $this->documentTransferManager->getLastModDate($document->getObjectIdentifier()) === $document->getRemoteLastModDate(); |
||
| 471 | } else { |
||
| 472 | $noNewerVersion = $tstamp === $document->getTstamp(); |
||
| 473 | } |
||
| 474 | |||
| 475 | if ($noNewerVersion) { |
||
| 476 | if ($this->documentTransferManager->delete($document, "") && $this->documentTransferManager->update($document)) { |
||
| 477 | $this->workflow->apply($document, DocumentWorkflow::TRANSITION_DISCARD); |
||
| 478 | $this->documentRepository->update($document); |
||
| 479 | $this->documentRepository->remove($document); |
||
| 480 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_discard.success'; |
||
| 481 | $this->flashMessage($document, $key, AbstractMessage::OK); |
||
| 482 | $this->redirectToDocumentList(); |
||
| 483 | } else { |
||
| 484 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_discard.failure'; |
||
| 485 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 486 | $this->redirect('showDetails', 'Document', NULL, ['document' => $document]); |
||
| 487 | } |
||
| 488 | } else { |
||
| 489 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_discard.failureNewVersion'; |
||
| 490 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 491 | $this->redirect('showDetails', 'Document', NULL, ['document' => $document]); |
||
| 492 | } |
||
| 493 | } else { |
||
| 494 | if ($tstamp === $document->getTstamp()) { |
||
| 495 | $this->workflow->apply($document, DocumentWorkflow::TRANSITION_DISCARD); |
||
| 496 | $this->documentRepository->update($document); |
||
| 497 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_discard.success'; |
||
| 498 | $this->flashMessage($document, $key, AbstractMessage::OK); |
||
| 499 | $this->redirectToDocumentList(); |
||
| 500 | } else { |
||
| 501 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_discard.failureNewVersion'; |
||
| 502 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 503 | $this->redirect('showDetails', 'Document', NULL, ['document' => $document]); |
||
| 504 | } |
||
| 505 | } |
||
| 506 | } catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $e) { |
||
| 507 | // A redirect always throws this exception, but in this case, however, |
||
| 508 | // redirection is desired and should not lead to an exception handling |
||
| 509 | } catch (\Exception $exception) { |
||
| 510 | if ($exception instanceof DPFExceptionInterface) { |
||
| 511 | $key = $exception->messageLanguageKey(); |
||
| 512 | } else { |
||
| 513 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_discard.failure'; |
||
| 514 | } |
||
| 515 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 516 | $this->redirectToDocumentList(); |
||
| 517 | } |
||
| 518 | } |
||
| 519 | |||
| 520 | /** |
||
| 521 | * action postpone |
||
| 522 | * |
||
| 523 | * @param \EWW\Dpf\Domain\Model\Document $document |
||
| 524 | * @param integer $tstamp |
||
| 525 | * @param string $reason |
||
| 526 | * @return void |
||
| 527 | */ |
||
| 528 | public function postponeAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp, $reason = NULL) |
||
| 529 | { |
||
| 530 | if (!$this->authorizationChecker->isGranted(DocumentVoter::POSTPONE, $document)) { |
||
| 531 | if ($document->getEditorUid()) { |
||
| 532 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_postpone.failureBlocked'; |
||
| 533 | } else { |
||
| 534 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_postpone.accessDenied'; |
||
| 535 | } |
||
| 536 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 537 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 538 | return FALSE; |
||
| 539 | } |
||
| 540 | |||
| 541 | $document->setEditorUid($this->security->getUser()->getUid()); |
||
| 542 | |||
| 543 | if ($reason) { |
||
| 544 | $timeStamp = (new \DateTime)->format("d.m.Y H:i:s"); |
||
| 545 | $note = "Das Dokument wurde zurückgestellt: ".$timeStamp."\n"."Kommentar: ".$reason; |
||
| 546 | $slub = new \EWW\Dpf\Helper\Slub($document->getSlubInfoData()); |
||
| 547 | $slub->addNote($note); |
||
| 548 | $document->setSlubInfoData($slub->getSlubXml()); |
||
| 549 | } |
||
| 550 | |||
| 551 | try { |
||
| 552 | if ( |
||
| 553 | in_array( |
||
| 554 | $document->getState(), |
||
| 555 | [ |
||
| 556 | DocumentWorkflow::STATE_IN_PROGRESS_DELETED, |
||
| 557 | DocumentWorkflow::STATE_IN_PROGRESS_INACTIVE, |
||
| 558 | DocumentWorkflow::STATE_IN_PROGRESS_ACTIVE |
||
| 559 | ] |
||
| 560 | ) |
||
| 561 | ) { |
||
| 562 | if ($document->getTemporary()) { |
||
| 563 | $noNewerVersion = $this->documentTransferManager->getLastModDate($document->getObjectIdentifier()) === $document->getRemoteLastModDate(); |
||
| 564 | } else { |
||
| 565 | $noNewerVersion = $tstamp === $document->getTstamp(); |
||
| 566 | } |
||
| 567 | |||
| 568 | if ($noNewerVersion) { |
||
| 569 | if ($this->documentTransferManager->delete($document, "inactivate") && $this->documentTransferManager->update($document)) { |
||
| 570 | $this->workflow->apply($document, \EWW\Dpf\Domain\Workflow\DocumentWorkflow::TRANSITION_POSTPONE); |
||
| 571 | $this->documentRepository->update($document); |
||
| 572 | $this->documentRepository->remove($document); |
||
| 573 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_postpone.success'; |
||
| 574 | $this->flashMessage($document, $key, AbstractMessage::OK); |
||
| 575 | $this->redirectToDocumentList(); |
||
| 576 | } else { |
||
| 577 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_postpone.failure'; |
||
| 578 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 579 | $this->redirect('showDetails', 'Document', NULL, ['document' => $document]); |
||
| 580 | } |
||
| 581 | } else { |
||
| 582 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_postpone.failureNewVersion'; |
||
| 583 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 584 | $this->redirect('showDetails', 'Document', NULL, ['document' => $document]); |
||
| 585 | } |
||
| 586 | } else { |
||
| 587 | if ($tstamp === $document->getTstamp()) { |
||
| 588 | $this->workflow->apply($document, \EWW\Dpf\Domain\Workflow\DocumentWorkflow::TRANSITION_POSTPONE); |
||
| 589 | $this->documentRepository->update($document); |
||
| 590 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_postpone.success'; |
||
| 591 | $this->flashMessage($document, $key, AbstractMessage::OK); |
||
| 592 | $this->redirectToDocumentList(); |
||
| 593 | } else { |
||
| 594 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_postpone.failureNewVersion'; |
||
| 595 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 596 | $this->redirect('showDetails', 'Document', NULL, ['document' => $document]); |
||
| 597 | } |
||
| 598 | } |
||
| 599 | } catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $e) { |
||
| 600 | // A redirect always throws this exception, but in this case, however, |
||
| 601 | // redirection is desired and should not lead to an exception handling |
||
| 602 | } catch (\Exception $exception) { |
||
| 603 | if ($exception instanceof DPFExceptionInterface) { |
||
| 604 | $key = $exception->messageLanguageKey(); |
||
| 605 | } else { |
||
| 606 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_postpone.failed'; |
||
| 607 | } |
||
| 608 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 609 | $this->redirectToDocumentList(); |
||
| 610 | } |
||
| 611 | } |
||
| 612 | |||
| 613 | |||
| 614 | /** |
||
| 615 | * action deleteLocallyAction |
||
| 616 | * |
||
| 617 | * @param Document $document |
||
| 618 | * @param integer $tstamp |
||
| 619 | * @return void |
||
| 620 | */ |
||
| 621 | public function deleteLocallyAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp) |
||
| 622 | { |
||
| 623 | if ($document->getObjectIdentifier()) { |
||
| 624 | $voterAttribute = DocumentVoter::DELETE_WORKING_COPY; |
||
| 625 | } else { |
||
| 626 | $voterAttribute = DocumentVoter::DELETE_LOCALLY; |
||
| 627 | } |
||
| 628 | |||
| 629 | if (!$this->authorizationChecker->isGranted($voterAttribute, $document)) { |
||
| 630 | if ($document->getEditorUid()) { |
||
| 631 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_deleteLocally.failureBlocked'; |
||
| 632 | } else { |
||
| 633 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_deleteLocally.accessDenied'; |
||
| 634 | } |
||
| 635 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 636 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 637 | return FALSE; |
||
| 638 | } |
||
| 639 | |||
| 640 | if ($tstamp === $document->getTstamp()) { |
||
| 641 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_deleteLocally.success'; |
||
| 642 | $this->flashMessage($document, $key, AbstractMessage::OK); |
||
| 643 | $this->documentRepository->remove($document); |
||
| 644 | |||
| 645 | $suggestions = $this->documentRepository->findByLinkedUid($document->getUid()); |
||
| 646 | foreach ($suggestions as $suggestion) { |
||
| 647 | $this->documentRepository->remove($suggestion); |
||
| 648 | } |
||
| 649 | |||
| 650 | $this->redirectToDocumentList(); |
||
| 651 | } else { |
||
| 652 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_deleteLocally.failureNewVersion'; |
||
| 653 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 654 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 655 | } |
||
| 656 | } |
||
| 657 | |||
| 658 | /** |
||
| 659 | * action duplicate |
||
| 660 | * |
||
| 661 | * @param \EWW\Dpf\Domain\Model\Document $document |
||
| 662 | * @return void |
||
| 663 | */ |
||
| 664 | public function duplicateAction(\EWW\Dpf\Domain\Model\Document $document) |
||
| 722 | } |
||
| 723 | } |
||
| 724 | |||
| 725 | |||
| 726 | /** |
||
| 727 | * releaseUpdateAction |
||
| 728 | * |
||
| 729 | * @param \EWW\Dpf\Domain\Model\Document $document |
||
| 730 | * @param integer $tstamp |
||
| 731 | * @return void |
||
| 732 | */ |
||
| 733 | public function releaseUpdateAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp) |
||
| 734 | { |
||
| 735 | if (!$this->authorizationChecker->isGranted(DocumentVoter::RELEASE_UPDATE, $document)) { |
||
| 736 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.accessDenied'; |
||
| 737 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 738 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 739 | return FALSE; |
||
| 740 | } |
||
| 741 | |||
| 742 | try { |
||
| 743 | if ( |
||
| 744 | $this->documentTransferManager->getLastModDate($document->getObjectIdentifier()) === $document->getRemoteLastModDate() && |
||
| 745 | $tstamp === $document->getTstamp() |
||
| 746 | ) { |
||
| 747 | if ($this->documentTransferManager->update($document)) { |
||
| 748 | $this->documentRepository->remove($document); |
||
| 749 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.success'; |
||
| 750 | $this->flashMessage($document, $key, AbstractMessage::OK); |
||
| 751 | $this->redirect('list'); |
||
| 752 | } |
||
| 753 | } else { |
||
| 754 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.failureNewVersion'; |
||
| 755 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 756 | $this->redirect('showDetails', 'Document', NULL, ['document' => $document]); |
||
| 757 | } |
||
| 758 | } catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $e) { |
||
| 759 | // A redirect always throws this exception, but in this case, however, |
||
| 760 | // redirection is desired and should not lead to an exception handling |
||
| 761 | } catch (\Exception $exception) { |
||
| 762 | if ($exception instanceof DPFExceptionInterface) { |
||
| 763 | $key = $exception->messageLanguageKey(); |
||
| 764 | } else { |
||
| 765 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:error.unexpected'; |
||
| 766 | } |
||
| 767 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 768 | $this->redirect('list'); |
||
| 769 | } |
||
| 770 | |||
| 771 | } |
||
| 772 | |||
| 773 | /** |
||
| 774 | * releasePublishAction |
||
| 775 | * |
||
| 776 | * @param \EWW\Dpf\Domain\Model\Document $document |
||
| 777 | * @param integer $tstamp |
||
| 778 | * @return void |
||
| 779 | */ |
||
| 780 | public function releasePublishAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp) |
||
| 781 | { |
||
| 782 | if (!$this->authorizationChecker->isGranted(DocumentVoter::RELEASE_PUBLISH, $document)) { |
||
| 783 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_ingest.accessDenied'; |
||
| 784 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 785 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 786 | return FALSE; |
||
| 787 | } |
||
| 788 | |||
| 789 | try { |
||
| 790 | if ($tstamp === $document->getTstamp()) { |
||
| 791 | if ($this->documentTransferManager->ingest($document)) { |
||
| 792 | $notifier = $this->objectManager->get(Notifier::class); |
||
| 793 | $notifier->sendIngestNotification($document); |
||
| 794 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_ingest.success'; |
||
| 795 | $this->flashMessage($document, $key, AbstractMessage::OK); |
||
| 796 | $this->redirectToDocumentList(); |
||
| 797 | } else { |
||
| 798 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_ingest.failure'; |
||
| 799 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 800 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 801 | } |
||
| 802 | } else { |
||
| 803 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_ingest.failureNewVersion'; |
||
| 804 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 805 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 806 | } |
||
| 807 | } catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $e) { |
||
| 808 | // A redirect always throws this exception, but in this case, however, |
||
| 809 | // redirection is desired and should not lead to an exception handling |
||
| 810 | } catch (\Exception $exception) { |
||
| 811 | |||
| 812 | if ($exception instanceof DPFExceptionInterface) { |
||
| 813 | $key = $exception->messageLanguageKey(); |
||
| 814 | } else { |
||
| 815 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:error.unexpected'; |
||
| 816 | } |
||
| 817 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 818 | $this->redirect('list'); |
||
| 819 | } |
||
| 820 | } |
||
| 821 | |||
| 822 | |||
| 823 | /** |
||
| 824 | * releaseActivateAction |
||
| 825 | * |
||
| 826 | * @param \EWW\Dpf\Domain\Model\Document $document |
||
| 827 | * @param integer $tstamp |
||
| 828 | * @return void |
||
| 829 | */ |
||
| 830 | public function releaseActivateAction(\EWW\Dpf\Domain\Model\Document $document, $tstamp) |
||
| 831 | { |
||
| 832 | if (!$this->authorizationChecker->isGranted(DocumentVoter::RELEASE_ACTIVATE, $document)) { |
||
| 833 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_activate.accessDenied'; |
||
| 834 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 835 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 836 | return FALSE; |
||
| 837 | } |
||
| 838 | |||
| 839 | try { |
||
| 840 | if ( |
||
| 841 | $this->documentTransferManager->getLastModDate($document->getObjectIdentifier()) === $document->getRemoteLastModDate() && |
||
| 842 | $tstamp === $document->getTstamp() |
||
| 843 | ) { |
||
| 844 | if ($this->documentTransferManager->delete($document, "revert") && $this->documentTransferManager->update($document)) { |
||
| 845 | $this->documentRepository->remove($document); |
||
| 846 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_activate.success'; |
||
| 847 | $this->flashMessage($document, $key, AbstractMessage::OK); |
||
| 848 | $this->redirectToDocumentList(); |
||
| 849 | } else { |
||
| 850 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_activate.failure'; |
||
| 851 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 852 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 853 | } |
||
| 854 | } else { |
||
| 855 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_activate.failureNewVersion'; |
||
| 856 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 857 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 858 | } |
||
| 859 | } catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $e) { |
||
| 860 | // A redirect always throws this exception, but in this case, however, |
||
| 861 | // redirection is desired and should not lead to an exception handling |
||
| 862 | } catch (\Exception $exception) { |
||
| 863 | if ($exception instanceof DPFExceptionInterface) { |
||
| 864 | $key = $exception->messageLanguageKey(); |
||
| 865 | } else { |
||
| 866 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:error.unexpected'; |
||
| 867 | } |
||
| 868 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 869 | $this->redirect('list'); |
||
| 870 | } |
||
| 871 | } |
||
| 872 | |||
| 873 | /** |
||
| 874 | * action register |
||
| 875 | * |
||
| 876 | * @param \EWW\Dpf\Domain\Model\Document $document |
||
| 877 | * @return void |
||
| 878 | */ |
||
| 879 | public function registerAction(\EWW\Dpf\Domain\Model\Document $document) |
||
| 880 | { |
||
| 881 | if (!$this->authorizationChecker->isGranted(DocumentVoter::REGISTER, $document)) { |
||
| 882 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_register.accessDenied'; |
||
| 883 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 884 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 885 | } |
||
| 886 | |||
| 887 | if (!$this->documentValidator->validate($document)) { |
||
| 888 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_register.missingValues'; |
||
| 889 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 890 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 891 | } |
||
| 892 | |||
| 893 | $this->workflow->apply($document, \EWW\Dpf\Domain\Workflow\DocumentWorkflow::TRANSITION_REGISTER); |
||
| 894 | $this->documentRepository->update($document); |
||
| 895 | |||
| 896 | $notifier = $this->objectManager->get(Notifier::class); |
||
| 897 | $notifier->sendRegisterNotification($document); |
||
| 898 | |||
| 899 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_register.success'; |
||
| 900 | $this->flashMessage($document, $key, AbstractMessage::OK); |
||
| 901 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 902 | } |
||
| 903 | |||
| 904 | /** |
||
| 905 | * action showDetails |
||
| 906 | * |
||
| 907 | * @param Document $document |
||
| 908 | * @return void |
||
| 909 | */ |
||
| 910 | public function showDetailsAction(\EWW\Dpf\Domain\Model\Document $document) |
||
| 911 | { |
||
| 912 | if (!$this->authorizationChecker->isGranted(DocumentVoter::SHOW_DETAILS, $document)) { |
||
| 913 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_showDetails.accessDenied'; |
||
| 914 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 915 | $this->redirectToDocumentList(); |
||
| 916 | } |
||
| 917 | |||
| 918 | $postponeOptions = $this->inputOptionListRepository->findOneByName($this->settings['postponeOptionListName']); |
||
| 919 | if ($postponeOptions) { |
||
| 920 | $this->view->assign('postponeOptions', $postponeOptions->getInputOptions()); |
||
| 921 | } |
||
| 922 | |||
| 923 | $discardOptions = $this->inputOptionListRepository->findOneByName($this->settings['discardOptionListName']); |
||
| 924 | if ($discardOptions) { |
||
| 925 | $this->view->assign('discardOptions', $discardOptions->getInputOptions()); |
||
| 926 | } |
||
| 927 | |||
| 928 | $this->view->assign('document', $document); |
||
| 929 | } |
||
| 930 | |||
| 931 | |||
| 932 | public function cancelListTaskAction() |
||
| 933 | { |
||
| 934 | $this->redirectToDocumentList(); |
||
| 935 | } |
||
| 936 | |||
| 937 | /** |
||
| 938 | * action uploadFiles |
||
| 939 | * |
||
| 940 | * @param \EWW\Dpf\Domain\Model\Document $document |
||
| 941 | * @return void |
||
| 942 | */ |
||
| 943 | public function uploadFilesAction(\EWW\Dpf\Domain\Model\Document $document) |
||
| 944 | { |
||
| 945 | $this->view->assign('document', $document); |
||
| 946 | } |
||
| 947 | |||
| 948 | /** |
||
| 949 | * action suggest restore |
||
| 950 | * |
||
| 951 | * @param Document $document |
||
| 952 | * @return void |
||
| 953 | */ |
||
| 954 | public function suggestRestoreAction(\EWW\Dpf\Domain\Model\Document $document) { |
||
| 955 | |||
| 956 | if (!$this->authorizationChecker->isGranted(DocumentVoter::SUGGEST_RESTORE, $document)) { |
||
| 957 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_suggestRestore.accessDenied'; |
||
| 958 | $this->flashMessage($document, $key, AbstractMessage::ERROR); |
||
| 959 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 960 | return FALSE; |
||
| 961 | } |
||
| 962 | |||
| 963 | $this->view->assign('document', $document); |
||
| 964 | } |
||
| 965 | |||
| 966 | /** |
||
| 967 | * @param Document $document |
||
| 968 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
||
| 969 | */ |
||
| 970 | public function suggestModificationAction(\EWW\Dpf\Domain\Model\Document $document) { |
||
| 971 | |||
| 972 | $this->authorizationChecker->denyAccessUnlessGranted(DocumentVoter::SUGGEST_MODIFICATION, $document); |
||
| 973 | |||
| 974 | $documentMapper = $this->objectManager->get(DocumentMapper::class); |
||
| 975 | |||
| 976 | /* @var $newDocument \EWW\Dpf\Domain\Model\Document */ |
||
| 977 | $documentForm = $documentMapper->getDocumentForm($document); |
||
| 978 | |||
| 979 | $this->view->assign('suggestMod', true); |
||
| 980 | $this->forward('edit','DocumentFormBackoffice',NULL, ['documentForm' => $documentForm, 'suggestMod' => true]); |
||
| 981 | } |
||
| 982 | |||
| 983 | |||
| 984 | /** |
||
| 985 | * initializeAction |
||
| 986 | */ |
||
| 987 | public function initializeAction() |
||
| 994 | } |
||
| 995 | |||
| 996 | /** |
||
| 997 | * Redirect to the current document list. |
||
| 998 | * |
||
| 999 | * @param null $message |
||
| 1000 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
||
| 1001 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
||
| 1002 | */ |
||
| 1003 | protected function redirectToDocumentList($message = null) |
||
| 1004 | { |
||
| 1005 | $redirectAction = $this->getSessionData('redirectToDocumentListAction'); |
||
| 1006 | $redirectController = $this->getSessionData('redirectToDocumentListController'); |
||
| 1007 | $this->redirect($redirectAction, $redirectController, null, array('message' => $message)); |
||
| 1008 | } |
||
| 1009 | |||
| 1010 | |||
| 1011 | /** |
||
| 1012 | * get list view data |
||
| 1013 | * |
||
| 1014 | * @param array $stateFilters |
||
| 1015 | * @param bool $suggestionsOnly |
||
| 1016 | * |
||
| 1017 | * @return array |
||
| 1018 | */ |
||
| 1019 | protected function getListViewData($stateFilters = array(), bool $suggestionsOnly = false) |
||
| 1020 | { |
||
| 1021 | switch ($this->security->getUserRole()) { |
||
| 1022 | |||
| 1023 | case Security::ROLE_LIBRARIAN: |
||
| 1024 | if ($suggestionsOnly) { |
||
| 1025 | $documents = $this->documentRepository->findAllLibrarianDocumentSuggestions( |
||
| 1026 | $this->security->getUser()->getUid() |
||
| 1027 | ); |
||
| 1028 | } else { |
||
| 1029 | $documents = $this->documentRepository->findAllOfALibrarian( |
||
| 1030 | $this->security->getUser()->getUid(), |
||
| 1031 | $stateFilters |
||
| 1032 | ); |
||
| 1033 | } |
||
| 1034 | $isWorkspace = TRUE; |
||
| 1035 | break; |
||
| 1036 | |||
| 1037 | case Security::ROLE_RESEARCHER; |
||
| 1038 | if ($suggestionsOnly) { |
||
| 1039 | $documents = $this->documentRepository->findAllResearcherDocumentSuggestions( |
||
| 1040 | $this->security->getUser()->getUid() |
||
| 1041 | ); |
||
| 1042 | } else { |
||
| 1043 | $documents = $this->documentRepository->findAllOfAResearcher( |
||
| 1044 | $this->security->getUser()->getUid(), |
||
| 1045 | $stateFilters |
||
| 1046 | ); |
||
| 1047 | } |
||
| 1048 | break; |
||
| 1049 | |||
| 1050 | default: |
||
| 1051 | $documents = NULL; |
||
| 1052 | } |
||
| 1053 | |||
| 1054 | return array( |
||
| 1055 | $isWorkspace, |
||
| 1056 | $documents |
||
| 1057 | ); |
||
| 1058 | } |
||
| 1059 | |||
| 1060 | protected function getStoragePID() |
||
| 1061 | { |
||
| 1062 | return $this->settings['persistence']['classes']['EWW\Dpf\Domain\Model\Document']['newRecordStoragePid']; |
||
| 1063 | } |
||
| 1064 | |||
| 1065 | /** |
||
| 1066 | * |
||
| 1067 | * @param \EWW\Dpf\Domain\Model\Document $document |
||
| 1068 | * @param string $key |
||
| 1069 | * @param string $severity |
||
| 1070 | * @param string $defaultMessage |
||
| 1071 | */ |
||
| 1072 | protected function flashMessage(\EWW\Dpf\Domain\Model\Document $document, $key, $severity, $defaultMessage = "") |
||
| 1089 | ); |
||
| 1090 | |||
| 1091 | } |
||
| 1092 | } |
||
| 1093 |