[BUGFIX] Remove ElementBrowser::isReadOnlyFolder 67/26467/2
authorMarkus Klein <klein.t3@mfc-linz.at>
Wed, 27 Nov 2013 22:20:25 +0000 (23:20 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Wed, 18 Dec 2013 10:55:55 +0000 (11:55 +0100)
ElementBrowser::isReadOnlyFolder is not required any more because the
check if the folder is writable has been moved to the methods that
create the file upload and folder creation forms.

The method and the parts where it was used were removed.

Additionally the check if the user is allowed to create folders
by TSConfig was moved to the createFolder method to reduce the amount
of duplicate code.

Resolves: #47648
Releases: 6.2, 6.1, 6.0
Change-Id: Ic6504c8def80012cbe420fc83539cfa859a53c0d
Reviewed-on: https://review.typo3.org/26467
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
typo3/sysext/rtehtmlarea/Classes/BrowseLinks.php
typo3/sysext/rtehtmlarea/Classes/SelectImage.php

index 5cdf804..92af6a8 100644 (file)
@@ -830,11 +830,9 @@ class ElementBrowser {
                        // Build the file upload and folder creation form
                        $uploadForm = '';
                        $createFolder = '';
-                       if ($selectedFolder && !$this->isReadOnlyFolder($selectedFolder)) {
+                       if ($selectedFolder) {
                                $uploadForm = ($this->act === 'file') ? $this->uploadForm($selectedFolder) : '';
-                               if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
-                                       $createFolder = $this->createFolder($selectedFolder);
-                               }
+                               $createFolder = $this->createFolder($selectedFolder);
                        }
                        // Insert the upload form on top, if so configured
                        if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
@@ -1177,17 +1175,9 @@ class ElementBrowser {
                        // Build the file upload and folder creation form
                $uploadForm = '';
                $createFolder = '';
-               if ($this->selectedFolder && !$this->isReadOnlyFolder($this->selectedFolder)) {
-                       $uploadForm = ($this->act === 'file') ? $this->uploadForm($this->selectedFolder) : '';
-                       if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
-                               $createFolder =  $this->createFolder($this->selectedFolder);
-                       }
-               }
                if ($this->selectedFolder) {
                        $uploadForm = $this->uploadForm($this->selectedFolder);
                        $createFolder = $this->createFolder($this->selectedFolder);
-               } else {
-                       $uploadForm = $createFolder = '';
                }
                // Insert the upload form on top, if so configured
                if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
@@ -1261,7 +1251,7 @@ class ElementBrowser {
                if ($this->expandFolder) {
                        $this->selectedFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
                }
-               if ($this->selectedFolder && !$this->isReadOnlyFolder($this->selectedFolder)) {
+               if ($this->selectedFolder) {
                        $createFolder = $this->createFolder($this->selectedFolder);
                } else {
                        $createFolder = '';
@@ -1291,9 +1281,7 @@ class ElementBrowser {
                        </table>
                        ';
                // Adding create folder if applicable:
-               if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
-                       $content .= $createFolder;
-               }
+               $content .= $createFolder;
                // Add some space
                $content .= '<br /><br />';
                // Ending page, returning content:
@@ -1883,17 +1871,6 @@ class ElementBrowser {
        }
 
        /**
-        * Checks, if a path is within a read-only mountpoint of the backend user
-        *
-        * @param string $folder Absolute filepath
-        * @return boolean If the input path is found in the backend users filemounts and if the filemount is of type readonly, then return TRUE.
-        * @todo Define visibility
-        */
-       public function isReadOnlyFolder($folder) {
-               return $GLOBALS['FILEMOUNTS'][$this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/')]['type'] == 'readonly';
-       }
-
-       /**
         * Prints a 'header' where string is in a tablecell
         *
         * @param string $str The string to print in the header. The value is htmlspecialchars()'ed before output.
@@ -2122,6 +2099,9 @@ class ElementBrowser {
                if (!$folderObject->checkActionPermission('write')) {
                        return '';
                }
+               if (!($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB'))) {
+                       return '';
+               }
                // Don't show Folder-create form if it's denied
                if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
                        return '';
index d202ceb..9a983e4 100644 (file)
@@ -575,11 +575,9 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                        // Build the file upload and folder creation forms
                        $uploadForm = '';
                        $createFolder = '';
-                       if ($selectedFolder && !$this->isReadOnlyFolder($selectedFolder)) {
+                       if ($selectedFolder) {
                                $uploadForm = $this->act === 'file' ? $this->uploadForm($selectedFolder) : '';
-                               if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
-                                       $createFolder = $this->createFolder($selectedFolder);
-                               }
+                               $createFolder = $this->createFolder($selectedFolder);
                        }
                        // Insert the upload form on top, if so configured
                        if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
@@ -973,4 +971,4 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 }
 
 
-?>
\ No newline at end of file
+?>
index 7995d83..938de1f 100644 (file)
@@ -742,11 +742,9 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                        // Build the file upload and folder creation form
                        $uploadForm = '';
                        $createFolder = '';
-                       if ($selectedFolder && !$this->isReadOnlyFolder($selectedFolder)) {
+                       if ($selectedFolder) {
                                $uploadForm = $this->uploadForm($selectedFolder);
-                               if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
-                                       $createFolder = $this->createFolder($selectedFolder);
-                               }
+                               $createFolder = $this->createFolder($selectedFolder);
                        }
                        // Insert the upload form on top, if so configured
                        if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {