Index: Resources/Public/JavaScript/grid.js =================================================================== --- Resources/Public/JavaScript/grid.js (Revision 3879) +++ Resources/Public/JavaScript/grid.js (Arbeitskopie) @@ -70,6 +70,13 @@ singleSelect: false, hidden: true, listeners: { + beforerowselect : function (selection, rowIndex, keep, rec) { + if (rec.json.allowedAction_nextStage || rec.json.allowedAction_prevStage) { + return true; + } else { + return false; + } + }, selectionchange: function (selection) { var record = selection.grid.getSelectionModel().getSelections(); if (record.length > 0) { @@ -130,4 +137,4 @@ }), bbar : TYPO3.Workspaces.Toolbar.FullBottomBar, tbar : TYPO3.Workspaces.Toolbar.FullTopToolbar -}); +}); \ No newline at end of file Index: Resources/Public/JavaScript/component.js =================================================================== --- Resources/Public/JavaScript/component.js (Revision 3879) +++ Resources/Public/JavaScript/component.js (Arbeitskopie) @@ -168,6 +168,18 @@ TYPO3.Workspaces.RowExpander = new Ext.grid.RowExpander({ menuDisabled: true, hideable: false, + getRowClass : function(record, rowIndex, p, ds) { + class = ''; + if (!record.json.allowedAction_nextStage && !record.json.allowedAction_prevStage) { + class = 'typo3-workspaces-row-disabled '; + } + if(this.state[record.id]) { + class += 'x-grid3-row-expanded'; + } else { + class += 'x-grid3-row-collapsed'; + } + return class; + }, remoteDataMethod : function (record, index) { TYPO3.Workspaces.RowDetail.rowDataStore.baseParams = { uid: record.json.uid, @@ -278,4 +290,4 @@ }, scope : this } -}); +}); \ No newline at end of file Index: Resources/Public/StyleSheet/module.css =================================================================== --- Resources/Public/StyleSheet/module.css (Revision 3879) +++ Resources/Public/StyleSheet/module.css (Arbeitskopie) @@ -187,4 +187,8 @@ div .t3-workspaces-comments-singleComment-content-title { padding: 8px 0 8px 0; font-weight: bold; +} + +.typo3-workspaces-row-disabled .x-grid3-td-checker { + visibility: hidden; } \ No newline at end of file Index: Classes/Service/Stages.php =================================================================== --- Classes/Service/Stages.php (Revision 3879) +++ Classes/Service/Stages.php (Arbeitskopie) @@ -157,29 +157,39 @@ */ public function getStagesForWSUser() { - // initiate return array of stages with edit stage $stagesForWSUserData = array(); + $allowedStages = array(); + $orderedAllowedStages = array(); - // get all stages for the current workspace $workspaceStageRecs = $this->getStagesForWS(); if (is_array($workspaceStageRecs) && !empty($workspaceStageRecs)) { - // go through custom stages records - foreach ($workspaceStageRecs as $workspaceStageRec) { - // check if the user has permissions to the custom stage - if ($GLOBALS['BE_USER']->workspaceCheckStageForCurrent($workspaceStageRec['uid'])) { - // yes, so add to return array - $stagesForWSUserData[] = array( - 'uid' => $workspaceStageRec['uid'], - 'title' => $workspaceStageRec['title'] - ); - } else if ($workspaceStageRec['uid'] == self::STAGE_PUBLISH_EXECUTE_ID) { - if ($GLOBALS['BE_USER']->workspacePublishAccess($this->getWorkspaceId())) { - $stagesForWSUserData[] = $workspaceStageRec; - } + if ($GLOBALS['BE_USER']->isAdmin()) { + $orderedAllowedStages = $workspaceStageRecs; + } else { + foreach ($workspaceStageRecs as $workspaceStageRec) { + if ($this->isStageAllowedForUser($workspaceStageRec['uid'])) { + $stagesForWSUserData[$workspaceStageRec['uid']] = $workspaceStageRec; + } else if ($workspaceStageRec['uid'] == self::STAGE_PUBLISH_EXECUTE_ID && $GLOBALS['BE_USER']->workspacePublishAccess($this->getWorkspaceId())) { + $allowedStages[] = $workspaceStageRec; + $stagesForWSUserData[$workspaceStageRec['uid']] = $workspaceStageRec; + } } + + foreach ($stagesForWSUserData as $allowedStage) { + $nextStage = $this->getNextStage($allowedStage['uid']); + $prevStage = $this->getPrevStage($allowedStage['uid']); + if (isset($nextStage['uid'])) { + $allowedStages[$nextStage['uid']] = $nextStage; + } + if (isset($prevStage['uid'])) { + $allowedStages[$prevStage['uid']] = $prevStage; + } + } + + $orderedAllowedStages = array_values($allowedStages); } } - return $stagesForWSUserData; + return $orderedAllowedStages; } /** @@ -591,7 +601,8 @@ // if there's no prev-stage the stageIds match, // otherwise we've to check if the user is permitted to use the stage if (!empty($prevStage) && $prevStage['uid'] != $stageId) { - $isAllowed = $this->isStageAllowedForUser($prevStage['uid']); + // if the current stage is allowed for the user, the user is also allowed to send to prev + $isAllowed = $this->isStageAllowedForUser($stageId); } } catch (Exception $e) { // Exception raised - we're not allowed to go this way @@ -613,7 +624,8 @@ // if there's no next-stage the stageIds match, // otherwise we've to check if the user is permitted to use the stage if (!empty($nextStage) && $nextStage['uid'] != $stageId) { - $isAllowed = $this->isStageAllowedForUser($nextStage['uid']); + // if the current stage is allowed for the user, the user is also allowed to send to next + $isAllowed = $this->isStageAllowedForUser($stageId); } } catch (Exception $e) { // Exception raised - we're not allowed to go this way @@ -630,10 +642,10 @@ $cacheKey = $this->getWorkspaceId() . '_' . $stageId; $isAllowed = FALSE; if (isset($this->workspaceStageAllowedCache[$cacheKey])) { - $isAllowed = $this->workspaceStageAllowedCache[$cacheKey]; + $isAllowed = $this->workspaceStageAllowedCache[$cacheKey]; } else { - $isAllowed = $GLOBALS['BE_USER']->workspaceCheckStageForCurrent($stageId); - $this->workspaceStageAllowedCache[$cacheKey] = $isAllowed; + $isAllowed = $GLOBALS['BE_USER']->workspaceCheckStageForCurrent($stageId); + $this->workspaceStageAllowedCache[$cacheKey] = $isAllowed; } return $isAllowed; }