TYPO3 CMS  TYPO3_6-2
ActionHandler.php
Go to the documentation of this file.
1 <?php
3 
19 
26 
30  protected $stageService;
31 
35  public function __construct() {
36  $this->stageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\StagesService');
37  }
38 
46  return $this->getWorkspaceService()->generateWorkspacePreviewLink($uid);
47  }
48 
56  return $this->getWorkspaceService()->generateWorkspacePreviewLinksForAllLanguages($uid);
57  }
58 
68  public function swapSingleRecord($table, $t3ver_oid, $orig_uid) {
69  $versionRecord = BackendUtility::getRecord($table, $orig_uid);
70  $currentWorkspace = $this->setTemporaryWorkspace($versionRecord['t3ver_wsid']);
71 
72  $cmd[$table][$t3ver_oid]['version'] = array(
73  'action' => 'swap',
74  'swapWith' => $orig_uid,
75  'swapIntoWS' => 1
76  );
77  $this->processTcaCmd($cmd);
78 
79  $this->setTemporaryWorkspace($currentWorkspace);
80  }
81 
90  public function deleteSingleRecord($table, $uid) {
91  $versionRecord = BackendUtility::getRecord($table, $uid);
92  $currentWorkspace = $this->setTemporaryWorkspace($versionRecord['t3ver_wsid']);
93 
94  $cmd[$table][$uid]['version'] = array(
95  'action' => 'clearWSID'
96  );
97  $this->processTcaCmd($cmd);
98 
99  $this->setTemporaryWorkspace($currentWorkspace);
100  }
101 
109  public function viewSingleRecord($table, $uid) {
110  return \TYPO3\CMS\Workspaces\Service\WorkspaceService::viewSingleRecord($table, $uid);
111  }
112 
119  public function executeSelectionAction($parameter) {
120  $result = array();
121 
122  if (empty($parameter->action) || empty($parameter->selection)) {
123  $result['error'] = 'No action or record selection given';
124  return $result;
125  }
126 
127  $commands = array();
128  $swapIntoWorkspace = ($parameter->action === 'swap');
129  if ($parameter->action === 'publish' || $swapIntoWorkspace) {
130  $commands = $this->getPublishSwapCommands($parameter->selection, $swapIntoWorkspace);
131  } elseif ($parameter->action === 'discard') {
132  $commands = $this->getFlushCommands($parameter->selection);
133  }
134 
135  $result = $this->processTcaCmd($commands);
136  $result['total'] = count($commands);
137  return $result;
138  }
139 
147  protected function getPublishSwapCommands(array $selection, $swapIntoWorkspace) {
148  $commands = array();
149  foreach ($selection as $record) {
150  $commands[$record->table][$record->liveId]['version'] = array(
151  'action' => 'swap',
152  'swapWith' => $record->versionId,
153  'swapIntoWS' => (bool)$swapIntoWorkspace,
154  );
155  }
156  return $commands;
157  }
158 
165  protected function getFlushCommands(array $selection) {
166  $commands = array();
167  foreach ($selection as $record) {
168  $commands[$record->table][$record->versionId]['version'] = array(
169  'action' => 'clearWSID',
170  );
171  }
172  return $commands;
173  }
174 
181  public function saveColumnModel($model) {
182  $data = array();
183  foreach ($model as $column) {
184  $data[$column->column] = array(
185  'position' => $column->position,
186  'hidden' => $column->hidden
187  );
188  }
189  $GLOBALS['BE_USER']->uc['moduleData']['Workspaces'][$GLOBALS['BE_USER']->workspace]['columns'] = $data;
190  $GLOBALS['BE_USER']->writeUC();
191  }
192 
193  public function loadColumnModel() {
194  if (is_array($GLOBALS['BE_USER']->uc['moduleData']['Workspaces'][$GLOBALS['BE_USER']->workspace]['columns'])) {
195  return $GLOBALS['BE_USER']->uc['moduleData']['Workspaces'][$GLOBALS['BE_USER']->workspace]['columns'];
196  } else {
197  return array();
198  }
199  }
200 
207  public function saveLanguageSelection($language) {
208  if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($language) === FALSE && $language !== 'all') {
209  $language = 'all';
210  }
211  $GLOBALS['BE_USER']->uc['moduleData']['Workspaces'][$GLOBALS['BE_USER']->workspace]['language'] = $language;
212  $GLOBALS['BE_USER']->writeUC();
213  }
214 
223  public function sendToNextStageWindow($uid, $table, $t3ver_oid) {
224  $elementRecord = BackendUtility::getRecord($table, $uid);
225  $currentWorkspace = $this->setTemporaryWorkspace($elementRecord['t3ver_wsid']);
226 
227  if (is_array($elementRecord)) {
228  $stageId = $elementRecord['t3ver_stage'];
229  if ($this->getStageService()->isValid($stageId)) {
230  $nextStage = $this->getStageService()->getNextStage($stageId);
231  $result = $this->getSentToStageWindow($nextStage['uid']);
232  $result['affects'] = array(
233  'table' => $table,
234  'nextStage' => $nextStage['uid'],
235  't3ver_oid' => $t3ver_oid,
236  'uid' => $uid
237  );
238  } else {
239  $result = $this->getErrorResponse('error.stageId.invalid', 1291111644);
240  }
241  } else {
242  $result = $this->getErrorResponse('error.sendToNextStage.noRecordFound', 1287264776);
243  }
244 
245  $this->setTemporaryWorkspace($currentWorkspace);
246  return $result;
247  }
248 
256  public function sendToPrevStageWindow($uid, $table) {
257  $elementRecord = BackendUtility::getRecord($table, $uid);
258  $currentWorkspace = $this->setTemporaryWorkspace($elementRecord['t3ver_wsid']);
259 
260  if (is_array($elementRecord)) {
261  $stageId = $elementRecord['t3ver_stage'];
262  if ($this->getStageService()->isValid($stageId)) {
263  if ($stageId !== \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_EDIT_ID) {
264  $prevStage = $this->getStageService()->getPrevStage($stageId);
265  $result = $this->getSentToStageWindow($prevStage['uid']);
266  $result['affects'] = array(
267  'table' => $table,
268  'uid' => $uid,
269  'nextStage' => $prevStage['uid']
270  );
271  } else {
272  // element is already in edit stage, there is no prev stage - return an error message
273  $result = $this->getErrorResponse('error.sendToPrevStage.noPreviousStage', 1287264746);
274  }
275  } else {
276  $result = $this->getErrorResponse('error.stageId.invalid', 1291111644);
277  }
278  } else {
279  $result = $this->getErrorResponse('error.sendToNextStage.noRecordFound', 1287264765);
280  }
281 
282  $this->setTemporaryWorkspace($currentWorkspace);
283  return $result;
284  }
285 
292  public function sendToSpecificStageWindow($nextStageId) {
293  $result = $this->getSentToStageWindow($nextStageId);
294  $result['affects'] = array(
295  'nextStage' => $nextStageId
296  );
297  return $result;
298  }
299 
308  public function getRecipientList(array $uidOfRecipients, $additionalRecipients, $stageId) {
309  $finalRecipients = array();
310  if (!$this->getStageService()->isValid($stageId)) {
311  throw new \InvalidArgumentException($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'));
312  } else {
313  $stageId = (int)$stageId;
314  }
315  $recipients = array();
316  foreach ($uidOfRecipients as $userUid) {
317  $beUserRecord = BackendUtility::getRecord('be_users', (int)$userUid);
318  if (is_array($beUserRecord) && $beUserRecord['email'] !== '') {
319  $uc = $beUserRecord['uc'] ? unserialize($beUserRecord['uc']) : array();
320  $recipients[$beUserRecord['email']] = array(
321  'email' => $beUserRecord['email'],
322  'lang' => isset($uc['lang']) ? $uc['lang'] : $beUserRecord['lang']
323  );
324  }
325  }
326  // the notification mode can be configured in the workspace stage record
327  $notification_mode = (int)$this->getStageService()->getNotificationMode($stageId);
328  if ($notification_mode === \TYPO3\CMS\Workspaces\Service\StagesService::MODE_NOTIFY_ALL || $notification_mode === \TYPO3\CMS\Workspaces\Service\StagesService::MODE_NOTIFY_ALL_STRICT) {
329  // get the default recipients from the stage configuration
330  // the default recipients needs to be added in some cases of the notification_mode
331  $default_recipients = $this->getStageService()->getResponsibleBeUser($stageId, TRUE);
332  foreach ($default_recipients as $default_recipient_uid => $default_recipient_record) {
333  if (!isset($recipients[$default_recipient_record['email']])) {
334  $uc = $default_recipient_record['uc'] ? unserialize($default_recipient_record['uc']) : array();
335  $recipients[$default_recipient_record['email']] = array(
336  'email' => $default_recipient_record['email'],
337  'lang' => isset($uc['lang']) ? $uc['lang'] : $default_recipient_record['lang']
338  );
339  }
340  }
341  }
342  if ($additionalRecipients !== '') {
343  $emails = GeneralUtility::trimExplode(LF, $additionalRecipients, TRUE);
344  $additionalRecipients = array();
345  foreach ($emails as $email) {
346  $additionalRecipients[$email] = array('email' => $email);
347  }
348  } else {
349  $additionalRecipients = array();
350  }
351  // We merge $recipients on top of $additionalRecipients because $recipients
352  // possibly is more complete with a user language. Furthermore, the list of
353  // recipients is automatically unique since we indexed $additionalRecipients
354  // and $recipients with the email address
355  $allRecipients = array_merge($additionalRecipients, $recipients);
356  foreach ($allRecipients as $email => $recipientInformation) {
357  if (GeneralUtility::validEmail($email)) {
358  $finalRecipients[] = $recipientInformation;
359  }
360  }
361  return $finalRecipients;
362  }
363 
371  public function discardStagesFromPage($pageId) {
372  $cmdMapArray = array();
374  $workspaceService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
376  $stageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\StagesService');
377  $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($stageService->getWorkspaceId(), ($filter = 1), ($stage = -99), $pageId, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
378  foreach ($workspaceItemsArray as $tableName => $items) {
379  foreach ($items as $item) {
380  $cmdMapArray[$tableName][$item['uid']]['version']['action'] = 'clearWSID';
381  }
382  }
383  $this->processTcaCmd($cmdMapArray);
384  return array(
385  'success' => TRUE
386  );
387  }
388 
404  public function sentCollectionToStage(\stdClass $parameters) {
405  $cmdMapArray = array();
406  $comment = $parameters->comments;
407  $stageId = $parameters->stageId;
408  if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($stageId) === FALSE) {
409  throw new \InvalidArgumentException('Missing "stageId" in $parameters array.', 1319488194);
410  }
411  if (!is_object($parameters->affects) || count($parameters->affects) == 0) {
412  throw new \InvalidArgumentException('Missing "affected items" in $parameters array.', 1319488195);
413  }
414  $recipients = $this->getRecipientList($parameters->receipients, $parameters->additional, $stageId);
415  foreach ($parameters->affects as $tableName => $items) {
416  foreach ($items as $item) {
417  // Publishing uses live id in command map
418  if ($stageId == \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_PUBLISH_EXECUTE_ID) {
419  $cmdMapArray[$tableName][$item->t3ver_oid]['version']['action'] = 'swap';
420  $cmdMapArray[$tableName][$item->t3ver_oid]['version']['swapWith'] = $item->uid;
421  $cmdMapArray[$tableName][$item->t3ver_oid]['version']['comment'] = $comment;
422  $cmdMapArray[$tableName][$item->t3ver_oid]['version']['notificationAlternativeRecipients'] = $recipients;
423  // Setting stage uses version id in command map
424  } else {
425  $cmdMapArray[$tableName][$item->uid]['version']['action'] = 'setStage';
426  $cmdMapArray[$tableName][$item->uid]['version']['stageId'] = $stageId;
427  $cmdMapArray[$tableName][$item->uid]['version']['comment'] = $comment;
428  $cmdMapArray[$tableName][$item->uid]['version']['notificationAlternativeRecipients'] = $recipients;
429  }
430  }
431  }
432  $this->processTcaCmd($cmdMapArray);
433  return array(
434  'success' => TRUE,
435  // force refresh after publishing changes
436  'refreshLivePanel' => $parameters->stageId == -20 ? TRUE : FALSE
437  );
438  }
439 
447  protected function processTcaCmd(array $cmdMapArray) {
448  $result = array();
449 
450  if (empty($cmdMapArray)) {
451  $result['error'] = 'No commands given to be processed';
452  return $result;
453  }
454 
456  $dataHandler = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
457  $dataHandler->start(array(), $cmdMapArray);
458  $dataHandler->process_cmdmap();
459 
460  if ($dataHandler->errorLog) {
461  $result['error'] = implode('<br/>', $dataHandler->errorLog);
462  }
463 
464  return $result;
465  }
466 
482  public function sendToNextStageExecute(\stdClass $parameters) {
483  $cmdArray = array();
484  $setStageId = $parameters->affects->nextStage;
485  $comments = $parameters->comments;
486  $table = $parameters->affects->table;
487  $uid = $parameters->affects->uid;
488  $t3ver_oid = $parameters->affects->t3ver_oid;
489 
490  $elementRecord = BackendUtility::getRecord($table, $uid);
491  $currentWorkspace = $this->setTemporaryWorkspace($elementRecord['t3ver_wsid']);
492 
493  $recipients = $this->getRecipientList($parameters->receipients, $parameters->additional, $setStageId);
494  if ($setStageId == \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_PUBLISH_EXECUTE_ID) {
495  $cmdArray[$table][$t3ver_oid]['version']['action'] = 'swap';
496  $cmdArray[$table][$t3ver_oid]['version']['swapWith'] = $uid;
497  $cmdArray[$table][$t3ver_oid]['version']['comment'] = $comments;
498  $cmdArray[$table][$t3ver_oid]['version']['notificationAlternativeRecipients'] = $recipients;
499  } else {
500  $cmdArray[$table][$uid]['version']['action'] = 'setStage';
501  $cmdArray[$table][$uid]['version']['stageId'] = $setStageId;
502  $cmdArray[$table][$uid]['version']['comment'] = $comments;
503  $cmdArray[$table][$uid]['version']['notificationAlternativeRecipients'] = $recipients;
504  }
505  $this->processTcaCmd($cmdArray);
506  $result = array(
507  'success' => TRUE
508  );
509 
510  $this->setTemporaryWorkspace($currentWorkspace);
511  return $result;
512  }
513 
528  public function sendToPrevStageExecute(\stdClass $parameters) {
529  $cmdArray = array();
530  $setStageId = $parameters->affects->nextStage;
531  $comments = $parameters->comments;
532  $table = $parameters->affects->table;
533  $uid = $parameters->affects->uid;
534 
535  $elementRecord = BackendUtility::getRecord($table, $uid);
536  $currentWorkspace = $this->setTemporaryWorkspace($elementRecord['t3ver_wsid']);
537 
538  $recipients = $this->getRecipientList($parameters->receipients, $parameters->additional, $setStageId);
539  $cmdArray[$table][$uid]['version']['action'] = 'setStage';
540  $cmdArray[$table][$uid]['version']['stageId'] = $setStageId;
541  $cmdArray[$table][$uid]['version']['comment'] = $comments;
542  $cmdArray[$table][$uid]['version']['notificationAlternativeRecipients'] = $recipients;
543  $this->processTcaCmd($cmdArray);
544  $result = array(
545  'success' => TRUE
546  );
547 
548  $this->setTemporaryWorkspace($currentWorkspace);
549  return $result;
550  }
551 
573  public function sendToSpecificStageExecute(\stdClass $parameters) {
574  $cmdArray = array();
575  $setStageId = $parameters->affects->nextStage;
576  $comments = $parameters->comments;
577  $elements = $parameters->affects->elements;
578  $recipients = $this->getRecipientList($parameters->receipients, $parameters->additional, $setStageId);
579  foreach ($elements as $element) {
580  // Avoid any action on records that have already been published to live
581  $elementRecord = BackendUtility::getRecord($element->table, $element->uid);
582  if ((int)$elementRecord['t3ver_wsid'] === 0) {
583  continue;
584  }
585 
586  if ($setStageId == \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_PUBLISH_EXECUTE_ID) {
587  $cmdArray[$element->table][$element->t3ver_oid]['version']['action'] = 'swap';
588  $cmdArray[$element->table][$element->t3ver_oid]['version']['swapWith'] = $element->uid;
589  $cmdArray[$element->table][$element->t3ver_oid]['version']['comment'] = $comments;
590  $cmdArray[$element->table][$element->t3ver_oid]['version']['notificationAlternativeRecipients'] = $recipients;
591  } else {
592  $cmdArray[$element->table][$element->uid]['version']['action'] = 'setStage';
593  $cmdArray[$element->table][$element->uid]['version']['stageId'] = $setStageId;
594  $cmdArray[$element->table][$element->uid]['version']['comment'] = $comments;
595  $cmdArray[$element->table][$element->uid]['version']['notificationAlternativeRecipients'] = $recipients;
596  }
597  }
598  $this->processTcaCmd($cmdArray);
599  $result = array(
600  'success' => TRUE
601  );
602  return $result;
603  }
604 
611  protected function getSentToStageWindow($nextStageId) {
612  $workspaceRec = BackendUtility::getRecord('sys_workspace', $this->getStageService()->getWorkspaceId());
613  $showNotificationFields = FALSE;
614  $stageTitle = $this->getStageService()->getStageTitle($nextStageId);
615  $result = array(
616  'title' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:actionSendToStage'),
617  'items' => array(
618  array(
619  'xtype' => 'panel',
620  'bodyStyle' => 'margin-bottom: 7px; border: none;',
621  'html' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.itemsWillBeSentTo') . ' ' . $stageTitle
622  )
623  )
624  );
625  switch ($nextStageId) {
626  case \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_PUBLISH_EXECUTE_ID:
627 
628  case \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_PUBLISH_ID:
629  if (!empty($workspaceRec['publish_allow_notificaton_settings'])) {
630  $showNotificationFields = TRUE;
631  }
632  break;
633  case \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_EDIT_ID:
634  if (!empty($workspaceRec['edit_allow_notificaton_settings'])) {
635  $showNotificationFields = TRUE;
636  }
637  break;
638  default:
639  $allow_notificaton_settings = $this->getStageService()->getPropertyOfCurrentWorkspaceStage($nextStageId, 'allow_notificaton_settings');
640  if (!empty($allow_notificaton_settings)) {
641  $showNotificationFields = TRUE;
642  }
643  }
644  if ($showNotificationFields == TRUE) {
645  $result['items'][] = array(
646  'fieldLabel' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.sendMailTo'),
647  'xtype' => 'checkboxgroup',
648  'itemCls' => 'x-check-group-alt',
649  'columns' => 1,
650  'style' => 'max-height: 200px',
651  'autoScroll' => TRUE,
652  'items' => array(
653  $this->getReceipientsOfStage($nextStageId)
654  )
655  );
656  $result['items'][] = array(
657  'fieldLabel' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.additionalRecipients'),
658  'name' => 'additional',
659  'xtype' => 'textarea',
660  'width' => 250
661  );
662  }
663  $result['items'][] = array(
664  'fieldLabel' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:window.sendToNextStageWindow.comments'),
665  'name' => 'comments',
666  'xtype' => 'textarea',
667  'width' => 250,
668  'value' => $this->getDefaultCommentOfStage($nextStageId)
669  );
670  return $result;
671  }
672 
679  protected function getReceipientsOfStage($stage) {
680  $result = array();
681  $recipients = $this->getStageService()->getResponsibleBeUser($stage);
682  $default_recipients = $this->getStageService()->getResponsibleBeUser($stage, TRUE);
683  foreach ($recipients as $id => $user) {
684  if (GeneralUtility::validEmail($user['email'])) {
685  $checked = FALSE;
686  $disabled = FALSE;
687  $name = $user['realName'] ? $user['realName'] : $user['username'];
688  // the notification mode can be configured in the workspace stage record
689  $notification_mode = (int)$this->getStageService()->getNotificationMode($stage);
690  if ($notification_mode === \TYPO3\CMS\Workspaces\Service\StagesService::MODE_NOTIFY_SOMEONE) {
691  // all responsible users are checked per default, as in versions before
692  $checked = TRUE;
693  } elseif ($notification_mode === \TYPO3\CMS\Workspaces\Service\StagesService::MODE_NOTIFY_ALL) {
694  // the default users are checked only
695  if (!empty($default_recipients[$id])) {
696  $checked = TRUE;
697  $disabled = TRUE;
698  } else {
699  $checked = FALSE;
700  }
701  } elseif ($notification_mode === \TYPO3\CMS\Workspaces\Service\StagesService::MODE_NOTIFY_ALL_STRICT) {
702  // all responsible users are checked
703  $checked = TRUE;
704  $disabled = TRUE;
705  }
706  $result[] = array(
707  'boxLabel' => sprintf('%s (%s)', $name, $user['email']),
708  'name' => 'receipients-' . $id,
709  'checked' => $checked,
710  'disabled' => $disabled
711  );
712  }
713  }
714  return $result;
715  }
716 
723  protected function getDefaultCommentOfStage($stage) {
724  $result = $this->getStageService()->getPropertyOfCurrentWorkspaceStage($stage, 'default_mailcomment');
725  return $result;
726  }
727 
733  protected function getStageService() {
734  if (!isset($this->stageService)) {
735  $this->stageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\StagesService');
736  }
737  return $this->stageService;
738  }
739 
747  public function sendPageToPreviousStage($id) {
748  $workspaceService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
749  $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), ($filter = 1), ($stage = -99), $id, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
750  list($currentStage, $previousStage) = $this->getStageService()->getPreviousStageForElementCollection($workspaceItemsArray);
751  // get only the relevant items for processing
752  $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), ($filter = 1), $currentStage['uid'], $id, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
753  return array(
754  'title' => 'Status message: Page send to next stage - ID: ' . $id . ' - Next stage title: ' . $previousStage['title'],
755  'items' => $this->getSentToStageWindow($previousStage['uid']),
756  'affects' => $workspaceItemsArray,
757  'stageId' => $previousStage['uid']
758  );
759  }
760 
766  public function sendPageToNextStage($id) {
767  $workspaceService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
768  $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), ($filter = 1), ($stage = -99), $id, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
769  list($currentStage, $nextStage) = $this->getStageService()->getNextStageForElementCollection($workspaceItemsArray);
770  // get only the relevant items for processing
771  $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), ($filter = 1), $currentStage['uid'], $id, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
772  return array(
773  'title' => 'Status message: Page send to next stage - ID: ' . $id . ' - Next stage title: ' . $nextStage['title'],
774  'items' => $this->getSentToStageWindow($nextStage['uid']),
775  'affects' => $workspaceItemsArray,
776  'stageId' => $nextStage['uid']
777  );
778  }
779 
787  public function updateStageChangeButtons($id) {
788  $stageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\StagesService');
789  $workspaceService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService');
790  // fetch the next and previous stage
791  $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($stageService->getWorkspaceId(), ($filter = 1), ($stage = -99), $id, ($recursionLevel = 0), ($selectionType = 'tables_modify'));
792  list(, $nextStage) = $stageService->getNextStageForElementCollection($workspaceItemsArray);
793  list(, $previousStage) = $stageService->getPreviousStageForElementCollection($workspaceItemsArray);
794  $toolbarButtons = array(
795  'feToolbarButtonNextStage' => array(
796  'visible' => is_array($nextStage) && count($nextStage) > 0,
797  'text' => $nextStage['title']
798  ),
799  'feToolbarButtonPreviousStage' => array(
800  'visible' => is_array($previousStage) && count($previousStage),
801  'text' => $previousStage['title']
802  ),
803  'feToolbarButtonDiscardStage' => array(
804  'visible' => is_array($nextStage) && count($nextStage) > 0 || is_array($previousStage) && count($previousStage) > 0,
805  'text' => $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:label_doaction_discard', TRUE)
806  )
807  );
808  return $toolbarButtons;
809  }
810 
816  protected function setTemporaryWorkspace($workspaceId) {
817  $workspaceId = (int)$workspaceId;
818  $currentWorkspace = (int)$this->getBackendUser()->workspace;
819 
820  if ($currentWorkspace !== $workspaceId) {
821  if (!$this->getBackendUser()->setTemporaryWorkspace($workspaceId)) {
822  throw new \TYPO3\CMS\Core\Exception(
823  'Cannot set temporary workspace to "' . $workspaceId . '"',
824  1371484524
825  );
826  }
827  }
828 
829  return $currentWorkspace;
830  }
831 
835  protected function getBackendUser() {
836  return $GLOBALS['BE_USER'];
837  }
838 
839 }
sendToNextStageWindow($uid, $table, $t3ver_oid)
$parameters
Definition: FileDumpEID.php:15
$uid
Definition: server.php:36
getErrorResponse($errorLabel, $errorCode=0, $successFlagValue=FALSE)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
getRecipientList(array $uidOfRecipients, $additionalRecipients, $stageId)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
getPublishSwapCommands(array $selection, $swapIntoWorkspace)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
swapSingleRecord($table, $t3ver_oid, $orig_uid)