Index: t3lib/class.t3lib_userauthgroup.php =================================================================== --- t3lib/class.t3lib_userauthgroup.php (revision 9262) +++ t3lib/class.t3lib_userauthgroup.php (working copy) @@ -1618,9 +1618,15 @@ break; default: // Checking if the guy is admin: - if (t3lib_div::inList($wsRec['adminusers'],$this->user['uid'])) { + if (t3lib_div::inList($wsRec['adminusers'], 'be_users_' . $this->user['uid'])) { return array_merge($wsRec, array('_ACCESS' => 'owner')); } + // Checking if he is owner through a user group of his: + foreach($this->userGroupsUID as $groupUid) { + if (t3lib_div::inList($wsRec['adminusers'], 'be_groups_' . $groupUid)) { + return array_merge($wsRec, array('_ACCESS' => 'owner')); + } + } // Checking if he is reviewer user: if (t3lib_div::inList($wsRec['reviewers'],'be_users_'.$this->user['uid'])) { return array_merge($wsRec, array('_ACCESS' => 'reviewer')); Index: t3lib/stddb/tables.sql =================================================================== --- t3lib/stddb/tables.sql (revision 9262) +++ t3lib/stddb/tables.sql (working copy) @@ -336,7 +336,7 @@ deleted tinyint(1) DEFAULT '0' NOT NULL, title varchar(30) DEFAULT '' NOT NULL, description varchar(255) DEFAULT '' NOT NULL, - adminusers varchar(255) DEFAULT '' NOT NULL, + adminusers text, members text, reviewers text, db_mountpoints varchar(255) DEFAULT '' NOT NULL, Index: typo3/sysext/install/updates/class.tx_coreupdates_migrateworkspaces.php =================================================================== --- typo3/sysext/install/updates/class.tx_coreupdates_migrateworkspaces.php (revision 9262) +++ typo3/sysext/install/updates/class.tx_coreupdates_migrateworkspaces.php (working copy) @@ -52,12 +52,20 @@ */ public function checkForUpdate(&$description) { $result = FALSE; - $description = 'Migrates the old hardcoded draft workspace to be a real workspace element'; + $description = 'Migrates the old hardcoded draft workspace to be a real workspace element and update workspace owner fields to support either users or groups.'; // TYPO3 version 4.5 and above if ($this->versionNumber >= 4005000) { - $this->includeTCA(); - $result = $this->isDraftWorkspaceUsed(); + $tables = array_keys($GLOBALS['TYPO3_DB']->admin_get_tables()); + // sys_workspace table might not exists if version extension was never installed + if (in_array('sys_workspace', $tables)) { + $result = $this->isOldStyleAdminFieldUsed(()); + } + + if (!$result) { + $this->includeTCA(); + $result = $this->isDraftWorkspaceUsed(); + } } return $result; @@ -97,6 +105,11 @@ // install version extension (especially when updating from very old TYPO3 versions $this->installExtensions(array('version')); + // migrate all workspaces to support groups and be_users + if ($this->isOldStyleAdminFieldUsed()) { + $this->migrateAdminFieldToNewStyle(); + } + // create a new dedicated "Draft" workspace and move all records to that new workspace if ($this->isDraftWorkspaceUsed()) { $draftWorkspaceId = $this->createWorkspace(); @@ -155,6 +168,17 @@ } /** + * Check if there's any workspace which doesn't support the new admin-field format yet + * @return bool + */ + protected function isOldStyleAdminFieldUsed() { + $where = 'adminusers != "" AND adminusers NOT LIKE "%be_users%" AND adminusers NOT LIKE "%be_groups%" AND deleted=0'; + $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'sys_workspace', $where); + $this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery; + return $count > 0; + } + + /** * Create a real workspace named "Draft" * * @return integer @@ -192,6 +216,30 @@ } /** + * Migrate all workspace adminusers fields to support groups aswell, + * this means that the old comma separated list of uids (referring to be_users) + * is updated to be a list of uids with the tablename as prefix + * + * @return void + */ + protected function migrateAdminFieldToNewStyle() { + $where = 'adminusers != "" AND adminusers NOT LIKE "%be_users%" AND adminusers NOT LIKE "%be_groups%" AND deleted=0'; + $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid, adminusers', 'sys_workspace', $where); + $this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery; + foreach($workspaces as $workspace) { + $updateArray = array( + 'adminusers' => 'be_users_' . implode(',be_users_', t3lib_div::trimExplode(',', $workspace['adminusers'], TRUE)), + ); + $resUp = $GLOBALS['TYPO3_DB']->exec_UPDATEquery( + 'sys_workspace', + 'uid = "' . $workspace['uid'] . '"', + $updateArray + ); + $this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery; + } + } + + /** * Includes the TCA definition of installed extensions. * * This method is used because usually the TCA is included within the init.php script, this doesn't happen Index: typo3/sysext/version/tca.php =================================================================== --- typo3/sysext/version/tca.php (revision 9262) +++ typo3/sysext/version/tca.php (working copy) @@ -27,7 +27,8 @@ 'config' => array( 'type' => 'group', 'internal_type' => 'db', - 'allowed' => 'be_users', + 'allowed' => 'be_users,be_groups', + 'prepend_tname' => 1, 'size' => '3', 'maxitems' => '10', 'autoSizeMax' => 10,