[BUGFIX] Limit workspace access checks if extension not used
authorTolleiv Nietsch <info@tolleiv.de>
Mon, 17 Oct 2011 16:47:35 +0000 (18:47 +0200)
committerXavier Perseguers <xavier@typo3.org>
Sat, 22 Oct 2011 10:30:56 +0000 (12:30 +0200)
In some cases the access to a workspace is checked even
if EXT:workspaces is not installed. This should be avoided
whenever possible.

Change-Id: I2f16a630a8f02bf1aa9a5bd61a340b53b6fd1365
Fixes: #30870
Branches: 4.6, 4.5
Reviewed-on: http://review.typo3.org/6063
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
t3lib/class.t3lib_userauthgroup.php

index 263c2f9..a978118 100644 (file)
@@ -196,7 +196,8 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
                }
 
                        // Workspaces check:
-               if ($conf['workspaces']) {
+
+               if (t3lib_extMgm::isLoaded('workspaces') && $conf['workspaces']) {
                        if (($this->workspace === 0 && t3lib_div::inList($conf['workspaces'], 'online')) ||
                                ($this->workspace === -1 && t3lib_div::inList($conf['workspaces'], 'offline')) ||
                                ($this->workspace > 0 && t3lib_div::inList($conf['workspaces'], 'custom'))) {
@@ -1669,25 +1670,30 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
        }
 
        /**
-        * Return default workspace ID for user
+        * Return default workspace ID for user,
+        * If EXT:workspaces is not installed the user will be pushed the the
+        * Live workspace
         *
         * @return      integer         Default workspace id. If no workspace is available it will be "-99"
         */
        function getDefaultWorkspace() {
 
-               if ($this->checkWorkspace(0)) { // Check online
-                       return 0;
+               $defaultWorkspace = -99;
+
+               if (!t3lib_extMgm::isLoaded('workspaces') || $this->checkWorkspace(0)) { // Check online
+                       $defaultWorkspace = 0;
                } elseif ($this->checkWorkspace(-1)) { // Check offline
-                       return -1;
+                       $defaultWorkspace = -1;
                } elseif (t3lib_extMgm::isLoaded('workspaces')) { // Traverse custom workspaces:
                        $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers', 'sys_workspace', 'pid=0' . t3lib_BEfunc::deleteClause('sys_workspace'), '', 'title');
                        foreach ($workspaces as $rec) {
                                if ($this->checkWorkspace($rec)) {
-                                       return $rec['uid'];
+                                       $defaultWorkspace = $rec['uid'];
+                                       break;
                                }
                        }
                }
-               return -99;
+               return $defaultWorkspace;
        }