Project

General

Profile

Bug #15215 » bug_1839_v2.txt

Administrator Admin, 2007-05-02 10:50

 
Index: t3lib/class.t3lib_page.php
===================================================================
--- t3lib/class.t3lib_page.php (revision 2255)
+++ t3lib/class.t3lib_page.php (working copy)
@@ -115,7 +115,7 @@
// Versioning preview related:
var $versioningPreview = FALSE; // If true, preview of other record versions is allowed. THIS MUST ONLY BE SET IF the page is not cached and truely previewed by a backend user!!!
var $versioningWorkspaceId = 0; // Workspace ID for preview
-
+ var $workspaceCache = array();
// Internal, dynamic:
@@ -799,7 +799,9 @@
$uid = intval($uid);
if (is_array($TCA[$table]) || $table=='pages') { // Excluding pages here so we can ask the function BEFORE TCA gets initialized. Support for this is followed up in deleteClause()...
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, 'uid='.intval($uid).$this->deleteClause($table));
- if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+ $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
+ $GLOBALS['TYPO3_DB']->sql_free_result($res);
+ if ($row) {
if (!$noWSOL) {
$this->versionOL($table,$row);
}
@@ -1068,8 +1070,8 @@
}
}
- // If workspace ids matches and ID of current online version is found, look up the PID value of that:
- if ($oid && !strcmp((int)$wsid,$this->versioningWorkspaceId)) {
+ // If workspace ids matches and ID of current online version is found, look up the PID value of that:
+ if ($oid && (($this->versioningWorkspaceId == 0 && $this->checkWorkspaceAccess($wsid)) || !strcmp((int)$wsid,$this->versioningWorkspaceId))) {
$oidRec = $this->getRawRecord($table,$oid,'pid',TRUE);
if (is_array($oidRec)) {
@@ -1199,6 +1201,38 @@
return FALSE; // No look up in database because versioning not enabled / or workspace not offline
}
+
+ /**
+ * Checks if user has access to workspace.
+ *
+ * @param int $wsid Workspace ID
+ * @return boolean <code>true</code> if has access
+ */
+ function checkWorkspaceAccess($wsid) {
+ if (!$GLOBALS['BE_USER']) {
+ return false;
+ }
+ if (isset($this->workspaceCache[$wsid])) {
+ $ws = $this->workspaceCache[$wsid];
+ }
+ else {
+ if ($wsid > 0) {
+ $ws = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_workspace', 'uid='.intval($wsid).' AND deleted=0'); // No $TCA yet!
+ if (count($ws)) {
+ $ws = $ws[0];
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ $ws = $wsid;
+ }
+ $ws = $GLOBALS['BE_USER']->checkWorkspace($ws);
+ $this->workspaceCache[$wsid] = $ws;
+ }
+ return ($ws['_ACCESS'] != '');
+ }
}
Index: t3lib/class.t3lib_tcemain.php
===================================================================
--- t3lib/class.t3lib_tcemain.php (revision 2255)
+++ t3lib/class.t3lib_tcemain.php (working copy)
@@ -2347,8 +2347,8 @@
$elementList[$table][] = array($id, $value['swapWith']);
}
foreach ($elementList as $tbl => $idList) {
- foreach ($idList as $id) {
- $this->version_swap($tbl,$id[0],$id[1],$value['swapIntoWS']);
+ foreach ($idList as $idSet) {
+ $this->version_swap($tbl,$idSet[0],$idSet[1],$value['swapIntoWS']);
}
}
break;
@@ -3780,6 +3780,7 @@
'1'
);
list($highestVerNumber) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
+ $GLOBALS['TYPO3_DB']->sql_free_result($res);
// Look for version number of the current:
$subVer = $row['t3ver_id'].'.'.($highestVerNumber+1);
Index: typo3/mod/user/ws/class.wslib_gui.php
===================================================================
--- typo3/mod/user/ws/class.wslib_gui.php (revision 2255)
+++ typo3/mod/user/ws/class.wslib_gui.php (working copy)
@@ -381,10 +381,24 @@
// Traverse the versions of the element
foreach($recs as $rec) {
- // Get the offline version record and icon:
+ // Get the offline version record:
$rec_off = t3lib_BEfunc::getRecord($table,$rec['uid']);
+
+ // Prepare swap-mode values:
+ if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1) {
+ if ($rec_off['t3ver_swapmode']>0) {
+ $vType = 'branch'; // Do not translate!
+ } else {
+ $vType = 'page'; // Do not translate!
+ }
+ } else {
+ $vType = 'element'; // Do not translate!
+ }
+
+ // Get icon:
$icon = t3lib_iconWorks::getIconImage($table, $rec_off, $this->doc->backPath, ' align="top" title="'.t3lib_BEfunc::getRecordIconAltText($rec_off,$table).'"');
- $icon = $this->doc->wrapClickMenuOnIcon($icon, $table, $rec_off['uid'], 2, '', '+edit,view,info,delete');
+ $tempUid = ($table != 'pages' || $vType==='branch' || $GLOBALS['BE_USER']->workspace == 0 ? $rec_off['uid'] : $rec_on['uid']);
+ $icon = $this->doc->wrapClickMenuOnIcon($icon, $table, $tempUid, 2, '', '+edit,' . ($table == 'pages' ? 'view,info,' : '') . 'delete');
// Prepare diff-code:
if ($this->diff) {
@@ -404,17 +418,6 @@
} else $diffCode = '';
- // Prepare swap-mode values:
- if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1) {
- if ($rec_off['t3ver_swapmode']>0) {
- $vType = 'branch'; // Do not translate!
- } else {
- $vType = 'page'; // Do not translate!
- }
- } else {
- $vType = 'element'; // Do not translate!
- }
-
switch($vType) {
case 'element':
$swapLabel = ' ['.$LANG->getLL('label_element').']';
@@ -447,12 +450,12 @@
$multipleWarning = (!$mainCell && $GLOBALS['BE_USER']->workspace!==0? '<br/>'.$this->doc->icons(3).'<b>'.$LANG->getLL('label_multipleversions').'</b>' : '');
$verWarning = $warnAboutVersions || ($warnAboutVersions_nonPages && $GLOBALS['TCA'][$table]['ctrl']['versioning_followPages'])? '<br/>'.$this->doc->icons(3).'<b>'.$LANG->getLL('label_nestedversions').'</b>' : '';
$verElement = $icon.
- '<a href="'.htmlspecialchars($this->doc->backPath.t3lib_extMgm::extRelPath('version').'cm1/index.php?id='.($table==='pages'?$rec_on['uid']:$rec_on['pid']).'&details='.rawurlencode($table.':'.$rec_off['uid']).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
- t3lib_BEfunc::getRecordTitle($table,$rec_off,TRUE).
- '</a>'.
- $versionsInOtherWSWarning.
- $multipleWarning.
- $verWarning;
+ '<a href="'.htmlspecialchars($this->doc->backPath.t3lib_extMgm::extRelPath('version').'cm1/index.php?id='.($table==='pages'?$rec_on['uid']:$rec_on['pid']).'&details='.rawurlencode($table.':'.$rec_off['uid']).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
+ t3lib_BEfunc::getRecordTitle($table,$rec_off,TRUE).
+ '</a>'.
+ $versionsInOtherWSWarning.
+ $multipleWarning.
+ $verWarning;
if ($diffCode) {
$verElement = '
<table border="0" cellpadding="0" cellspacing="0" class="ver-verElement">
Index: typo3/sysext/cms/tslib/class.tslib_fe.php
===================================================================
--- typo3/sysext/cms/tslib/class.tslib_fe.php (revision 2255)
+++ typo3/sysext/cms/tslib/class.tslib_fe.php (working copy)
@@ -734,7 +734,6 @@
// Initialize the page-select functions to check rootline:
$temp_sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
$temp_sys_page->init($this->showHiddenPage);
-
// If root line contained NO records and ->error_getRootLine_failPid tells us that it was because of a pid=-1 (indicating a "version" record)...:
if (!count($temp_sys_page->getRootLine($this->id,$this->MP)) && $temp_sys_page->error_getRootLine_failPid==-1) {
@@ -966,8 +965,17 @@
// If not rootline we're off...
if (!count($this->rootLine)) {
- $this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')');
- exit;
+ $ws = $this->whichWorkspace();
+ if ($this->sys_page->error_getRootLine_failPid==-1 && $ws) {
+ $this->sys_page->versioningPreview = TRUE;
+ $this->versioningWorkspaceId = $ws;
+ $this->rootLine = $this->sys_page->getRootLine($this->id,$this->MP);
+ }
+ if (!count($this->rootLine)) {
+ $this->printError('The requested page didn\'t have a proper connection to the tree-root! <br /><br />('.$this->sys_page->error_getRootLine.')');
+ exit;
+ }
+ $this->fePreview = 1;
}
// Checking for include section regarding the hidden/starttime/endtime/fe_user (that is access control of a whole subbranch!)
Index: typo3/sysext/version/cm1/index.php
===================================================================
--- typo3/sysext/version/cm1/index.php (revision 2255)
+++ typo3/sysext/version/cm1/index.php (working copy)
@@ -800,8 +800,22 @@
// Get the offline version record and icon:
$rec_off = t3lib_BEfunc::getRecord($table,$rec['uid']);
+
+ // Prepare swap-mode values:
+ if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1) {
+ if ($rec_off['t3ver_swapmode']>0) {
+ $vType = 'branch';
+ } else {
+ $vType = 'page';
+ }
+ } else {
+ $vType = 'element';
+ }
+
+ // Get icon
$icon = t3lib_iconWorks::getIconImage($table, $rec_off, $this->doc->backPath, ' align="top" title="'.t3lib_BEfunc::getRecordIconAltText($rec_off,$table).'"');
- $icon = $this->doc->wrapClickMenuOnIcon($icon, $table, $rec_off['uid'], 1, '', '+edit,view,info,delete');
+ $tempUid = ($table != 'pages' || $vType==='branch' || $GLOBALS['BE_USER']->workspace===0 ? $rec_off['uid'] : $rec_on['uid']);
+ $icon = $this->doc->wrapClickMenuOnIcon($icon, $table, $tempUid, 1, '', '+edit,' . ($table == 'pages' ? 'view,info,' : '') . 'delete');
// Prepare diff-code:
if ($this->MOD_SETTINGS['diff'] || $this->diffOnly) {
@@ -818,17 +832,6 @@
}
} else $diffCode = '';
- // Prepare swap-mode values:
- if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1) {
- if ($rec_off['t3ver_swapmode']>0) {
- $vType = 'branch';
- } else {
- $vType = 'page';
- }
- } else {
- $vType = 'element';
- }
-
switch($vType) {
case 'element':
$swapLabel = ' [Element]';
(2-2/2)