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 true
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? '
'.$this->doc->icons(3).''.$LANG->getLL('label_multipleversions').'' : '');
$verWarning = $warnAboutVersions || ($warnAboutVersions_nonPages && $GLOBALS['TCA'][$table]['ctrl']['versioning_followPages'])? '
'.$this->doc->icons(3).''.$LANG->getLL('label_nestedversions').'' : '';
$verElement = $icon.
- ''.
- t3lib_BEfunc::getRecordTitle($table,$rec_off,TRUE).
- ''.
- $versionsInOtherWSWarning.
- $multipleWarning.
- $verWarning;
+ ''.
+ t3lib_BEfunc::getRecordTitle($table,$rec_off,TRUE).
+ ''.
+ $versionsInOtherWSWarning.
+ $multipleWarning.
+ $verWarning;
if ($diffCode) {
$verElement = '