[BUGFIX] Setting capabilities to readonly show always drag+drop dialog 46/27946/6
authorRico Sonntag <rico.sonntag@netresearch.de>
Fri, 28 Feb 2014 13:57:47 +0000 (14:57 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 4 Mar 2014 18:09:15 +0000 (19:09 +0100)
If a driver is readonly, the upload button in the file list disappears,
but the DragUploader is still activated - on the whole page.
Clicking anywhere on the list page causes an upload file selection to
pop up. Additionally the new button is shown but has no functionality.
The patch removes DragUploader and superfluous button.

Change-Id: I3f6c2e932d9f66feb6590f08229ddaaad06e688e
Resolves: #56443
Releases: 6.2
Reviewed-on: https://review.typo3.org/27946
Reviewed-by: Nicole Cordes
Tested-by: Nicole Cordes
Reviewed-by: Christian Weiske
Tested-by: Christian Weiske
Reviewed-by: Rico Sonntag
Tested-by: Rico Sonntag
Reviewed-by: Frans Saris
Tested-by: Frans Saris
typo3/sysext/filelist/Classes/Controller/FileListController.php

index 806ab0c..0cf7bc0 100644 (file)
@@ -234,13 +234,7 @@ class FileListController {
                $pageRenderer = $this->doc->getPageRenderer();
                $pageRenderer->loadPrototype();
                $pageRenderer->loadJQuery();
-               $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DragUploader');
                $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileListLocalisation');
-               $pageRenderer->addInlineSetting('DragUploader', 'ajaxUrl', BackendUtility::getAjaxUrl('TYPO3_tcefile::process'));
-               $pageRenderer->addInlineLanguagelabelFile(
-                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('lang') . 'locallang_core.xlf',
-                       'file_upload'
-               );
 
                // There there was access to this file path, continue, make the list
                if ($this->folderObject) {
@@ -333,6 +327,18 @@ class FileListController {
                        $otherMarkers['FOLDER_INFO'] = $this->filelist->getFolderInfo();
                        $docHeaderButtons = array_merge($this->getButtons(), $buttons);
 
+                       // Include DragUploader only if we have write access
+                       if ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File')
+                               && $this->folderObject->checkActionPermission('write')
+                       ) {
+                               $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DragUploader');
+                               $pageRenderer->addInlineSetting('DragUploader', 'ajaxUrl', BackendUtility::getAjaxUrl('TYPO3_tcefile::process'));
+                               $pageRenderer->addInlineLanguagelabelFile(
+                                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('lang') . 'locallang_core.xlf',
+                                       'file_upload'
+                               );
+                       }
+
                        // Build the <body> for the module
                        $moduleHeadline = $this->getModuleHeadline();
                        // Create output
@@ -450,7 +456,9 @@ class FileListController {
                        $buttons['upload'] = '<a href="' . $GLOBALS['BACK_PATH'] . 'file_upload.php?target=' . rawurlencode($this->folderObject->getCombinedIdentifier()) . '&amp;returnUrl=' . rawurlencode($this->filelist->listURL()) . '" id="button-upload" title="' . $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.upload', TRUE)) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-upload') . '</a>';
                }
                // New folder button
-               if ($this->folderObject && ($this->folderObject->checkActionPermission('add') || $this->folderObject->getStorage()->checkUserActionPermission('add', 'File'))) {
+               if ($this->folderObject && $this->folderObject->checkActionPermission('write')
+                       && ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File') || $this->folderObject->checkActionPermission('add'))
+               ) {
                        $buttons['new'] = '<a href="' . $GLOBALS['BACK_PATH'] . 'file_newfolder.php?target=' . rawurlencode($this->folderObject->getCombinedIdentifier()) . '&amp;returnUrl=' . rawurlencode($this->filelist->listURL()) . '" title="' . $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.new', TRUE)) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-new') . '</a>';
                }
                return $buttons;