[FEATURE] Allow appending of element browser mounts 98/31898/13
authorAlexander Stehlik <alexander.stehlik@gmail.com>
Wed, 7 Jan 2015 15:10:25 +0000 (16:10 +0100)
committerBenjamin Mack <benni@typo3.org>
Thu, 22 Jan 2015 19:15:39 +0000 (20:15 +0100)
A new User TSconfig option is introduced that allows the alternative
element browser page tree mounts to be appended instead of beeing
replaced:

options.pageTree.altElementBrowserMountPoints.append

Additionally the handling of temporary mount points within the RTE
and the wizard element browser is unified. If a temporary mount
point is active the altElementBrowserMountPoints will be ignored.

Resolves: #50780
Documentation: #63009
Releases: master
Change-Id: I2a0b616b398131684a2c7c71a25b4b51ef6f0c50
Reviewed-on: http://review.typo3.org/31898
Reviewed-by: Alexander Stehlik <alexander.stehlik@gmail.com>
Tested-by: Alexander Stehlik <alexander.stehlik@gmail.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
typo3/sysext/core/Documentation/Changelog/master/Feature-50780-AppendElementBrowserMountPoints.rst [new file with mode: 0644]
typo3/sysext/recordlist/Classes/Controller/ElementBrowserController.php
typo3/sysext/rtehtmlarea/Classes/Controller/BrowseLinksController.php
typo3/sysext/rtehtmlarea/Classes/Extension/Abbreviation.php

index c4fb66b..56379b2 100644 (file)
@@ -1210,6 +1210,24 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
        }
 
        /**
+        * Initializes the given mount points for the current Backend user.
+        *
+        * @param array $mountPointUids Page UIDs that should be used as web mountpoints
+        * @param bool $append If TRUE the given mount point will be appended. Otherwise the current mount points will be replaced.
+        * @return void
+        */
+       public function setWebmounts(array $mountPointUids, $append = FALSE) {
+               if (empty($mountPointUids)) {
+                       return;
+               }
+               if ($append) {
+                       $currentWebMounts = GeneralUtility::intExplode(',', $this->groupData['webmounts']);
+                       $mountPointUids = array_merge($currentWebMounts, $mountPointUids);
+               }
+               $this->groupData['webmounts'] = implode(',', array_unique($mountPointUids));
+       }
+
+       /**
         * Returns TRUE or FALSE, depending if an alert popup (a javascript confirmation) should be shown
         * call like $GLOBALS['BE_USER']->jsConfirmation($BITMASK)
         *
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-50780-AppendElementBrowserMountPoints.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-50780-AppendElementBrowserMountPoints.rst
new file mode 100644 (file)
index 0000000..5ab569f
--- /dev/null
@@ -0,0 +1,38 @@
+=====================================================
+Feature: #50780 - Append element browser mount points
+=====================================================
+
+Description
+===========
+
+A new UserTSconfig option is introduced:
+
+::
+
+       options.pageTree.altElementBrowserMountPoints.append
+
+This option allows administrators to add additional mount points
+in the RTE and the Wizard element browser instead of replacing
+the configured database mount points of the user when using the
+existing UserTSconfig option:
+
+::
+
+       options.pageTree.altElementBrowserMountPoints
+
+Usage:
+
+Set these options in User TSconfig:
+
+::
+
+       options.pageTree.altElementBrowserMountPoints = 20,31
+       options.pageTree.altElementBrowserMountPoints.append = 1
+
+
+Impact
+======
+
+Mount point overriding is centralized in the BackendUser object and
+used by element browsers of rtehtmlarea and recordlist for calculating
+the page tree mount points that are displayed to the user.
index d159253..2a973e2 100644 (file)
@@ -93,25 +93,25 @@ class ElementBrowserController {
                        $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', (int)$tmpMount);
                }
                // Set temporary DB mounts
-               $tempDBmount = (int)$GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint');
-               if ($tempDBmount) {
-                       $altMountPoints = $tempDBmount;
-               }
-               if ($altMountPoints) {
-                       $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $altMountPoints)));
+               $alternativeWebmountPoint = (int)$GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint');
+               if ($alternativeWebmountPoint) {
+                       $alternativeWebmountPoint = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $alternativeWebmountPoint);
+                       $GLOBALS['BE_USER']->setWebmounts($alternativeWebmountPoint);
+               } else {
+                       switch ((string)$this->mode) {
+                               case 'rte':
+                               case 'db':
+                               case 'wizard':
+                                       // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
+                                       $alternativeWebmountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
+                                       $appendAlternativeWebmountPoints = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append');
+                                       if ($alternativeWebmountPoints) {
+                                               $alternativeWebmountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $alternativeWebmountPoints);
+                                               $GLOBALS['BE_USER']->setWebmounts($alternativeWebmountPoints, $appendAlternativeWebmountPoints);
+                                       }
+                       }
                }
                $this->content = '';
-               // Look for alternative mountpoints
-               switch ((string)$this->mode) {
-                       case 'rte':
-                       case 'db':
-                       case 'wizard':
-                               // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
-                               $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
-                               if ($altMountPoints) {
-                                       $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $altMountPoints)));
-                               }
-               }
                // Render type by user func
                $browserRendered = FALSE;
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
index ba438d6..60f6e8a 100644 (file)
@@ -42,6 +42,7 @@ class BrowseLinksController {
        public function main() {
                // Setting alternative web browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
                $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
+               $appendAltMountPoints = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append');
                // Clear temporary DB mounts
                $tmpMount = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('setTempDBmount');
                if (isset($tmpMount)) {
@@ -51,9 +52,11 @@ class BrowseLinksController {
                $tempDBmount = (int)$GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint');
                if ($tempDBmount) {
                        $altMountPoints = $tempDBmount;
+                       $appendAltMountPoints = FALSE;
                }
                if ($altMountPoints) {
-                       $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $altMountPoints)));
+                       $alternativeMountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $altMountPoints);
+                       $GLOBALS['BE_USER']->setWebmounts($alternativeMountPoints, $appendAltMountPoints);
                }
                // Setting alternative file browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
                $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
index 63748a6..fcc34f9 100644 (file)
@@ -189,10 +189,13 @@ class Abbreviation extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi {
                $lockBeUserToDBmounts = isset($this->thisConfig['buttons.'][$button . '.']['lockBeUserToDBmounts']) ? $this->thisConfig['buttons.'][$button . '.']['lockBeUserToDBmounts'] : $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts'];
                if (!$GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts'] && $lockBeUserToDBmounts) {
                        // Temporarily setting alternative web browsing mounts
-                       $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
-                       if ($altMountPoints) {
-                               $savedGroupDataWebmounts = $GLOBALS['BE_USER']->groupData['webmounts'];
-                               $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $altMountPoints)));
+                       $existingWebMounts = '';
+                       $alternativeWebmountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
+                       $appendAlternativeWebmountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append'));
+                       if (!empty($alternativeWebmountPoints)) {
+                               $alternativeWebmountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $alternativeWebmountPoints);
+                               $existingWebMounts = $GLOBALS['BE_USER']->returnWebmounts();
+                               $GLOBALS['BE_USER']->setWebmounts($alternativeWebmountPoints, $appendAlternativeWebmountPoints);
                        }
                        $webMounts = $GLOBALS['BE_USER']->returnWebmounts();
                        $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
@@ -208,8 +211,8 @@ class Abbreviation extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi {
                                $pids = $webMounts;
                        }
                        // Restoring webmounts
-                       if ($altMountPoints) {
-                               $GLOBALS['BE_USER']->groupData['webmounts'] = $savedGroupDataWebmounts;
+                       if (!empty($alternativeWebmountPoints)) {
+                               $GLOBALS['BE_USER']->setWebmounts($existingWebMounts);
                        }
                        $queryGenerator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\QueryGenerator::class);
                        $pageTree = '';