### Eclipse Workspace Patch 1.0 #P igeworkspace42 Index: typo3/mod/user/ws/class.wsstagelib.php =================================================================== --- typo3/mod/user/ws/class.wsstagelib.php (revision 323) +++ typo3/mod/user/ws/class.wsstagelib.php (working copy) @@ -144,6 +144,39 @@ } /** + * Recursive function to get all next stages for a record depending on user permissions + * + * @param array next stages + * @param int workspace id + * @param int stage id + * @param int current stage id of the record + * @return array next stages + */ + function getNextStages(&$nextStageArray, $workspaceId, $stageId) { + // Current stage is "Ready to publish" - there is no next stage + if($stageId == '10') { + return $nextStageArray; + } else { + $nextStageRecord = $this->getNextStage($workspaceId,$stageId); + if(empty($nextStageRecord) || !is_array($nextStageRecord)) { + // There is no next stage + return $nextStageArray; + } else { + // Check if the user has the permission to for the current stage + // If this next stage record is the first next stage after the current the user has always the needed permission + //if($GLOBALS['BE_USER']->workspaceCheckStageForCurrent($nextStageRecord['uid']) || $stageId == $currentStageId) { + if($GLOBALS['BE_USER']->workspaceCheckStageForCurrent($stageId)) { + $nextStageArray[] = $nextStageRecord; + return $this->getNextStages($nextStageArray, $workspaceId, $nextStageRecord['uid']); + } else { + // He hasn't - return given next stage array + return $nextStageArray; + } + } + } + } + + /** * Get next stage in process for given stage id * * @param int workspace id @@ -186,6 +219,38 @@ } /** + * Recursive function to get all prev stages for a record depending on user permissions + * + * @param array prev stages + * @param int workspace id + * @param int stage id + * @param int current stage id of the record + * @return array prev stages + */ + function getPrevStages(&$prevStageArray, $workspaceId, $stageId) { + // Current stage is "Editing" - there is no prev stage + if($stageId == '0') { + return $prevStageArray; + } else { + $prevStageRecord = $this->getPrevStage($workspaceId,$stageId); + if(empty($prevStageRecord) || !is_array($prevStageRecord)) { + // There is no prev stage + return $prevStageArray; + } else { + // Check if the user has the permission to switch to that stage + // If this prev stage record is the first previous stage before the current the user has always the needed permission + if($GLOBALS['BE_USER']->workspaceCheckStageForCurrent($stageId)) { + $prevStageArray[] = $prevStageRecord; + return $this->getPrevStages($prevStageArray, $workspaceId, $prevStageRecord['uid']); + } else { + // He hasn't - return given prev stage array + return $prevStageArray; + } + } + } + } + + /** * Get uids of all responsilbe persons for a stage * * @param string responsible_persion value from stage record Index: typo3/mod/user/ws/class.wslib_gui.php =================================================================== --- typo3/mod/user/ws/class.wslib_gui.php (revision 287) +++ typo3/mod/user/ws/class.wslib_gui.php (working copy) @@ -1264,7 +1264,7 @@ function displayWorkspaceOverview_stageCmd($table,&$rec_off) { global $LANG; - $this->workspaceId = (!is_null($wsid) ? $wsid : $GLOBALS['BE_USER']->workspace); + $this->workspaceId = (!is_null($this->workspaceId) ? $this->workspaceId : $GLOBALS['BE_USER']->workspace); // Initialize workspace stage object $wsstagelibObj = t3lib_div::makeInstance('wsstagelib');