From a8fa578906544110ef2ef3b47f44c7fbdcfb12c4 Mon Sep 17 00:00:00 2001
From: Marc Bastian Heinrichs <typo3@mbh-software.de>
Date: Wed, 5 Feb 2014 16:18:42 +0100
Subject: [PATCH] [BUGFIX] Show data of valid columns in element info

The element information show rows for the data from
the special fields crdate, cruser_id and tstamp also if they
are not defined in TCA. They are also hardcoded and
doesn't rely on the settings in TCA ctrl.

Resolves: #55699
Releases: master, 6.2
Change-Id: I7c9a387c75d367618117ffcb6f04592ee519cecc
Reviewed-on: http://review.typo3.org/27360
Reviewed-by: Frederic Gaus <frederic.gaus@flagbit.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
---
 .../ElementInformationController.php             | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
index 2be0e145f70d..b0888b9c46c6 100644
--- a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
+++ b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
@@ -329,9 +329,18 @@ class ElementInformationController {
 			$extraFields['crdate'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
 			$extraFields['cruser_id'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', TRUE);
 			$extraFields['tstamp'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
+
+			// check if the special fields are defined in the TCA ctrl section of the table
+			foreach ($extraFields as $fieldName => $fieldLabel) {
+				if (isset($GLOBALS['TCA'][$this->table]['ctrl'][$fieldName])) {
+					$extraFields[$GLOBALS['TCA'][$this->table]['ctrl'][$fieldName]] = $fieldLabel;
+				} else {
+					unset($extraFields[$fieldName]);
+				}
+			}
 		}
 
-		foreach ($extraFields as $name => $value) {
+		foreach ($extraFields as $name => $fieldLabel) {
 			$rowValue = '';
 			if (!isset($this->row[$name])) {
 				$resourceObject = $this->fileObject ?: $this->folderObject;
@@ -345,8 +354,9 @@ class ElementInformationController {
 			} else {
 				$rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
 			}
+			// show the backend username who created the issue
 			if ($name === 'cruser_id' && $rowValue) {
-				$userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('username, realName', 'be_users', 'uid = ' . (int)$rowValue);
+				$userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('username, realName', 'be_users', 'uid = ' . (int)$rowValue);
 				if ($userTemp[0]['username'] !== '') {
 					$rowValue = $userTemp[0]['username'];
 					if ($userTemp[0]['realName'] !== '') {
@@ -356,7 +366,7 @@ class ElementInformationController {
 			}
 			$tableRows[] = '
 				<tr>
-					<th>' . rtrim($value, ':') . '</th>
+					<th>' . rtrim($fieldLabel, ':') . '</th>
 					<td>' . htmlspecialchars($rowValue) . '</td>
 				</tr>';
 		}
-- 
GitLab