47 private $pathToLocallang =
'LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf';
95 array $byTableName = [
'tt_content',
'pages']
103 $byTableName = array_flip($byTableName);
104 foreach ($workspaceItems as $tableName => $items) {
105 if (!array_key_exists($tableName, $byTableName)) {
108 foreach ($items as $item) {
109 $usedStages[$item[
't3ver_stage']] =
true;
112 foreach ($availableStagesForWS as $stage) {
113 if (isset($usedStages[$stage[
'uid']])) {
114 $currentStage = $stage;
119 foreach ($availableStagesForWSUser as $userWS) {
120 if ($previousStage[
'uid'] == $userWS[
'uid']) {
143 array $byTableName = [
'tt_content',
'pages']
150 $byTableName = array_flip($byTableName);
152 foreach ($workspaceItems as $tableName => $items) {
153 if (!array_key_exists($tableName, $byTableName)) {
156 foreach ($items as $item) {
157 $usedStages[$item[
't3ver_stage']] =
true;
160 foreach ($availableStagesForWS as $stage) {
161 if (isset($usedStages[$stage[
'uid']])) {
162 $currentStage = $stage;
167 foreach ($availableStagesForWSUser as $userWS) {
168 if ($nextStage[
'uid'] == $userWS[
'uid']) {
216 foreach ($stageRecords as $stageRecord) {
217 if ($stageRecord->isAllowed()) {
218 $allowedStages[$stageRecord->getUid()] = $stageRecord;
223 foreach ($allowedStages as $allowedStage) {
225 $nextStage = $allowedStage->
getNext();
226 if ($previousStage !==
null && !isset($allowedStages[$previousStage->getUid()])) {
227 $allowedStages[$previousStage->getUid()] = $previousStage;
229 if ($nextStage !==
null && !isset($allowedStages[$nextStage->getUid()])) {
230 $allowedStages[$nextStage->getUid()] = $nextStage;
249 foreach ($stageRecords as $stageRecord) {
251 'uid' => $stageRecord->getUid(),
252 'label' => $stageRecord->getTitle(),
254 if (!$stageRecord->isExecuteStage()) {
255 $stage[
'title'] =
$GLOBALS[
'LANG']->sL($this->pathToLocallang .
':actionSendToStage') .
' "' . $stageRecord->getTitle() .
'"';
257 $stage[
'title'] =
$GLOBALS[
'LANG']->sL($this->pathToLocallang .
':publish_execute_action_option');
259 $stagesArray[] = $stage;
272 switch ($ver_stage) {
274 $stageTitle =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_publish');
277 $stageTitle =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:workspaces/Resources/Private/Language/locallang_mod.xlf:stage_ready_to_publish');
280 $stageTitle =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_editing');
284 if ($stageTitle ==
null) {
285 $stageTitle =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.getStageTitle.stageNotFound');
312 throw new \InvalidArgumentException(
313 $GLOBALS[
'LANG']->sL(
'LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'),
319 if (is_array($workspaceStageRecs) && !empty($workspaceStageRecs)) {
320 reset($workspaceStageRecs);
321 while (key($workspaceStageRecs) !==
null) {
322 $workspaceStageRec = current($workspaceStageRecs);
323 if ($workspaceStageRec[
'uid'] == $stageId) {
324 $nextStage = next($workspaceStageRecs);
327 next($workspaceStageRecs);
330 if ($nextStage ===
false) {
333 'title' =>
$GLOBALS[
'LANG']->sL($this->pathToLocallang .
':actionSendToStage') .
' "'
334 .
$GLOBALS[
'LANG']->sL(
'LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_editing') .
'"'
350 if ($stageId == self::STAGE_PUBLISH_ID) {
351 return $nextStageArray;
354 if (empty($nextStageRecord) || !is_array($nextStageRecord)) {
356 return $nextStageArray;
362 $nextStageArray[] = $nextStageRecord;
363 return $this->
getNextStages($nextStageArray, $nextStageRecord[
'uid']);
366 return $nextStageArray;
379 throw new \InvalidArgumentException(
380 $GLOBALS[
'LANG']->sL(
'LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'),
386 if (is_array($workspaceStageRecs) && !empty($workspaceStageRecs)) {
387 end($workspaceStageRecs);
388 while (key($workspaceStageRecs) !==
null) {
389 $workspaceStageRec = current($workspaceStageRecs);
390 if ($workspaceStageRec[
'uid'] == $stageId) {
391 $prevStage = prev($workspaceStageRecs);
394 prev($workspaceStageRecs);
411 if ($stageId != self::STAGE_EDIT_ID) {
413 if (!empty($prevStageRecord) && is_array($prevStageRecord)) {
418 $prevStageArray[] = $prevStageRecord;
419 $prevStageArray = $this->
getPrevStages($prevStageArray, $prevStageRecord[
'uid']);
423 return $prevStageArray;
436 if (!$stageRecord instanceof StageRecord) {
440 $recipientArray = [];
442 if (!$selectDefaultUserField) {
445 $backendUserIds = $stageRecord->getDefaultRecipients();
448 $userList = implode(
',', $backendUserIds);
450 foreach ($userRecords as $userUid => $userRecord) {
451 $recipientArray[$userUid] = $userRecord;
453 return $recipientArray;
478 $elements = GeneralUtility::trimExplode(
',', $backendUserGroupList,
true);
479 $backendUserIds = [];
480 $backendGroupIds = [];
482 foreach ($elements as $element) {
483 if (strpos($element,
'be_users_') === 0) {
485 $backendUserIds[] = str_replace(
'be_users_',
'', $element);
486 } elseif (strpos($element,
'be_groups_') === 0) {
487 $backendGroupIds[] = str_replace(
'be_groups_',
'', $element);
488 } elseif ((
int)$element) {
489 $backendUserIds[] = (int)$element;
493 if (!empty($backendGroupIds)) {
495 $backendGroupList = implode(
',', $backendGroupIds);
496 $this->userGroups = [];
497 $backendGroups = $this->
fetchGroups($backendGroupList);
498 foreach ($backendGroups as $backendGroup) {
499 foreach ($allBeUserArray as $backendUserId => $backendUser) {
500 if (GeneralUtility::inList($backendUser[
'usergroup_cached_list'], $backendGroup[
'uid'])) {
501 $backendUserIds[] = $backendUserId;
507 return array_unique($backendUserIds);
518 if (empty($backendUserList)) {
522 $backendUserList = implode(
',', GeneralUtility::intExplode(
',', $backendUserList));
524 'username, uid, email, realName, lang, uc',
528 if (empty($backendUsers)) {
531 return $backendUsers;
543 $this->getRecordService()->getCreateUserIds()
564 $cacheKey = md5($grList . $idList);
565 if (isset($this->fetchGroupsCache[$cacheKey])) {
566 return $this->fetchGroupsCache[$cacheKey];
568 if ($idList ===
'') {
570 $this->userGroups = [];
573 $this->fetchGroupsCache[$cacheKey] = $groupList;
583 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'be_groups');
585 $result = $queryBuilder
589 $queryBuilder->expr()->in(
591 $queryBuilder->createNamedParameter($groups, Connection::PARAM_INT_ARRAY)
596 while ($row = $result->fetch()) {
597 $this->userGroups[$row[
'uid']] = $row;
610 $requiredGroups = GeneralUtility::intExplode(
',', $grList,
true);
611 $existingGroups = array_keys($this->userGroups);
612 $missingGroups = array_diff($requiredGroups, $existingGroups);
613 if (!empty($missingGroups)) {
617 foreach ($requiredGroups as $uid) {
620 $row = $this->userGroups[$uid];
621 if (is_array($row) && !GeneralUtility::inList($idList, $uid)) {
624 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'customStageShowRecipientRecursive'] == 1) {
626 if (trim($row[
'subgroup'])) {
628 $theList = implode(
',', GeneralUtility::intExplode(
',', $row[
'subgroup']));
630 $subGroups = $this->
fetchGroups($theList, $idList .
',' . $uid);
632 $subUid = key($subGroups);
633 $this->userGroups[$subUid] = $subGroups[$subUid];
653 throw new \InvalidArgumentException(
654 $GLOBALS[
'LANG']->sL(
'LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.stageId.integer'),
659 if (is_array($workspaceStage) && isset($workspaceStage[$property])) {
660 $result = $workspaceStage[$property];
675 $countOfStages = count($stagesOfWS);
678 $position = $countOfStages;
685 foreach ($stagesOfWS as $key => $stageInfoArray) {
687 if ($stageId == $stageInfoArray[
'uid']) {
692 return [
'position' => $position,
'count' => $countOfStages];
708 if (!empty($prevStage) && $prevStage[
'uid'] != $stageId) {
712 }
catch (\Exception $e) {
730 if (!empty($nextStage) && $nextStage[
'uid'] != $stageId) {
734 }
catch (\Exception $e) {
746 if (isset($this->workspaceStageAllowedCache[$cacheKey])) {
747 return $this->workspaceStageAllowedCache[$cacheKey];
750 $this->workspaceStageAllowedCache[$cacheKey] = $isAllowed;
764 foreach ($stages as $stage) {
765 if ($stage[
'uid'] == $stageId) {
778 if (!isset($this->recordService)) {
779 $this->recordService = GeneralUtility::makeInstance(RecordService::class);