[BUGFIX] Fix display logic of ShortcutButton 31/44031/2
authorMathias Schreiber <mathias.schreiber@wmdb.de>
Tue, 13 Oct 2015 12:20:56 +0000 (14:20 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 13 Oct 2015 12:30:21 +0000 (14:30 +0200)
Just because a user may not store shortcuts it seems a bit drastic to
declare the button invalid thus triggering an exception.
This has been fixed now.

Resolves: #70651
Releases: master
Change-Id: I8f8848501926c8c7a9445e0d59b3ff865d005791
Reviewed-on: http://review.typo3.org/44031
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Andreas Allacher <andreas.allacher@gmx.at>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Andreas Allacher <andreas.allacher@gmx.at>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Template/Components/Buttons/Action/ShortcutButton.php

index 746bc6f..c560dcd 100644 (file)
@@ -168,8 +168,7 @@ class ShortcutButton implements ButtonInterface, PositionInterface
         $this->preProcess();
 
         return (
-            $this->getBackendUser()->mayMakeShortcut()
-            && !empty($this->moduleName)
+            !empty($this->moduleName)
         );
     }
 
@@ -190,15 +189,19 @@ class ShortcutButton implements ButtonInterface, PositionInterface
      */
     public function render()
     {
-        /** @var DocumentTemplate $documentTemplate */
-        $documentTemplate = GeneralUtility::makeInstance(DocumentTemplate::class);
-        $shortcutMarkup = $documentTemplate->makeShortcutIcon(
-            implode(',', $this->getVariables),
-            implode(',', $this->setVariables),
-            $this->moduleName,
-            '',
-            'btn btn-sm btn-default'
-        );
+        if ($this->getBackendUser()->mayMakeShortcut()) {
+            /** @var DocumentTemplate $documentTemplate */
+            $documentTemplate = GeneralUtility::makeInstance(DocumentTemplate::class);
+            $shortcutMarkup = $documentTemplate->makeShortcutIcon(
+                implode(',', $this->getVariables),
+                implode(',', $this->setVariables),
+                $this->moduleName,
+                '',
+                'btn btn-sm btn-default'
+            );
+        } else {
+            $shortcutMarkup = '';
+        }
 
         return $shortcutMarkup;
     }