From 55b54a2ffd6eec7689fc25e6c01757ecb149a897 Mon Sep 17 00:00:00 2001
From: Francois Suter <francois@typo3.org>
Date: Thu, 23 Jan 2014 13:29:34 +0100
Subject: [PATCH] [BUGFIX] Categories as exclude field

When a table is marked as being categorizable, the
categories field is added with an "exclude" flag
hard-coded to 0. Thus it is not possible to hide
this field for editors.

This patch changes the default value to 1 and makes
overridable.

Resolves: #53454
Documentation: #55718
Releases: 6.2
Change-Id: Iff2431b4294b8d3b9cf3dff291186e1a6a2ebafb
Reviewed-on: https://review.typo3.org/27373
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Francois Suter
Tested-by: Francois Suter
---
 NEWS.md                                                |  5 +++++
 .../sysext/core/Classes/Category/CategoryRegistry.php  | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/NEWS.md b/NEWS.md
index 4347027f8595..61e9590625fc 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -210,3 +210,8 @@ Pages and content elements are now categorizable by default.
 
 The "Special Menus" content element type now offers the possibility to display
 a list of categorized pages or content elements.
+
+* Category fields are excluded by default
+
+Category fields are created as exclude field (TCA) by default.
+If you're upgrading don't forget to add the permission for users.
diff --git a/typo3/sysext/core/Classes/Category/CategoryRegistry.php b/typo3/sysext/core/Classes/Category/CategoryRegistry.php
index 2ea70aeebf48..5dd35b07be24 100644
--- a/typo3/sysext/core/Classes/Category/CategoryRegistry.php
+++ b/typo3/sysext/core/Classes/Category/CategoryRegistry.php
@@ -348,6 +348,7 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
 				),
 			);
 
+			// Merge changes to TCA configuration
 			if (!empty($options['fieldConfiguration'])) {
 				\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(
 					$fieldConfiguration,
@@ -355,14 +356,21 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
 				);
 			}
 
+			// Take specific label into account
 			$label = 'LLL:EXT:lang/locallang_tca.xlf:sys_category.categories';
 			if (!empty($options['label'])) {
 				$label = $options['label'];
 			}
 
+			// Take specific value of exclude flag into account
+			$exclude = TRUE;
+			if (isset($options['exclude'])) {
+				$exclude = (bool)$options['exclude'];
+			}
+
 			$columns = array(
 				$fieldName => array(
-					'exclude' => 0,
+					'exclude' => $exclude,
 					'label' => $label,
 					'config' => $fieldConfiguration,
 				),
-- 
GitLab