Index: Classes/Service/GridData.php =================================================================== --- Classes/Service/GridData.php (revision 3882) +++ Classes/Service/GridData.php (working copy) @@ -53,7 +53,7 @@ $limit = isset($parameter->limit) ? intval($parameter->limit) : 10; $this->sort = isset($parameter->sort) ? $parameter->sort : 't3ver_oid'; $this->sortDir = isset($parameter->dir) ? $parameter->dir : 'ASC'; - + if (is_int($currentWorkspace)) { $this->currentWorkspace = $currentWorkspace; } else { @@ -81,25 +81,30 @@ protected function generateDataArray(array $versions, $filterTxt) { /** @var $stagesObj Tx_Workspaces_Service_Stages */ $stagesObj = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages'); - + /** @var $workspacesObj Tx_Workspaces_Service_Workspaces */ $workspacesObj = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces'); $availableWorkspaces = $workspacesObj->getAvailableWorkspaces(); + $workspaceAccess = $GLOBALS['BE_USER']->checkWorkspace($GLOBALS['BE_USER']->workspace); + $swapStage = ($workspaceAccess['publish_access'] & 1) ? Tx_Workspaces_Service_Stages::STAGE_PUBLISH_ID : 0; + $swapAccess = $GLOBALS['BE_USER']->workspacePublishAccess($GLOBALS['BE_USER']->workspace) && + $GLOBALS['BE_USER']->workspaceSwapAccess(); + $this->initializeWorkspacesCachingFramework(); // check for dataArray in cache if ($this->getDataArrayFromCache($versions, $filterTxt) == FALSE) { $stagesObj = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages'); - + foreach ($versions as $table => $records) { $versionArray = array('table' => $table); - + foreach ($records as $record) { - + $origRecord = t3lib_BEFunc::getRecord($table, $record['t3ver_oid']); $versionRecord = t3lib_BEFunc::getRecord($table, $record['uid']); - + if (isset($GLOBALS['TCA'][$table]['columns']['hidden'])) { $recordState = $this->workspaceState($versionRecord['t3ver_state'], $origRecord['hidden'], $versionRecord['hidden']); } else { @@ -128,8 +133,14 @@ $versionArray['allowedAction_nextStage'] = $stagesObj->isNextStageAllowedForUser($versionRecord['t3ver_stage']); $versionArray['allowedAction_prevStage'] = $stagesObj->isPrevStageAllowedForUser($versionRecord['t3ver_stage']); - // @todo hide the actions if the user is not allowed to edit the current stage - $versionArray['allowedAction_swap'] = $GLOBALS['BE_USER']->workspaceSwapAccess(); + + if ($swapAccess && $swapStage != 0 && $versionRecord['t3ver_stage'] == $swapStage) { + $versionArray['allowedAction_swap'] = $stagesObj->isNextStageAllowedForUser($swapStage); + } else if ($swapAccess && $swapStage == 0) { + $versionArray['allowedAction_swap'] = TRUE; + } else { + $versionArray['allowedAction_swap'] = FALSE; + } $versionArray['allowedAction_delete'] = TRUE; // preview and editing of a deleted page won't work ;) $versionArray['allowedAction_view'] = !$isDeletedPage; @@ -144,7 +155,7 @@ } } $this->sortDataArray(); - + $this->setDataArrayIntoCache($versions, $filterTxt); } $this->sortDataArray(); @@ -171,7 +182,7 @@ /** * Initialize the workspace cache - * + * * @return void */ protected function initializeWorkspacesCachingFramework() { @@ -185,7 +196,7 @@ } catch (t3lib_cache_exception_DuplicateIdentifier $e) { // do nothing, a workspace cache already exists } - + $this->workspacesCache = $GLOBALS['typo3CacheManager']->getCache('workspaces_cache'); } } @@ -193,7 +204,7 @@ /** * Put the generated dataArray into the workspace cache. - * + * * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid, t3ver_oid and t3ver_swapmode fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid" * @param string $filterTxt The given filter text from the grid. */ @@ -201,38 +212,38 @@ if (TYPO3_UseCachingFramework === TRUE) { $hash = $this->calculateHash($versions, $filterTxt); $content = serialize($this->dataArray); - + $this->workspacesCache->set($hash, $content, array($this->currentWorkspace)); } } - - + + /** * Checks if a cache entry is given for given versions and filter text and tries to load the data array from cache. - * + * * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid, t3ver_oid and t3ver_swapmode fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid" * @param string $filterTxt The given filter text from the grid. */ protected function getDataArrayFromCache (array $versions, $filterTxt) { $cacheEntry = FALSE; - + if (TYPO3_UseCachingFramework === TRUE) { $hash = $this->calculateHash($versions, $filterTxt); - + $content = $this->workspacesCache->get($hash); - + if ($content != FALSE) { $this->dataArray = unserialize($content); $cacheEntry = TRUE; } } - + return $cacheEntry; } - + /** * Calculate the hash value of the used workspace, the user id, the versions array, the filter text, the sorting attribute, the workspace selected in grid and the sorting direction. - * + * * @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid, t3ver_oid and t3ver_swapmode fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid" * @param string $filterTxt The given filter text from the grid. */ @@ -246,7 +257,7 @@ $this->sortDir, $this->currentWorkspace); $hash = md5(serialize($hashArray)); - + return $hash; }