Fixed bug #12307: Workspaces non-admin user cannot send to next stage
authorpsychomieze <psychomieze@743128fe-103e-dd11-99c4-001b210b3e58>
Wed, 19 Jan 2011 22:50:10 +0000 (22:50 +0000)
committerpsychomieze <psychomieze@743128fe-103e-dd11-99c4-001b210b3e58>
Wed, 19 Jan 2011 22:50:10 +0000 (22:50 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/CoreProjects/workspaces/workspaces/trunk@3887 743128fe-103e-dd11-99c4-001b210b3e58

typo3/sysext/workspaces/ChangeLog
typo3/sysext/workspaces/Classes/Service/Stages.php
typo3/sysext/workspaces/Resources/Public/JavaScript/component.js
typo3/sysext/workspaces/Resources/Public/JavaScript/grid.js
typo3/sysext/workspaces/Resources/Public/StyleSheet/module.css

index 837703f..8535bbe 100644 (file)
@@ -1,6 +1,7 @@
 2011-01-18  Susanne Moog <typo3@susanne-moog.de>
 
        * Fixed bug #11972: Switching workspaces with tabs causes module menu to loose its selection
+       * Fixed bug #12307: Workspaces non-admin user cannot send to next stage
 
 2011-01-18  Sonja Scholz <ss@cabag.ch>
 
index a1a423d..30ffe1d 100644 (file)
@@ -157,29 +157,39 @@ class Tx_Workspaces_Service_Stages {
         */
        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 @@ class Tx_Workspaces_Service_Stages {
                                // 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 @@ class Tx_Workspaces_Service_Stages {
                                // 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 @@ class Tx_Workspaces_Service_Stages {
                $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;
        }
index 8d3df76..2ef0f0b 100644 (file)
@@ -168,6 +168,18 @@ Ext.ux.TYPO3.Workspace.RowPanel = Ext.extend(Ext.Panel, {
 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 @@ TYPO3.Workspaces.MainStore = new Ext.data.GroupingStore({
                },
                scope : this
        }
-});
+});
\ No newline at end of file
index 0628923..5472182 100644 (file)
@@ -70,6 +70,13 @@ TYPO3.Workspaces.SelectionModel = new Ext.grid.CheckboxSelectionModel({
        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 @@ TYPO3.Workspaces.WorkspaceGrid = new Ext.grid.GridPanel({
        }),
        bbar : TYPO3.Workspaces.Toolbar.FullBottomBar,
        tbar : TYPO3.Workspaces.Toolbar.FullTopToolbar
-});
+});
\ No newline at end of file
index 3bed5ff..9d8889b 100644 (file)
@@ -187,4 +187,8 @@ div .t3-workspaces-comments-singleComment-content {
 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