[BUGFIX] Enable deletion of translated sys_file_metadata records 54/55354/2
authorWolfgang Klinger <wolfgang@wazum.com>
Fri, 12 Jan 2018 10:57:24 +0000 (11:57 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 13 Jan 2018 19:45:24 +0000 (20:45 +0100)
UserTS disableDelete was set for sys_file_metadata globally
and therefore also prevented the deletion of translated file metadata.
By preventing deletion of sys_file_metadata records only for default
language records, the user can remove translated ones again at will.

Resolves: #83066
Relates: #71678
Releases: master, 8.7
Change-Id: I3b83a3dd63b02b94bdd34dd8f002436af14ad45d
Reviewed-on: https://review.typo3.org/55354
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/backend/Configuration/TSconfig/User/Options.ts [deleted file]
typo3/sysext/backend/ext_localconf.php

index ef05fc2..7b5fede 100644 (file)
@@ -1293,7 +1293,7 @@ class EditDocumentController extends AbstractModule
                 // Delete:
                 if ($this->firstEl['deleteAccess']
                     && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly']
-                    && !$this->getNewIconMode($this->firstEl['table'], 'disableDelete')
+                    && !$this->getDisableDelete()
                 ) {
                     $returnUrl = $this->retUrl;
                     if ($this->firstEl['table'] === 'pages') {
@@ -1497,6 +1497,27 @@ class EditDocumentController extends AbstractModule
         }
     }
 
+    /**
+     * Returns if delete for the current table is disabled by configuration.
+     * For sys_file_metadata in default language delete is always disabled.
+     *
+     * @return bool
+     */
+    protected function getDisableDelete(): bool
+    {
+        $disableDelete = false;
+        if ($this->firstEl['table'] === 'sys_file_metadata') {
+            $row = BackendUtility::getRecord('sys_file_metadata', $this->firstEl['uid'], 'sys_language_uid');
+            $languageUid = $row['sys_language_uid'];
+            if ($languageUid === 0) {
+                $disableDelete = true;
+            }
+        } else {
+            $disableDelete = (bool)$this->getNewIconMode($this->firstEl['table'], 'disableDelete');
+        }
+        return $disableDelete;
+    }
+
     /***************************
      *
      * Localization stuff
diff --git a/typo3/sysext/backend/Configuration/TSconfig/User/Options.ts b/typo3/sysext/backend/Configuration/TSconfig/User/Options.ts
deleted file mode 100644 (file)
index ca96d3e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-options.disableDelete.sys_file_metadata = 1
index c059718..176ae2b 100644 (file)
@@ -42,4 +42,3 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch']['page'] = 'pages';
 
 // Include base TSconfig setup
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:backend/Configuration/TSconfig/Page/Mod/Wizards/NewContentElement.ts">');
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:backend/Configuration/TSconfig/User/Options.ts">');