[BUGFIX] Show duplicate button only if it makes sense 13/55713/4
authorFrank Naegler <frank.naegler@typo3.org>
Wed, 14 Feb 2018 12:10:00 +0000 (13:10 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 15 Feb 2018 01:29:02 +0000 (02:29 +0100)
Resolves: #83892
Related: #77685
Releases: master
Change-Id: I16a7d57efa7d75e712bba24724d4da365b0aa40a
Reviewed-on: https://review.typo3.org/55713
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Controller/EditDocumentController.php

index 401b447..cdf8e76 100644 (file)
@@ -1328,7 +1328,27 @@ class EditDocumentController
             ));
         $buttonBar->addButton($closeButton);
         // DUPLICATE button:
+        $record = BackendUtility::getRecord($this->firstEl['table'], $this->firstEl['uid']);
+        $l18nParent = $record['l18n_parent'] ?? 0;
+        $sysLanguageUid = $record['sys_language_uid'] ?? 0;
+        $showDuplicateButton = false;
         if ($this->firstEl['cmd'] !== 'new' && MathUtility::canBeInterpretedAsInteger($this->firstEl['uid'])) {
+            // Special case: pages
+            if ($this->firstEl['table'] === 'pages') {
+                // show button only, if record is in default language
+                $showDuplicateButton = (int)$sysLanguageUid === 0;
+            } else {
+                // not pages table
+                if ((int)$sysLanguageUid === 0) {
+                    // show button, if record is in default language
+                    $showDuplicateButton = true;
+                } else {
+                    // show button, if record is NOT in default language AND has no parent
+                    $showDuplicateButton = (int)$l18nParent === 0;
+                }
+            }
+        }
+        if ($showDuplicateButton) {
             $duplicateButton = $buttonBar->makeLinkButton()
                 ->setHref('#')
                 ->setClasses('t3js-editform-duplicate')