From 968be676db270a9c5aa347b55e83fcae1e4f8590 Mon Sep 17 00:00:00 2001
From: Wouter Wolters <typo3@wouterwolters.nl>
Date: Sun, 24 Apr 2016 14:02:12 +0200
Subject: [PATCH] [BUGFIX] Remove hardcoded hidden column

In InlineRecordContainer the enable column for disabled is not used
correctly but instead "hidden" is hardcoded. Use the enable column
from the foreign table.

Resolves: #75647
Releases: master, 7.6
Change-Id: I8d6dc05f368c4e358694572d0dfcbe1f996d72b8
Reviewed-on: https://review.typo3.org/47888
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Form/Container/InlineRecordContainer.php  | 20 +++++++++----------
 .../Public/JavaScript/jsfunc.inline.js        |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
index 7a2cc668d520..2a38ab1c27aa 100644
--- a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
+++ b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
@@ -127,6 +127,7 @@ class InlineRecordContainer extends AbstractContainer
         $html = '';
         $combinationHtml = '';
         $isNewRecord = $data['command'] === 'new';
+        $hiddenField = $GLOBALS['TCA'][$foreignTable]['ctrl']['enablecolumns']['disabled'];
         if (!$data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
             if ($isNewRecord || $data['isInlineChildExpanded']) {
                 // Render full content ONLY IF this is an AJAX request, a new record, or the record is not collapsed
@@ -160,15 +161,13 @@ class InlineRecordContainer extends AbstractContainer
                 // Set additional field for processing for saving
                 $html .= '<input type="hidden" name="cmd' . htmlspecialchars($appendFormFieldNames)
                     . '[delete]" value="1" disabled="disabled" />';
-                if (!$data['isInlineChildExpanded']
-                    && !empty($GLOBALS['TCA'][$foreignTable]['ctrl']['enablecolumns']['disabled'])
-                ) {
-                    $checked = !empty($record['hidden']) ? ' checked="checked"' : '';
+                if (!$data['isInlineChildExpanded'] && !empty($hiddenField)) {
+                    $checked = !empty($record[$hiddenField]) ? ' checked="checked"' : '';
                     $html .= '<input type="checkbox" data-formengine-input-name="data'
                         . htmlspecialchars($appendFormFieldNames)
-                        . '[hidden]" value="1"' . $checked . ' />';
+                        . '[' . htmlspecialchars($hiddenField) . ']" value="1"' . $checked . ' />';
                     $html .= '<input type="input" name="data' . htmlspecialchars($appendFormFieldNames)
-                        . '[hidden]" value="' . htmlspecialchars($record['hidden']) . '" />';
+                        . '[' . htmlspecialchars($hiddenField) . ']" value="' . htmlspecialchars($record[$hiddenField]) . '" />';
                 }
             }
             // If this record should be shown collapsed
@@ -182,7 +181,7 @@ class InlineRecordContainer extends AbstractContainer
             if ($data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
                 $class .= ' t3-form-field-container-inline-placeHolder';
             }
-            if (isset($record['hidden']) && (int)$record['hidden']) {
+            if (isset($record[$hiddenField]) && (int)$record[$hiddenField]) {
                 $class .= ' t3-form-field-container-inline-hidden';
             }
             $class .= ($isNewRecord ? ' inlineIsNewRecord' : '');
@@ -382,8 +381,8 @@ class InlineRecordContainer extends AbstractContainer
         $additionalCells = array();
         $isNewItem = substr($rec['uid'], 0, 3) == 'NEW';
         $isParentExisting = MathUtility::canBeInterpretedAsInteger($data['inlineParentUid']);
-        $tcaTableCtrl = &$GLOBALS['TCA'][$foreignTable]['ctrl'];
-        $tcaTableCols = &$GLOBALS['TCA'][$foreignTable]['columns'];
+        $tcaTableCtrl = $GLOBALS['TCA'][$foreignTable]['ctrl'];
+        $tcaTableCols = $GLOBALS['TCA'][$foreignTable]['columns'];
         $isPagesTable = $foreignTable === 'pages';
         $isSysFileReferenceTable = $foreignTable === 'sys_file_reference';
         $enableManualSorting = $tcaTableCtrl['sortby'] || $inlineConfig['MM'] || !$data['isOnSymmetricSide']
@@ -499,7 +498,8 @@ class InlineRecordContainer extends AbstractContainer
             // "Hide/Unhide" links:
             $hiddenField = $tcaTableCtrl['enablecolumns']['disabled'];
             if ($enabledControls['hide'] && $permsEdit && $hiddenField && $tcaTableCols[$hiddenField] && (!$tcaTableCols[$hiddenField]['exclude'] || $backendUser->check('non_exclude_fields', $foreignTable . ':' . $hiddenField))) {
-                $onClick = 'return inline.enableDisableRecord(' . GeneralUtility::quoteJSvalue($nameObjectFtId) . ')';
+                $onClick = 'return inline.enableDisableRecord(' . GeneralUtility::quoteJSvalue($nameObjectFtId) . ',' .
+                    GeneralUtility::quoteJSvalue($hiddenField) .')';
                 $className = 't3js-' . $nameObjectFtId . '_disabled';
                 if ($rec[$hiddenField]) {
                     $title = $languageService->sL(('LLL:EXT:lang/locallang_mod_web_list.xlf:unHide' . ($isPagesTable ? 'Page' : '')), true);
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js b/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js
index af43bc200ff7..ff5eb7fb977e 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js
@@ -883,8 +883,8 @@ var inline = {
 		}
 	},
 
-	enableDisableRecord: function (objectIdentifier) {
-		var elName = this.parseObjectId('full', objectIdentifier, 2, 0, true) + '[hidden]';
+	enableDisableRecord: function (objectIdentifier, fieldName) {
+		var elName = this.parseObjectId('full', objectIdentifier, 2, 0, true) + '[' + fieldName + ']';
 		var formObj = document.querySelector('[data-formengine-input-name="' + elName + '"]');
 		var valueObj = document.getElementsByName(elName);
 		var escapedObjectIdentifier = this.escapeObjectId(objectIdentifier);
-- 
GitLab