‪TYPO3CMS  9.5
ActionHandler.php
Go to the documentation of this file.
1 <?php
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 
31 
36 {
40  protected ‪$stageService;
41 
45  protected ‪$workspaceService;
46 
50  public function ‪__construct()
51  {
52  $this->stageService = GeneralUtility::makeInstance(StagesService::class);
53  $this->workspaceService = GeneralUtility::makeInstance(WorkspaceService::class);
54  }
55 
62  public function ‪generateWorkspacePreviewLink($uid)
63  {
64  return GeneralUtility::makeInstance(PreviewUriBuilder::class)->buildUriForPage((int)$uid, 0);
65  }
66 
74  {
75  return GeneralUtility::makeInstance(PreviewUriBuilder::class)->buildUrisForAllLanguagesOfPage((int)$uid);
76  }
77 
86  public function ‪swapSingleRecord($table, $t3ver_oid, $orig_uid)
87  {
88  $versionRecord = ‪BackendUtility::getRecord($table, $orig_uid);
89  $currentWorkspace = $this->‪setTemporaryWorkspace($versionRecord['t3ver_wsid']);
90 
91  $cmd[$table][$t3ver_oid]['version'] = [
92  'action' => 'swap',
93  'swapWith' => $orig_uid,
94  'swapIntoWS' => 1
95  ];
96  $this->‪processTcaCmd($cmd);
97 
98  $this->‪setTemporaryWorkspace($currentWorkspace);
99  }
100 
108  public function ‪deleteSingleRecord($table, $uid)
109  {
110  $versionRecord = ‪BackendUtility::getRecord($table, $uid);
111  $currentWorkspace = $this->‪setTemporaryWorkspace($versionRecord['t3ver_wsid']);
112 
113  $cmd[$table][$uid]['version'] = [
114  'action' => 'clearWSID'
115  ];
116  $this->‪processTcaCmd($cmd);
117 
118  $this->‪setTemporaryWorkspace($currentWorkspace);
119  }
120 
128  public function ‪viewSingleRecord($table, $uid)
129  {
130  return GeneralUtility::makeInstance(PreviewUriBuilder::class)->buildUriForElement($table, $uid);
131  }
132 
139  public function ‪executeSelectionAction($parameter)
140  {
141  $result = [];
142 
143  if (empty($parameter->action) || empty($parameter->selection)) {
144  $result['error'] = 'No action or record selection given';
145  return $result;
146  }
147 
148  $commands = [];
149  $swapIntoWorkspace = ($parameter->action === 'swap');
150  if ($parameter->action === 'publish' || $swapIntoWorkspace) {
151  $commands = $this->‪getPublishSwapCommands($parameter->selection, $swapIntoWorkspace);
152  } elseif ($parameter->action === 'discard') {
153  $commands = $this->‪getFlushCommands($parameter->selection);
154  }
155 
156  $result = $this->‪processTcaCmd($commands);
157  $result['total'] = count($commands);
158  return $result;
159  }
160 
168  protected function ‪getPublishSwapCommands(array $selection, $swapIntoWorkspace)
169  {
170  $commands = [];
171  foreach ($selection as $record) {
172  $commands[$record->table][$record->liveId]['version'] = [
173  'action' => 'swap',
174  'swapWith' => $record->versionId,
175  'swapIntoWS' => (bool)$swapIntoWorkspace,
176  ];
177  }
178  return $commands;
179  }
180 
187  protected function ‪getFlushCommands(array $selection)
188  {
189  $commands = [];
190  foreach ($selection as $record) {
191  $commands[$record->table][$record->versionId]['version'] = [
192  'action' => 'clearWSID',
193  ];
194  }
195  return $commands;
196  }
197 
203  public function ‪saveColumnModel($model)
204  {
205  $data = [];
206  foreach ($model as $column) {
207  $data[$column->column] = [
208  'position' => $column->position,
209  'hidden' => $column->hidden
210  ];
211  }
212  $this->‪getBackendUser()->uc['moduleData']['Workspaces'][$this->‪getBackendUser()->workspace]['columns'] = $data;
213  $this->‪getBackendUser()->‪writeUC();
214  }
215 
216  public function ‪loadColumnModel()
217  {
218  if (is_array($this->‪getBackendUser()->uc['moduleData']['Workspaces'][$this->‪getBackendUser()->workspace]['columns'])) {
219  return $this->‪getBackendUser()->uc['moduleData']['Workspaces'][$this->‪getBackendUser()->workspace]['columns'];
220  }
221  return [];
222  }
223 
229  public function ‪saveLanguageSelection($language)
230  {
231  if (‪MathUtility::canBeInterpretedAsInteger($language) === false && $language !== 'all') {
232  $language = 'all';
233  }
234  $this->‪getBackendUser()->uc['moduleData']['Workspaces'][$this->‪getBackendUser()->workspace]['language'] = $language;
235  $this->‪getBackendUser()->‪writeUC();
236  }
237 
246  public function ‪sendToNextStageWindow($uid, $table, $t3ver_oid)
247  {
248  $elementRecord = ‪BackendUtility::getRecord($table, $uid);
249  $currentWorkspace = $this->‪setTemporaryWorkspace($elementRecord['t3ver_wsid']);
250 
251  if (is_array($elementRecord)) {
252  $workspaceRecord = ‪WorkspaceRecord::get($elementRecord['t3ver_wsid']);
253  $nextStageRecord = $workspaceRecord->getNextStage($elementRecord['t3ver_stage']);
254  if ($nextStageRecord !== null) {
255  $this->stageService->getRecordService()->add($table, $uid);
256  $result = $this->‪getSentToStageWindow($nextStageRecord);
257  $result['affects'] = [
258  'table' => $table,
259  'nextStage' => $nextStageRecord->getUid(),
260  't3ver_oid' => $t3ver_oid,
261  'uid' => $uid
262  ];
263  } else {
264  $result = $this->‪getErrorResponse('error.stageId.invalid', 1291111644);
265  }
266  } else {
267  $result = $this->‪getErrorResponse('error.sendToNextStage.noRecordFound', 1287264776);
268  }
269 
270  $this->‪setTemporaryWorkspace($currentWorkspace);
271  return $result;
272  }
273 
281  public function ‪sendToPrevStageWindow($uid, $table)
282  {
283  $elementRecord = ‪BackendUtility::getRecord($table, $uid);
284  $currentWorkspace = $this->‪setTemporaryWorkspace($elementRecord['t3ver_wsid']);
285 
286  if (is_array($elementRecord)) {
287  $workspaceRecord = ‪WorkspaceRecord::get($elementRecord['t3ver_wsid']);
288  $stageRecord = $workspaceRecord->getStage($elementRecord['t3ver_stage']);
289 
290  if ($stageRecord !== null) {
291  if (!$stageRecord->isEditStage()) {
292  $this->stageService->getRecordService()->add($table, $uid);
293  $previousStageRecord = $stageRecord->getPrevious();
294  $result = $this->‪getSentToStageWindow($previousStageRecord);
295  $result['affects'] = [
296  'table' => $table,
297  'uid' => $uid,
298  'nextStage' => $previousStageRecord->getUid()
299  ];
300  } else {
301  // element is already in edit stage, there is no prev stage - return an error message
302  $result = $this->‪getErrorResponse('error.sendToPrevStage.noPreviousStage', 1287264746);
303  }
304  } else {
305  $result = $this->‪getErrorResponse('error.stageId.invalid', 1291111644);
306  }
307  } else {
308  $result = $this->‪getErrorResponse('error.sendToNextStage.noRecordFound', 1287264765);
309  }
310 
311  $this->‪setTemporaryWorkspace($currentWorkspace);
312  return $result;
313  }
314 
322  public function ‪sendToSpecificStageWindow($nextStageId, array $elements)
323  {
324  foreach ($elements as $element) {
325  $this->stageService->getRecordService()->add(
326  $element->table,
327  $element->uid
328  );
329  }
330 
331  $result = $this->‪getSentToStageWindow($nextStageId);
332  $result['affects'] = [
333  'nextStage' => $nextStageId
334  ];
335  return $result;
336  }
337 
347  public function ‪getRecipientList(array $uidOfRecipients, $additionalRecipients, $stageId)
348  {
349  $stageRecord = ‪WorkspaceRecord::get($this->‪getCurrentWorkspace())->‪getStage($stageId);
350 
351  if ($stageRecord === null) {
352  throw new \InvalidArgumentException(
353  $this->‪getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'),
354  1476044776
355  );
356  }
357 
358  $recipients = [];
359  $finalRecipients = [];
360  $backendUserIds = $stageRecord->getAllRecipients();
361  foreach ($uidOfRecipients as $userUid) {
362  // Ensure that only configured backend users are considered
363  if (!in_array($userUid, $backendUserIds)) {
364  continue;
365  }
366  $beUserRecord = ‪BackendUtility::getRecord('be_users', (int)$userUid);
367  if (is_array($beUserRecord) && $beUserRecord['email'] !== '') {
368  $uc = $beUserRecord['uc'] ? unserialize($beUserRecord['uc'], ['allowed_classes' => false]) : [];
369  $recipients[$beUserRecord['email']] = [
370  'email' => $beUserRecord['email'],
371  'lang' => $uc['lang'] ?? $beUserRecord['lang']
372  ];
373  }
374  }
375 
376  if ($stageRecord->hasPreselection() && !$stageRecord->isPreselectionChangeable()) {
377  $preselectedBackendUsers = $this->stageService->getBackendUsers(
378  implode(',', $this->stageService->getPreselectedRecipients($stageRecord))
379  );
380 
381  foreach ($preselectedBackendUsers as $preselectedBackendUser) {
382  if (empty($preselectedBackendUser['email']) || !GeneralUtility::validEmail($preselectedBackendUser['email'])) {
383  continue;
384  }
385  if (!isset($recipients[$preselectedBackendUser['email']])) {
386  $uc = (!empty($preselectedBackendUser['uc']) ? unserialize($preselectedBackendUser['uc'], ['allowed_classes' => false]) : []);
387  $recipients[$preselectedBackendUser['email']] = [
388  'email' => $preselectedBackendUser['email'],
389  'lang' => $uc['lang'] ?? $preselectedBackendUser['lang']
390  ];
391  }
392  }
393  }
394 
395  if ($additionalRecipients !== '') {
396  $emails = GeneralUtility::trimExplode(LF, $additionalRecipients, true);
397  $additionalRecipients = [];
398  foreach ($emails as $email) {
399  $additionalRecipients[$email] = ['email' => $email];
400  }
401  } else {
402  $additionalRecipients = [];
403  }
404  // We merge $recipients on top of $additionalRecipients because $recipients
405  // possibly is more complete with a user language. Furthermore, the list of
406  // recipients is automatically unique since we indexed $additionalRecipients
407  // and $recipients with the email address
408  $allRecipients = array_merge($additionalRecipients, $recipients);
409  foreach ($allRecipients as $email => $recipientInformation) {
410  if (GeneralUtility::validEmail($email)) {
411  $finalRecipients[] = $recipientInformation;
412  }
413  }
414  return $finalRecipients;
415  }
416 
423  public function ‪discardStagesFromPage($pageId)
424  {
425  $cmdMapArray = [];
426  $workspaceItemsArray = $this->workspaceService->selectVersionsInWorkspace(
427  $this->stageService->getWorkspaceId(),
428  $filter = 1,
429  $stage = -99,
430  $pageId,
431  $recursionLevel = 0,
432  $selectionType = 'tables_modify'
433  );
434  foreach ($workspaceItemsArray as $tableName => $items) {
435  foreach ($items as $item) {
436  $cmdMapArray[$tableName][$item['uid']]['version']['action'] = 'clearWSID';
437  }
438  }
439  $this->‪processTcaCmd($cmdMapArray);
440  return [
441  'success' => true
442  ];
443  }
444 
459  public function ‪sentCollectionToStage(\stdClass $parameters)
460  {
461  $cmdMapArray = [];
462  $comment = $parameters->comments;
463  $stageId = $parameters->stageId;
464  if (‪MathUtility::canBeInterpretedAsInteger($stageId) === false) {
465  throw new \InvalidArgumentException('Missing "stageId" in $parameters array.', 1319488194);
466  }
467  if (!is_object($parameters->affects) || empty($parameters->affects)) {
468  throw new \InvalidArgumentException('Missing "affected items" in $parameters array.', 1319488195);
469  }
470  $recipients = $this->‪getRecipientList((array)$parameters->recipients, $parameters->additional, $stageId);
471  foreach ($parameters->affects as $tableName => $items) {
472  foreach ($items as $item) {
473  // Publishing uses live id in command map
475  $cmdMapArray[$tableName][$item->t3ver_oid]['version']['action'] = 'swap';
476  $cmdMapArray[$tableName][$item->t3ver_oid]['version']['swapWith'] = $item->uid;
477  $cmdMapArray[$tableName][$item->t3ver_oid]['version']['comment'] = $comment;
478  $cmdMapArray[$tableName][$item->t3ver_oid]['version']['notificationAlternativeRecipients'] = $recipients;
479  } else {
480  // Setting stage uses version id in command map
481  $cmdMapArray[$tableName][$item->uid]['version']['action'] = 'setStage';
482  $cmdMapArray[$tableName][$item->uid]['version']['stageId'] = $stageId;
483  $cmdMapArray[$tableName][$item->uid]['version']['comment'] = $comment;
484  $cmdMapArray[$tableName][$item->uid]['version']['notificationAlternativeRecipients'] = $recipients;
485  }
486  }
487  }
488  $this->‪processTcaCmd($cmdMapArray);
489  return [
490  'success' => true,
491  // force refresh after publishing changes
492  'refreshLivePanel' => $parameters->stageId == -20
493  ];
494  }
495 
502  protected function ‪processTcaCmd(array $cmdMapArray)
503  {
504  $result = [];
505 
506  if (empty($cmdMapArray)) {
507  $result['error'] = 'No commands given to be processed';
508  return $result;
509  }
510 
511  $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
512  $dataHandler->start([], $cmdMapArray);
513  $dataHandler->process_cmdmap();
514 
515  if ($dataHandler->errorLog) {
516  $result['error'] = implode('<br/>', $dataHandler->errorLog);
517  }
518 
519  return $result;
520  }
521 
537  public function ‪sendToNextStageExecute(\stdClass $parameters)
538  {
539  $cmdArray = [];
540  $setStageId = $parameters->affects->nextStage;
541  $comments = $parameters->comments;
542  $table = $parameters->affects->table;
543  $uid = $parameters->affects->uid;
544  $t3ver_oid = $parameters->affects->t3ver_oid;
545 
546  $elementRecord = ‪BackendUtility::getRecord($table, $uid);
547  $currentWorkspace = $this->‪setTemporaryWorkspace($elementRecord['t3ver_wsid']);
548 
549  $recipients = $this->‪getRecipientList((array)$parameters->recipients, $parameters->additional, $setStageId);
550  if ($setStageId == ‪StagesService::STAGE_PUBLISH_EXECUTE_ID) {
551  $cmdArray[$table][$t3ver_oid]['version']['action'] = 'swap';
552  $cmdArray[$table][$t3ver_oid]['version']['swapWith'] = $uid;
553  $cmdArray[$table][$t3ver_oid]['version']['comment'] = $comments;
554  $cmdArray[$table][$t3ver_oid]['version']['notificationAlternativeRecipients'] = $recipients;
555  } else {
556  $cmdArray[$table][$uid]['version']['action'] = 'setStage';
557  $cmdArray[$table][$uid]['version']['stageId'] = $setStageId;
558  $cmdArray[$table][$uid]['version']['comment'] = $comments;
559  $cmdArray[$table][$uid]['version']['notificationAlternativeRecipients'] = $recipients;
560  }
561  $this->‪processTcaCmd($cmdArray);
562  $result = [
563  'success' => true
564  ];
565 
566  $this->‪setTemporaryWorkspace($currentWorkspace);
567  return $result;
568  }
569 
584  public function ‪sendToPrevStageExecute(\stdClass $parameters)
585  {
586  $cmdArray = [];
587  $setStageId = $parameters->affects->nextStage;
588  $comments = $parameters->comments;
589  $table = $parameters->affects->table;
590  $uid = $parameters->affects->uid;
591 
592  $elementRecord = ‪BackendUtility::getRecord($table, $uid);
593  $currentWorkspace = $this->‪setTemporaryWorkspace($elementRecord['t3ver_wsid']);
594 
595  $recipients = $this->‪getRecipientList((array)$parameters->recipients, $parameters->additional, $setStageId);
596  $cmdArray[$table][$uid]['version']['action'] = 'setStage';
597  $cmdArray[$table][$uid]['version']['stageId'] = $setStageId;
598  $cmdArray[$table][$uid]['version']['comment'] = $comments;
599  $cmdArray[$table][$uid]['version']['notificationAlternativeRecipients'] = $recipients;
600  $this->‪processTcaCmd($cmdArray);
601  $result = [
602  'success' => true
603  ];
604 
605  $this->‪setTemporaryWorkspace($currentWorkspace);
606  return $result;
607  }
608 
630  public function ‪sendToSpecificStageExecute(\stdClass $parameters)
631  {
632  $cmdArray = [];
633  $setStageId = $parameters->affects->nextStage;
634  $comments = $parameters->comments;
635  $elements = $parameters->affects->elements;
636  $recipients = $this->‪getRecipientList((array)$parameters->recipients, $parameters->additional, $setStageId);
637  foreach ($elements as $element) {
638  // Avoid any action on records that have already been published to live
639  $elementRecord = ‪BackendUtility::getRecord($element->table, $element->uid);
640  if ((int)$elementRecord['t3ver_wsid'] === 0) {
641  continue;
642  }
643 
644  if ($setStageId == ‪StagesService::STAGE_PUBLISH_EXECUTE_ID) {
645  $cmdArray[$element->table][$element->t3ver_oid]['version']['action'] = 'swap';
646  $cmdArray[$element->table][$element->t3ver_oid]['version']['swapWith'] = $element->uid;
647  $cmdArray[$element->table][$element->t3ver_oid]['version']['comment'] = $comments;
648  $cmdArray[$element->table][$element->t3ver_oid]['version']['notificationAlternativeRecipients'] = $recipients;
649  } else {
650  $cmdArray[$element->table][$element->uid]['version']['action'] = 'setStage';
651  $cmdArray[$element->table][$element->uid]['version']['stageId'] = $setStageId;
652  $cmdArray[$element->table][$element->uid]['version']['comment'] = $comments;
653  $cmdArray[$element->table][$element->uid]['version']['notificationAlternativeRecipients'] = $recipients;
654  }
655  }
656  $this->‪processTcaCmd($cmdArray);
657  $result = [
658  'success' => true
659  ];
660  return $result;
661  }
662 
669  protected function ‪getSentToStageWindow($nextStage)
670  {
671  if (!$nextStage instanceof StageRecord) {
672  $nextStage = ‪WorkspaceRecord::get($this->‪getCurrentWorkspace())->‪getStage($nextStage);
673  }
674 
675  $result = [];
676  if ($nextStage->isDialogEnabled()) {
677  $result['sendMailTo'] = $this->‪getRecipientsOfStage($nextStage);
678  $result['additional'] = [
679  'type' => 'textarea',
680  'value' => ''
681  ];
682  }
683  $result['comments'] = [
684  'type' => 'textarea',
685  'value' => $nextStage->isInternal() ? '' : $nextStage->getDefaultComment()
686  ];
687 
688  return $result;
689  }
690 
697  protected function ‪getRecipientsOfStage($stageRecord)
698  {
699  if (!$stageRecord instanceof StageRecord) {
700  $stageRecord = ‪WorkspaceRecord::get($this->‪getCurrentWorkspace())->‪getStage($stageRecord);
701  }
702 
703  $result = [];
704  $allRecipients = $this->stageService->getResponsibleBeUser($stageRecord);
705  $preselectedRecipients = $this->stageService->‪getPreselectedRecipients($stageRecord);
706  $isPreselectionChangeable = $stageRecord->isPreselectionChangeable();
707 
708  foreach ($allRecipients as $backendUserId => $backendUser) {
709  if (empty($backendUser['email']) || !GeneralUtility::validEmail($backendUser['email'])) {
710  continue;
711  }
712 
713  $name = (!empty($backendUser['realName']) ? $backendUser['realName'] : $backendUser['username']);
714  $checked = in_array($backendUserId, $preselectedRecipients);
715  $disabled = ($checked && !$isPreselectionChangeable);
716 
717  $result[] = [
718  'label' => sprintf('%s (%s)', $name, $backendUser['email']),
719  'value' => $backendUserId,
720  'name' => 'recipients-' . $backendUserId,
721  'checked' => $checked,
722  'disabled' => $disabled
723  ];
724  }
725 
726  return $result;
727  }
728 
735  protected function ‪getDefaultCommentOfStage($stage)
736  {
737  $result = $this->stageService->getPropertyOfCurrentWorkspaceStage($stage, 'default_mailcomment');
738  return $result;
739  }
740 
747  public function ‪sendPageToPreviousStage($id)
748  {
749  $workspaceItemsArray = $this->workspaceService->selectVersionsInWorkspace(
750  $this->stageService->getWorkspaceId(),
751  $filter = 1,
752  $stage = -99,
753  $id,
754  $recursionLevel = 0,
755  $selectionType = 'tables_modify'
756  );
757  list($currentStage, $previousStage) = $this->stageService->getPreviousStageForElementCollection($workspaceItemsArray);
758  // get only the relevant items for processing
759  $workspaceItemsArray = $this->workspaceService->selectVersionsInWorkspace(
760  $this->stageService->getWorkspaceId(),
761  $filter = 1,
762  $currentStage['uid'],
763  $id,
764  $recursionLevel = 0,
765  $selectionType = 'tables_modify'
766  );
767  $stageFormFields = $this->‪getSentToStageWindow($previousStage['uid']);
768  $result = array_merge($stageFormFields, [
769  'title' => 'Status message: Page send to next stage - ID: ' . $id . ' - Next stage title: ' . $previousStage['title'],
770  'items' => $this->‪getSentToStageWindow($previousStage['uid']),
771  'affects' => $workspaceItemsArray,
772  'stageId' => $previousStage['uid']
773  ]);
774  return $result;
775  }
776 
781  public function ‪sendPageToNextStage($id)
782  {
783  $workspaceItemsArray = $this->workspaceService->selectVersionsInWorkspace(
784  $this->stageService->getWorkspaceId(),
785  $filter = 1,
786  $stage = -99,
787  $id,
788  $recursionLevel = 0,
789  $selectionType = 'tables_modify'
790  );
791  list($currentStage, $nextStage) = $this->stageService->getNextStageForElementCollection($workspaceItemsArray);
792  // get only the relevant items for processing
793  $workspaceItemsArray = $this->workspaceService->selectVersionsInWorkspace(
794  $this->stageService->getWorkspaceId(),
795  $filter = 1,
796  $currentStage['uid'],
797  $id,
798  $recursionLevel = 0,
799  $selectionType = 'tables_modify'
800  );
801  $stageFormFields = $this->‪getSentToStageWindow($nextStage['uid']);
802  $result = array_merge($stageFormFields, [
803  'title' => 'Status message: Page send to next stage - ID: ' . $id . ' - Next stage title: ' . $nextStage['title'],
804  'affects' => $workspaceItemsArray,
805  'stageId' => $nextStage['uid']
806  ]);
807  return $result;
808  }
809 
816  public function ‪updateStageChangeButtons($id)
817  {
818  // fetch the next and previous stage
819  $workspaceItemsArray = $this->workspaceService->selectVersionsInWorkspace(
820  $this->stageService->getWorkspaceId(),
821  $filter = 1,
822  $stage = -99,
823  $id,
824  $recursionLevel = 0,
825  $selectionType = 'tables_modify'
826  );
827  list(, $nextStage) = $this->stageService->getNextStageForElementCollection($workspaceItemsArray);
828  list(, $previousStage) = $this->stageService->getPreviousStageForElementCollection($workspaceItemsArray);
829 
830  $view = GeneralUtility::makeInstance(StandaloneView::class);
831  $extensionPath = ‪ExtensionManagementUtility::extPath('workspaces');
832  $view->setPartialRootPaths(['default' => $extensionPath . 'Resources/Private/Partials']);
833  $view->setTemplatePathAndFilename($extensionPath . 'Resources/Private/Templates/Preview/Ajax/StageButtons.html');
834  $request = $view->getRequest();
835  $request->setControllerExtensionName('workspaces');
836  $view->assignMultiple([
837  'enablePreviousStageButton' => is_array($previousStage) && !empty($previousStage),
838  'enableNextStageButton' => is_array($nextStage) && !empty($nextStage),
839  'enableDiscardStageButton' => is_array($nextStage) && !empty($nextStage) || is_array($previousStage) && !empty($previousStage),
840  'nextStage' => $nextStage['title'],
841  'nextStageId' => $nextStage['uid'],
842  'prevStage' => $previousStage['title'],
843  'prevStageId' => $previousStage['uid'],
844  ]);
845  $renderedView = $view->render();
846  return $renderedView;
847  }
848 
854  protected function ‪setTemporaryWorkspace($workspaceId)
855  {
856  $workspaceId = (int)$workspaceId;
857  $currentWorkspace = (int)$this->‪getBackendUser()->workspace;
858 
859  if ($currentWorkspace !== $workspaceId) {
860  if (!$this->‪getBackendUser()->‪setTemporaryWorkspace($workspaceId)) {
861  throw new Exception(
862  'Cannot set temporary workspace to "' . $workspaceId . '"',
863  1371484524
864  );
865  }
866  }
867 
868  return $currentWorkspace;
869  }
870 
874  protected function ‪getBackendUser()
875  {
876  return ‪$GLOBALS['BE_USER'];
877  }
878 
882  protected function ‪getLanguageService()
883  {
884  return ‪$GLOBALS['LANG'];
885  }
886 
895  protected function ‪getErrorResponse($errorLabel, $errorCode = 0, $successFlagValue = false)
896  {
897  $localLangFile = 'LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf';
898  $response = [
899  'error' => [
900  'code' => $errorCode,
901  'message' => $this->‪getLanguageService()->‪sL($localLangFile . ':' . $errorLabel)
902  ],
903  'success' => $successFlagValue
904  ];
905  return $response;
906  }
907 
913  protected function ‪getCurrentWorkspace()
914  {
915  return $this->workspaceService->getCurrentWorkspace();
916  }
917 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:81
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\getRecipientsOfStage
‪array getRecipientsOfStage($stageRecord)
Definition: ActionHandler.php:695
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\sendToSpecificStageWindow
‪array sendToSpecificStageWindow($nextStageId, array $elements)
Definition: ActionHandler.php:320
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\viewSingleRecord
‪string viewSingleRecord($table, $uid)
Definition: ActionHandler.php:126
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\sendToPrevStageWindow
‪array sendToPrevStageWindow($uid, $table)
Definition: ActionHandler.php:279
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\sentCollectionToStage
‪array sentCollectionToStage(\stdClass $parameters)
Definition: ActionHandler.php:457
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger($var)
Definition: MathUtility.php:73
‪TYPO3\CMS\Core\Authentication\AbstractUserAuthentication\writeUC
‪writeUC($variable='')
Definition: AbstractUserAuthentication.php:1172
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: ActionHandler.php:872
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\setTemporaryWorkspace
‪int setTemporaryWorkspace($workspaceId)
Definition: ActionHandler.php:852
‪TYPO3\CMS\Core\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\getSentToStageWindow
‪array getSentToStageWindow($nextStage)
Definition: ActionHandler.php:667
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\sendPageToNextStage
‪array sendPageToNextStage($id)
Definition: ActionHandler.php:779
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\saveColumnModel
‪saveColumnModel($model)
Definition: ActionHandler.php:201
‪TYPO3\CMS\Core\Exception
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\swapSingleRecord
‪swapSingleRecord($table, $t3ver_oid, $orig_uid)
Definition: ActionHandler.php:84
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\getFlushCommands
‪array getFlushCommands(array $selection)
Definition: ActionHandler.php:185
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\getErrorResponse
‪array getErrorResponse($errorLabel, $errorCode=0, $successFlagValue=false)
Definition: ActionHandler.php:893
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\sendPageToPreviousStage
‪array sendPageToPreviousStage($id)
Definition: ActionHandler.php:745
‪TYPO3\CMS\Workspaces\Domain\Record\WorkspaceRecord
Definition: WorkspaceRecord.php:24
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\getLanguageService
‪LanguageService getLanguageService()
Definition: ActionHandler.php:880
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:158
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\sendToNextStageExecute
‪array sendToNextStageExecute(\stdClass $parameters)
Definition: ActionHandler.php:535
‪TYPO3\CMS\Workspaces\Service\StagesService\STAGE_PUBLISH_EXECUTE_ID
‪const STAGE_PUBLISH_EXECUTE_ID
Definition: StagesService.php:34
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\discardStagesFromPage
‪array discardStagesFromPage($pageId)
Definition: ActionHandler.php:421
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\sendToNextStageWindow
‪array sendToNextStageWindow($uid, $table, $t3ver_oid)
Definition: ActionHandler.php:244
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\getPreselectedRecipients
‪int[] getPreselectedRecipients()
Definition: StageRecord.php:338
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\generateWorkspacePreviewLink
‪string generateWorkspacePreviewLink($uid)
Definition: ActionHandler.php:60
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:36
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\getDefaultCommentOfStage
‪string getDefaultCommentOfStage($stage)
Definition: ActionHandler.php:733
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\getCurrentWorkspace
‪int getCurrentWorkspace()
Definition: ActionHandler.php:911
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord
Definition: StageRecord.php:22
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\processTcaCmd
‪array processTcaCmd(array $cmdMapArray)
Definition: ActionHandler.php:500
‪TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder
Definition: PreviewUriBuilder.php:39
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\getPublishSwapCommands
‪array getPublishSwapCommands(array $selection, $swapIntoWorkspace)
Definition: ActionHandler.php:166
‪TYPO3\CMS\Workspaces\Controller\Remote
Definition: ActionHandler.php:2
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\sendToSpecificStageExecute
‪array sendToSpecificStageExecute(\stdClass $parameters)
Definition: ActionHandler.php:628
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Workspaces\Service\WorkspaceService
Definition: WorkspaceService.php:34
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:130
‪TYPO3\CMS\Workspaces\Service\StagesService
Definition: StagesService.php:31
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\$stageService
‪StagesService $stageService
Definition: ActionHandler.php:39
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\sendToPrevStageExecute
‪array sendToPrevStageExecute(\stdClass $parameters)
Definition: ActionHandler.php:582
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\updateStageChangeButtons
‪string updateStageChangeButtons($id)
Definition: ActionHandler.php:814
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\loadColumnModel
‪loadColumnModel()
Definition: ActionHandler.php:214
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:32
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler
Definition: ActionHandler.php:36
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\getRecipientList
‪array getRecipientList(array $uidOfRecipients, $additionalRecipients, $stageId)
Definition: ActionHandler.php:345
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:21
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\extPath
‪static string extPath($key, $script='')
Definition: ExtensionManagementUtility.php:149
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\generateWorkspacePreviewLinksForAllLanguages
‪array generateWorkspacePreviewLinksForAllLanguages($uid)
Definition: ActionHandler.php:71
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\saveLanguageSelection
‪saveLanguageSelection($language)
Definition: ActionHandler.php:227
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\__construct
‪__construct()
Definition: ActionHandler.php:48
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\executeSelectionAction
‪array executeSelectionAction($parameter)
Definition: ActionHandler.php:137
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\setTemporaryWorkspace
‪bool setTemporaryWorkspace($workspaceId)
Definition: BackendUserAuthentication.php:2276
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\$workspaceService
‪WorkspaceService $workspaceService
Definition: ActionHandler.php:43
‪TYPO3\CMS\Workspaces\Domain\Record\WorkspaceRecord\get
‪static WorkspaceRecord get($uid, array $record=null)
Definition: WorkspaceRecord.php:67
‪TYPO3\CMS\Workspaces\Controller\Remote\ActionHandler\deleteSingleRecord
‪deleteSingleRecord($table, $uid)
Definition: ActionHandler.php:106
‪TYPO3\CMS\Workspaces\Domain\Record\WorkspaceRecord\getStage
‪StageRecord null getStage($stageId)
Definition: WorkspaceRecord.php:142