[BUGFIX] Hidden state is not always visualized in module
authorOliver Hader <oliver@typo3.org>
Wed, 19 Dec 2012 12:00:45 +0000 (13:00 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Fri, 4 Jan 2013 08:34:00 +0000 (09:34 +0100)
The hidden state of a record is not always visualized in the
workspace module. This is fixed by not looking whether 'hidden'
is configured as $TCA column but to use the 'disabled' part of
the enable-fields instead.

Change-Id: I5dbb89b83988311b38a3fb7f690c9eb78478566a
Fixes: #44114
Releases: 4.5, 4.6, 4.7, 6.0, 6.1
Reviewed-on: https://review.typo3.org/17238
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/workspaces/Classes/Service/GridDataService.php

index e3b379d..fd9cc70 100644 (file)
@@ -127,17 +127,21 @@ class GridDataService {
                        $stagesObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\StagesService');
                        foreach ($versions as $table => $records) {
                                $versionArray = array('table' => $table);
+                               $hiddenField = $this->getTcaEnableColumnsFieldName($table, 'disabled');
                                $isRecordTypeAllowedToModify = $GLOBALS['BE_USER']->check('tables_modify', $table);
+
                                foreach ($records as $record) {
                                        $origRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $record['t3ver_oid']);
                                        $versionRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $record['uid']);
                                        $combinedRecord = \TYPO3\CMS\Workspaces\Domain\Model\CombinedRecord::createFromArrays($table, $origRecord, $versionRecord);
                                        $this->getIntegrityService()->checkElement($combinedRecord);
-                                       if (isset($GLOBALS['TCA'][$table]['columns']['hidden'])) {
-                                               $recordState = $this->workspaceState($versionRecord['t3ver_state'], $origRecord['hidden'], $versionRecord['hidden']);
+
+                                       if ($hiddenField !== NULL) {
+                                               $recordState = $this->workspaceState($versionRecord['t3ver_state'], $origRecord[$hiddenField], $versionRecord[$hiddenField]);
                                        } else {
                                                $recordState = $this->workspaceState($versionRecord['t3ver_state']);
                                        }
+
                                        $isDeletedPage = $table == 'pages' && $recordState == 'deleted';
                                        $viewUrl = \TYPO3\CMS\Workspaces\Service\WorkspaceService::viewSingleRecord($table, $record['uid'], $origRecord, $versionRecord);
                                        $versionArray['id'] = $table . ':' . $record['uid'];
@@ -449,6 +453,23 @@ class GridDataService {
                return $state;
        }
 
+       /**
+        * Gets the field name of the enable-columns as defined in $TCA.
+        *
+        * @param string $table Name of the table
+        * @param string $type Type to be fetches (e.g. 'disabled', 'starttime', 'endtime', 'fe_group)
+        * @return string|NULL The accordant field name or NULL if not defined
+        */
+       protected function getTcaEnableColumnsFieldName($table, $type) {
+               $fieldName = NULL;
+
+               if (!(empty($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'][$type]))) {
+                       $fieldName = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'][$type];
+               }
+
+               return $fieldName;
+       }
+
        /**
         * Gets the used language value (sys_language.uid) of
         * a given database record.
@@ -541,4 +562,4 @@ class GridDataService {
 }
 
 
-?>
\ No newline at end of file
+?>