Project

General

Profile

Bug #21923 » 0013170_v3.patch

Administrator Admin, 2010-11-03 23:25

View differences:

t3lib/class.t3lib_userauthgroup.php (working copy)
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'));
t3lib/stddb/tables.sql (working copy)
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,
typo3/sysext/install/updates/class.tx_coreupdates_migrateworkspaces.php (working copy)
*/
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;
......
// 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();
......
}
/**
* 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
......
}
/**
* 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
typo3/sysext/version/tca.php (working copy)
'config' => array(
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'be_users',
'allowed' => 'be_users,be_groups',
'prepend_tname' => 1,
'size' => '3',
'maxitems' => '10',
'autoSizeMax' => 10,
(3-3/3)