More workspace dev.
authorKasper Skårhøj <kasper@typo3.org>
Thu, 27 Oct 2005 18:42:18 +0000 (18:42 +0000)
committerKasper Skårhøj <kasper@typo3.org>
Thu, 27 Oct 2005 18:42:18 +0000 (18:42 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@829 709f56b5-9817-0410-a4d7-c38de5d9e867

TODO.txt
t3lib/class.t3lib_befunc.php
t3lib/class.t3lib_tcemain.php
t3lib/class.t3lib_treeview.php
t3lib/class.t3lib_userauthgroup.php
typo3/class.db_list.inc
typo3/db_new.php
typo3/mod/user/ws/index.php
typo3/sysext/cms/layout/class.tx_cms_layout.php
typo3/tce_db.php

index 3bb7cf7..53a9ff9 100755 (executable)
--- a/TODO.txt
+++ b/TODO.txt
@@ -300,35 +300,50 @@ SQLengine (t3lib_sqlengine):
 *******************************
 Versioning/Workspaces:
 *******************************
+- delete:
+       - something twice? / delete a version, not just unlink it?
+       - unlink a version which has deleted flag must remove that version completely!
 
-- check edit and new permissions....
-- Implement flag in Workspace: Publish only content marked "Publish" stage.
-
-- Complete implementation in TCEmain:
-       COMMANDS:
-       - copy/cut/paste:
-               - between versionized branches and other places (permissions)
-               - check stage of branches and records (permissions)
-               - new records (stage)
-               - Copy a page in workspace will not copy the contents?
-       - localize command
-               - ?
-       - delete:
-               - something twice?
-               - delete a page with a branch, possible?
-               - delete a version, not just unlink it?
-               - Check recursive deletion when setting the delete version and force it when swapping!
-       - versioning:
-               - "branch" (and "page") versioning:(Document this)
-                       - Copy all tables regardless of user "modify" permissions and excludeFields
-                       - Check all subpages for "read" permission (down to specified level) and decline (unless special flag set?)
-
-       - usual permissions, how do they apply? For swapping? For creating new versions? What are the rules? (Document this)
 
-- Documentation "Backend challenges"
+- Implement flag in Workspace:
+       - Publish only content in "Publish" stage
+       - Only workspace owner can publish
+       - Stage change notification ->review (reviewers) ->publish (owner) ->rejection (reviewers and members) + message (goes into log as well)
+
+- Set branch-versioning to 100 by default in versioning API.
+- Way to change versioning type from element to page to branch for new records?
+
+---------------------------------------
+
+Versioning management TODO:
+- Implement more of recent "t3ver_*" fields in display.
+- By default, don't display branch of online version.
+
+Workspace Manager TODO:
+- TODO: Workspace list
+       - Admin features
+- Details view for versions (when clicked)
+       - display change log for specific element?
+       - Also available as a Web >* module / click menu item (another way to browse stuff in need of preview, raise level, log checking etc.)
+- Show log of who raised content levels.
+
+
+----------------------------------------------
+- copy/move:
+       - copying versions:
+               - with references in workspace?
+               - "Page" types?
+               - "Element" types?
+       - Copying depends on "new" versioning type: Element, page, branch!
+       - Check destination if versionized branch / stage
+       - Copy a page in workspace will not copy the contents?
+       - Copy branch in workspace which already has versions - what does it take?
+
+- localize command
+       - ?
+
 ----------------------------
 - Backend challenges yet to solve:
-       - Access evaluation? How does it work, how should it work?
        - FlexForms: t3lib_BEfunc::getFlexFormDS(), workspaceOL/fixVersioningPid ??
        - Page and (User) TSconfig?
        - Mount points and versionized branches?
@@ -345,10 +360,10 @@ Backend preview:
        - Quick Edit in page module should work
 - TemplaVoila:
        - Check up on it (should work)
-- Web > List:
-       - For "page" versions, use different ID for records part of the version.
 - Logging: Filter on workspace
-- Describe best-practice/constaints in "Inside TYPO3"
+
+- Documentation "Backend challenges"
+
 
 Frontend Preview:
 - ONLINE PREVIEW: Versionized pages should be previewed just by their UID (which will select the offline version!) - only in "Live" space, disabled at the moment inside tslib_fe!
@@ -376,17 +391,6 @@ Frontend Preview:
        t3lib_page::getPageOverlay() - because pages_language_overlay records have "versioning_followPages" set this should be observed when selecting language overlay records. But should it be hardcoded or something better?
 - Documentation. As frontend preview implementation is dealt with, describe any persisting incompatibilities in "TYPO3 Core API"
 
-Versioning management TODO:
-- Implement more of recent "t3ver_*" fields in display.
-- By default, don't display branch of online version.
-
-Workspace Manager TODO:
-- TODO: Workspace list
-       - Admin features
-- Implement the disabling of swap-mode on publish links when that is supported in the core (which I think it should be first...?)
-- Details view for versions (when clicked)
-       - display change log for specific element?
-       - Also available as a Web >* module / click menu item (another way to browse stuff in need of preview, raise level, log checking etc.)
 
 Swapping versions:
        - (Support for) swapping using temporary file (instead of using negative ID)
@@ -405,6 +409,7 @@ Workflows:
 
 Documentation:
 - Finish chapter "Using versioning and workspaces" in "Inside TYPO3" with screenshots etc.
+- Documentation "Backend challenges"
 
 -----LATER:
 
index d9a556c..ec7ecd1 100755 (executable)
@@ -791,6 +791,7 @@ class t3lib_BEfunc  {
                                $pageinfo = t3lib_BEfunc::getRecord('pages',$id,'*',($perms_clause ? ' AND '.$perms_clause : ''));
                                if ($pageinfo['uid'] && $GLOBALS['BE_USER']->isInWebMount($id,$perms_clause))   {
                                        t3lib_BEfunc::workspaceOL('pages', $pageinfo);
+                                       t3lib_BEfunc::fixVersioningPid('pages', $pageinfo);
                                        list($pageinfo['_thePath'],$pageinfo['_thePathFull']) = t3lib_BEfunc::getRecordPath(intval($pageinfo['uid']), $perms_clause, 15, 1000);
                                        return $pageinfo;
                                }
@@ -3116,6 +3117,24 @@ class t3lib_BEfunc       {
        }
 
        /**
+        *
+        * @param       string          Table name
+        * @return
+        */
+       function getLiveVersionOfRecord($table,$uid,$fields='*')        {
+               global $TCA;
+
+                       // Check that table supports versioning:
+               if ($TCA[$table] && $TCA[$table]['ctrl']['versioningWS'])       {
+                       $rec = t3lib_BEfunc::getRecord($table,$uid,'pid,t3ver_oid');
+
+                       if ($rec['pid']==-1)    {
+                               return t3lib_BEfunc::getRecord($table,$rec['t3ver_oid'],$fields);
+                       }
+               }
+       }
+
+       /**
         * Will fetch the rootline for the pid, then check if anywhere in the rootline there is a branch point and if so everything is allowed of course.
         * Alternatively; if the page of the PID itself is a version and swapmode is zero (page+content) then tables from versioning_followPages are allowed as well.
         *
@@ -3141,6 +3160,18 @@ class t3lib_BEfunc       {
                }
        }
 
+       /**
+        * Will return where clause de-selecting new-versions from other workspaces.
+        *
+        * @param       string          Table name
+        * @return      string          Where clause if applicable.
+        */
+       function versioningPlaceholderClause($table)    {
+               if ($GLOBALS['BE_USER']->workspace!==0 && $GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['versioningWS'])   {
+                       return ' AND ('.$table.'.t3ver_state!=1 OR '.$table.'.t3ver_wsid='.intval($GLOBALS['BE_USER']->workspace).')';
+               }
+       }
+
 
 
 
index 54faede..7d8549b 100755 (executable)
@@ -606,7 +606,6 @@ class t3lib_TCEmain {
                                                                if ($recordAccess)      {
 
                                                                        if ($res = $this->BE_USER->workspaceAllowLiveRecordsInPID($theRealPid,$table))  {       // If LIVE records cannot be created in the current PID due to workspace restrictions, prepare creation of placeholder-record
-#debug($res,'NEW');
                                                                                if ($res<0)     {
                                                                                        $recordAccess = FALSE;
                                                                                        $this->newlog('Stage for versioning root point and users access level did not allow for editing',1);
@@ -614,7 +613,6 @@ class t3lib_TCEmain {
                                                                        } else {        // So, if no live records were allowed, we have to create a new version of this record:
                                                                                if ($TCA[$table]['ctrl']['versioningWS'])       {
                                                                                        $createNewVersion = TRUE;
-#debug('new version');
                                                                                } else {
                                                                                        $recordAccess = FALSE;
                                                                                        $this->newlog('Record could not be created in this workspace in this branch',1);
@@ -738,6 +736,7 @@ class t3lib_TCEmain {
                                                                                if ($this->BE_USER->workspaceVersioningTypeAccess($versioningType))     {
                                                                                        $newVersion_placeholderFieldArray['t3ver_label'] = 'INITIAL PLACEHOLDER';
                                                                                        $newVersion_placeholderFieldArray['t3ver_state'] = 1;   // Setting placeholder state value for temporary record
+                                                                                       $newVersion_placeholderFieldArray['t3ver_wsid'] = $this->BE_USER->workspace;    // Setting workspace - only so display of place holders can filter out those from other workspaces.
                                                                                        $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['label']] = '[PLACEHOLDER, WS#'.$this->BE_USER->workspace.']';
                                                                                        $this->insertDB($table,$id,$newVersion_placeholderFieldArray,FALSE);    // Saving placeholder as 'original'
 
@@ -2081,14 +2080,21 @@ class t3lib_TCEmain     {
                                                        break;
                                                        case 'delete':
                                                                $delRec = t3lib_BEfunc::getRecord($table, $id);
-                                                               if (is_array($delRec))  {
-                                                                       if ($this->BE_USER->workspaceAllowLiveRecordsInPID($delRec['pid'], $table))     {       // Directly delete:
-                                                                               if ($table === 'pages') {
-                                                                                       $this->deletePages($id);
+                                                               if (is_array($delRec))  {       // Record asked to be deleted was found:
+
+                                                                               // Look, if record is "online" or in a versionized branch, then delete directly.
+                                                                       if ($res = $this->BE_USER->workspaceAllowLiveRecordsInPID($delRec['pid'], $table))      {       // Directly delete:
+                                                                               if ($res>0)     {
+                                                                                       if ($table === 'pages') {
+                                                                                               $this->deletePages($id);
+                                                                                       } else {
+                                                                                               $this->deleteRecord($table,$id);
+                                                                                       }
                                                                                } else {
-                                                                                       $this->deleteRecord($table,$id, 0);
+                                                                                       $this->newlog('Stage of root point did not allow for deletion',1);
                                                                                }
                                                                        } else {
+                                                                               // Otherwise, try to delete by versionization:
                                                                                $this->versionizeRecord($table,$id,'DELETED!',TRUE);
                                                                        }
                                                                }
@@ -2137,14 +2143,25 @@ class t3lib_TCEmain     {
         * @param       boolean         $first is a flag set, if the record copied is NOT a 'slave' to another record copied. That is, if this record was asked to be copied in the cmd-array
         * @param       array           Associative array with field/value pairs to override directly. Notice; Fields must exist in the table record and NOT be among excluded fields!
         * @param       string          Commalist of fields to exclude from the copy process (might get default values)
-        * @return      void
+        * @return      integer         ID of new record, if any
         */
        function copyRecord($table,$uid,$destPid,$first=0,$overrideValues=array(),$excludeFields='')    {
                global $TCA;
 
-               $uid = intval($uid);
+               $uid = $origUid = intval($uid);
                if ($TCA[$table] && $uid)       {
                        t3lib_div::loadTCA($table);
+/*
+                               // In case the record to be moved turns out to be an offline version, we have to find the live version and work on that one (this case happens for pages with "branch" versioning type)
+                       if ($lookForLiveVersion = t3lib_BEfunc::getLiveVersionOfRecord($table,$uid,'uid'))      {
+                               $uid = $lookForLiveVersion['uid'];
+                       }
+                               // Get workspace version of the source record, if any: Then we will copy workspace version instead:
+                       if ($WSversion = t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, $table, $uid, 'uid,t3ver_oid'))   {
+                               $uid = $WSversion['uid'];
+                       }
+                               // Now, the $uid is the actual record we will copy while $origUid is the record we asked to get copied - but that could be a live version.
+*/
                        if ($this->doesRecordExist($table,$uid,'show')) {               // This checks if the record can be selected which is all that a copy action requires.
                                $data = Array();
 
@@ -2227,13 +2244,15 @@ class t3lib_TCEmain     {
                                                // Getting the new UID:
                                        $theNewSQLID = $copyTCE->substNEWwithIDs[$theNewID];
                                        if ($theNewSQLID)       {
-                                               $this->copyMappingArray[$table][$uid] = $theNewSQLID;
+                                               $this->copyMappingArray[$table][$origUid] = $theNewSQLID;
                                        }
 
                                                // Copy back the cached TSconfig
                                        $this->cachedTSconfig = $copyTCE->cachedTSconfig;
                                        $this->errorLog = array_merge($this->errorLog,$copyTCE->errorLog);
                                        unset($copyTCE);
+
+                                       return $theNewSQLID;
                                } else $this->log($table,$uid,3,0,1,'Attempt to copy record that did not exist!');
                        } else $this->log($table,$uid,3,0,1,'Attempt to copy record without permission');
                }
@@ -2268,8 +2287,7 @@ class t3lib_TCEmain       {
                if ($this->admin || in_array('pages',$copyTablesArray)) {
 
                                // Copy this page we're on. And set first-flag (this will trigger that the record is hidden if that is configured)!
-                       $this->copySpecificPage($uid,$destPid,$copyTablesArray,1);
-                       $theNewRootID = $this->copyMappingArray['pages'][$uid];         // This is the new ID of the rootpage of the copy-action. This ID is excluded when the list is gathered lateron
+                       $theNewRootID = $this->copySpecificPage($uid,$destPid,$copyTablesArray,1);
 
                                // If we're going to copy recursively...:
                        if ($theNewRootID && $this->copyTree)   {
@@ -2300,14 +2318,13 @@ class t3lib_TCEmain     {
         * @param       integer         Destination PID: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
         * @param       array           Table on pages to copy along with the page.
         * @param       boolean         $first is a flag set, if the record copied is NOT a 'slave' to another record copied. That is, if this record was asked to be copied in the cmd-array
-        * @return      void
+        * @return      integer         The id of the new page, if applicable.
         */
        function copySpecificPage($uid,$destPid,$copyTablesArray,$first=0)      {
                global $TCA;
 
                        // Copy the page itself:
-               $this->copyRecord('pages',$uid,$destPid,$first);
-               $theNewRootID = $this->copyMappingArray['pages'][$uid]; // The new uid
+               $theNewRootID = $this->copyRecord('pages',$uid,$destPid,$first);
 
                        // If a new page was created upon the copy operation we will proceed with all the tables ON that page:
                if ($theNewRootID)      {
@@ -2319,6 +2336,7 @@ class t3lib_TCEmain       {
                                        }
                                }
                        }
+                       return $theNewRootID;
                }
        }
 
@@ -2629,14 +2647,23 @@ class t3lib_TCEmain     {
        function moveRecord($table,$uid,$destPid)       {
                global $TCA;
 
-                       // Initialize:
-               $sortRow = $TCA[$table]['ctrl']['sortby'];
-               $destPid = intval($destPid);
-               $origDestPid = $destPid;
-
                if ($TCA[$table])       {
+
+                               // In case the record to be moved turns out to be an offline version, we have to find the live version and work on that one (this case happens for pages with "branch" versioning type)
+                       if ($lookForLiveVersion = t3lib_BEfunc::getLiveVersionOfRecord($table,$uid,'uid'))      {
+                               $uid = $lookForLiveVersion['uid'];
+                       }
+
+                               // Get workspace version of the source record, if any:
+                       $WSversion = t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, $table, $uid, 'uid,t3ver_oid');
+
+                               // Initialize:
+                       $sortRow = $TCA[$table]['ctrl']['sortby'];
+                       $destPid = intval($destPid);
+                       $origDestPid = $destPid;
+
                        $propArr = $this->getRecordProperties($table,$uid);     // Get this before we change the pid (for logging)
-                       $resolvedPid = $this->resolvePid($table,$destPid);      // This is the actual pid of the moving.
+                       $resolvedPid = $this->resolvePid($table,$destPid);      // This is the actual pid of the moving to destination
 
                                // Finding out, if the record may be moved from where it is. If the record is a non-page, then it depends on edit-permissions.
                                // If the record is a page, then there are two options: If the page is moved within itself, (same pid) it's edit-perms of the pid. If moved to another place then its both delete-perms of the pid and new-page perms on the destination.
@@ -2646,28 +2673,34 @@ class t3lib_TCEmain     {
                                $mayMoveAccess = $this->doesRecordExist($table,$uid,'delete');
                        }
 
-                               // Finding out, if the record may be moved TO another place. Here we check insert-rights (non-pages = edit, pages = new), unless the pages is moved on the same pid, then edit-rights are checked
+                               // Finding out, if the record may be moved TO another place. Here we check insert-rights (non-pages = edit, pages = new), unless the pages are moved on the same pid, then edit-rights are checked
                        if ($table!='pages' || $resolvedPid!=$propArr['pid'])   {
-                               $mayInsertAccess = $this->checkRecordInsertAccess($table,$resolvedPid,4);       // Edit rights for the record...
+                               $mayInsertAccess = $this->checkRecordInsertAccess($table,$resolvedPid,4);       // Insert rights for the record...
                        } else {
                                $mayInsertAccess = $this->checkRecordUpdateAccess($table,$uid);
                        }
 
                                // Check workspace permissions:
-                       if (!strcmp($propArr['_ORIG_pid'],'') && (int)$propArr['t3ver_state']==1)       {               // Element was an online version AND it was in "New state" so it can be moved...
-                               // Nothing.
+                       $workspaceAccessBlocked = array();
+                       $recIsNewVersion = !strcmp($propArr['_ORIG_pid'],'') && (int)$propArr['t3ver_state']==1;        // Element was an online version AND it was in "New state" so it can be moved...
+                       $destRes = $this->BE_USER->workspaceAllowLiveRecordsInPID($resolvedPid,$table);
+                               // Workspace source check:
+                       if ($errorCode = $this->BE_USER->workspaceCannotEditRecord($table, $WSversion['uid'] ? $WSversion['uid'] : $uid))       {
+                               $workspaceAccessBlocked['src1']='Record could not be edited in workspace: '.$errorCode.' ';
                        } else {
-                               $workspaceAccessBlocked = '';
-                               if ($this->BE_USER->workspaceAllowLiveRecordsInPID($resolvedPid,$table)<=0)     {
-                                       $workspaceAccessBlocked.='Could not insert record from table "'.$table.'" in destination PID "'.$resolvedPid.'" ';
-                               }
-                               if ($this->BE_USER->workspaceAllowLiveRecordsInPID($propArr['pid'],$table)<=0)  {
-                                       $workspaceAccessBlocked.='Could not remove record from table "'.$table.'" from its page "'.$propArr['pid'].'" ';
+                               if (!$recIsNewVersion && $this->BE_USER->workspaceAllowLiveRecordsInPID($propArr['pid'],$table)<=0)     {
+                                       $workspaceAccessBlocked['src2']='Could not remove record from table "'.$table.'" from its page "'.$propArr['pid'].'" ';
                                }
                        }
+                               // Workspace destination check:
+                       if (!($destRes>0 || ($recIsNewVersion && !$destRes)))   {       // All records can be inserted if $destRes is greater than zero. Only new versions can be inserted if $destRes is false. NO RECORDS can be inserted if $destRes is negative which indicates a stage not allowed for use.
+                               $workspaceAccessBlocked['dest1']='Could not insert record from table "'.$table.'" in destination PID "'.$resolvedPid.'" ';
+                       } elseif ($destRes==1 && $WSversion['uid'])     {
+                               $workspaceAccessBlocked['dest2']='Could not insert other versions in destination PID ';
+                       }
 
                                // Checking if the pid is negative, but no sorting row is defined. In that case, find the correct pid. Basically this check make the error message 4-13 meaning less... But you can always remove this check if you prefer the error instead of a no-good action (which is to move the record to its own page...)
-                       if ($destPid<0 && !$sortRow)    {
+                       if (($destPid<0 && !$sortRow) || $destPid>=0)   {       // $destPid>=0 because we must correct pid in case of versioning "page" types.
                                $destPid = $resolvedPid;
                        }
 
@@ -2678,7 +2711,7 @@ class t3lib_TCEmain       {
                        }
 
                                        // If moving is allowed, begin the processing:
-                       if (!$workspaceAccessBlocked)   {
+                       if (!count($workspaceAccessBlocked))    {
                                if ($mayMoveAccess)     {
                                        if ($destPid>=0)        {       // insert as first element on page (where uid = $destPid)
                                                if ($mayInsertAccess)   {
@@ -2692,7 +2725,6 @@ class t3lib_TCEmain       {
                                                                        $sortNumber = $this->getSortNumber($table,$uid,$destPid);
                                                                        $updateFields[$sortRow] = $sortNumber;
                                                                }
-
                                                                        // Create query for update:
                                                                $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($uid), $updateFields);
 
@@ -2763,7 +2795,7 @@ class t3lib_TCEmain       {
                                        $this->log($table,$uid,4,0,1,"Attempt to move record '%s' (%s) without having permissions to do so",14,array($propArr['header'],$table.':'.$uid),$propArr['event_pid']);
                                }
                        } else {
-                               $this->newlog("Move attempt failed due to workspace restrictions: ".$workspaceAccessBlocked);
+                               $this->newlog("Move attempt failed due to workspace restrictions: ".implode(' ',$workspaceAccessBlocked),1);
                        }
                }
        }
@@ -2792,7 +2824,7 @@ class t3lib_TCEmain       {
                                                if (is_array($row))     {
                                                        if ($row[$TCA[$table]['ctrl']['languageField']] <= 0)   {
                                                                if ($row[$TCA[$table]['ctrl']['transOrigPointerField']] == 0)   {
-                                                                       if (!t3lib_BEfunc::getRecordsByField($table,$TCA[$table]['ctrl']['transOrigPointerField'],$uid,'AND pid='.intval($row['pid']).' AND '.$TCA[$table]['ctrl']['languageField'].'='.$langRec['uid']))       {
+                                                                       if (!t3lib_BEfunc::getRecordsByField($table,$TCA[$table]['ctrl']['transOrigPointerField'],$uid,'AND pid='.intval($row['pid']).' AND '.$TCA[$table]['ctrl']['languageField'].'='.intval($langRec['uid'])))       {
 
                                                                                        // Initialize:
                                                                                $overrideValues = array();
@@ -2857,64 +2889,66 @@ class t3lib_TCEmain     {
                $id = intval($id);
 
                if ($TCA[$table] && $TCA[$table]['ctrl']['versioningWS'] && $id>0)      {
-                       if ($this->doesRecordExist($table,$id,'show') && $this->doesRecordExist($table,$id,'edit'))     {
+                       if ($this->doesRecordExist($table,$id,'show'))  {
                                if ($this->BE_USER->workspaceVersioningTypeAccess($versionizeTree))     {
 
                                                // Select main record:
                                        $row = $this->recordInfo($table,$id,'pid,t3ver_id');
                                        if (is_array($row))     {
-                                               if ($row['pid']>=0)     {       // record must be online record.
-
-                                                               // Checking if the record already has a version in the current workspace of the backend user
-                                                       $workspaceCheck = TRUE;
-                                                       if ($this->BE_USER->workspace!==0)      {
-                                                                       // Look for version already in workspace:
-                                                               $workspaceCheck = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                                                                       'uid',
-                                                                       $table,
-                                                                       '(t3ver_oid='.$id.' || uid='.$id.')
-                                                                               AND t3ver_wsid='.intval($this->BE_USER->workspace).
-                                                                               $this->deleteClause($table)
-                                                               ) ? FALSE : TRUE;
-                                                       }
-
-                                                       if ($workspaceCheck)    {
-                                                                       // Look for next version number:
-                                                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                                                       't3ver_id',
-                                                                       $table,
-                                                                       '(t3ver_oid='.$id.' || uid='.$id.')'.$this->deleteClause($table),
-                                                                       '',
-                                                                       't3ver_id DESC',
-                                                                       '1'
-                                                               );
-                                                               list($highestVerNumber) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-
-                                                                       // Look for version number of the current:
-                                                               $subVer = $row['t3ver_id'].'.'.($highestVerNumber+1);
-
-                                                                       // Set up the values to override when making a raw-copy:
-                                                               $overrideArray = array(
-                                                                       't3ver_id' => $highestVerNumber+1,
-                                                                       't3ver_oid' => $id,
-                                                                       't3ver_label' => ($label ? $label : $subVer.' / '.date('d-m-Y H:m:s')),
-                                                                       't3ver_wsid' => $this->BE_USER->workspace,
-                                                                       't3ver_state' => $delete ? 2 : 0,
-                                                                       't3ver_count' => 0,
-                                                                       't3ver_stage' => 0,
-                                                                       't3ver_tstamp' => 0
-                                                               );
-                                                               if ($TCA[$table]['ctrl']['editlock'])   {
-                                                                       $overrideArray[$TCA[$table]['ctrl']['editlock']] = 0;
-                                                               }
-                                                               if ($table==='pages')   {
-                                                                       $overrideArray['t3ver_swapmode'] = $versionizeTree;
+                                               if ($row['pid']>=0)     {       // record must be online record
+                                                       if (!$delete || !$this->cannotDeleteRecord($table,$id)) {
+
+                                                                       // Checking if the record already has a version in the current workspace of the backend user
+                                                               $workspaceCheck = TRUE;
+                                                               if ($this->BE_USER->workspace!==0)      {
+                                                                               // Look for version already in workspace:
+                                                                       $workspaceCheck = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                                                                               'uid',
+                                                                               $table,
+                                                                               '(t3ver_oid='.$id.' || uid='.$id.')
+                                                                                       AND t3ver_wsid='.intval($this->BE_USER->workspace).
+                                                                                       $this->deleteClause($table)
+                                                                       ) ? FALSE : TRUE;
                                                                }
 
-                                                                       // Create raw-copy and return result:
-                                                               return $this->copyRecord_raw($table,$id,-1,$overrideArray);
+                                                               if ($workspaceCheck)    {
+                                                                               // Look for next version number:
+                                                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                                                                               't3ver_id',
+                                                                               $table,
+                                                                               '(t3ver_oid='.$id.' || uid='.$id.')'.$this->deleteClause($table),
+                                                                               '',
+                                                                               't3ver_id DESC',
+                                                                               '1'
+                                                                       );
+                                                                       list($highestVerNumber) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
+
+                                                                               // Look for version number of the current:
+                                                                       $subVer = $row['t3ver_id'].'.'.($highestVerNumber+1);
+
+                                                                               // Set up the values to override when making a raw-copy:
+                                                                       $overrideArray = array(
+                                                                               't3ver_id' => $highestVerNumber+1,
+                                                                               't3ver_oid' => $id,
+                                                                               't3ver_label' => ($label ? $label : $subVer.' / '.date('d-m-Y H:m:s')),
+                                                                               't3ver_wsid' => $this->BE_USER->workspace,
+                                                                               't3ver_state' => $delete ? 2 : 0,
+                                                                               't3ver_count' => 0,
+                                                                               't3ver_stage' => 0,
+                                                                               't3ver_tstamp' => 0
+                                                                       );
+                                                                       if ($TCA[$table]['ctrl']['editlock'])   {
+                                                                               $overrideArray[$TCA[$table]['ctrl']['editlock']] = 0;
+                                                                       }
+                                                                       if ($table==='pages')   {
+                                                                               $overrideArray['t3ver_swapmode'] = $versionizeTree;
+                                                                       }
+
+                                                                               // Create raw-copy and return result:
+                                                                       return $this->copyRecord_raw($table,$id,-1,$overrideArray);
 
-                                                       } else $this->newlog('Record you wanted to versionize was already a version in the workspace (wsid='.$this->BE_USER->workspace.')!',1);
+                                                               } else $this->newlog('Record you wanted to versionize was already a version in the workspace (wsid='.$this->BE_USER->workspace.')!',1);
+                                                       } else $this->newlog('Record cannot be deleted: '.$this->cannotDeleteRecord($table,$id),1);
                                                } else $this->newlog('Record you wanted to versionize was already a version in archive (pid=-1)!',1);
                                        } else $this->newlog('Record you wanted to versionize did not exist!',1);
                                } else $this->newlog('The versioning type '.$versionizeTree.' mode you requested was not allowed',1);
@@ -2935,46 +2969,53 @@ class t3lib_TCEmain     {
                global $TCA;
 
                $uid = intval($uid);
+               $brExist = $this->doesBranchExist('',$uid,$this->pMap['show'],1);       // returns the branch
+
+               if ($brExist != -1)     {       // Checks if we had permissions
 
-                       // Finding list of tables ALLOWED to be copied
-               $allowedTablesArray = $this->admin ? $this->compileAdminTables() : explode(',',$this->BE_USER->groupData['tables_modify']);     // These are the tables, the user may modify
+                               // Finding list of tables ALLOWED to be copied
+                       $allowedTablesArray = $this->admin ? $this->compileAdminTables() : explode(',',$this->BE_USER->groupData['tables_modify']);     // These are the tables, the user may modify
+                       $allowedTablesArray = $this->compileAdminTables();      // These are ALL tables because a new version should be ALL of them regardless of permission of the user executing the request.
 
-                       // Make list of tables that should come along with a new version of the page:
-               $verTablesArray = array();
-               $allTables = array_keys($TCA);
-               foreach($allTables as $tN)      {
-                       if ($tN!='pages' && ($versionizeTree>0 || $TCA[$tN]['ctrl']['versioning_followPages']) && ($this->admin || in_array($tN, $allowedTablesArray))) {
-                               $verTablesArray[] = $tN;
+                               // Make list of tables that should come along with a new version of the page:
+                       $verTablesArray = array();
+                       $allTables = array_keys($TCA);
+                       foreach($allTables as $tN)      {
+                               if ($tN!='pages' && ($versionizeTree>0 || $TCA[$tN]['ctrl']['versioning_followPages']) && ($this->admin || in_array($tN, $allowedTablesArray))) {
+                                       $verTablesArray[] = $tN;
+                               }
                        }
-               }
 
-                       // Begin to copy pages if we're allowed to:
-               if ($this->admin || in_array('pages',$allowedTablesArray))      {
-                       if ($this->BE_USER->workspaceVersioningTypeAccess($versionizeTree))     {
-                                       // Versionize this page:
-                               $theNewRootID = $this->versionizeRecord('pages',$uid,$label,FALSE,$versionizeTree);
-                               $this->rawCopyPageContent($uid,$theNewRootID,$verTablesArray);
-
-                                       // If we're going to copy recursively...:
-                               if ($theNewRootID && $versionizeTree>0) {
-
-                                               // Get ALL subpages to copy (read permissions respected - they should NOT be...):
-                                       $CPtable = $this->int_pageTreeInfo(Array(), $uid, intval($versionizeTree), $theNewRootID);
-
-                                               // Now copying the subpages:
-                                       foreach($CPtable as $thePageUid => $thePagePid) {
-                                               $newPid = $this->copyMappingArray['pages'][$thePagePid];
-                                               if (isset($newPid))     {
-                                                       $theNewRootID = $this->copyRecord_raw('pages',$thePageUid,$newPid);
-                                                       $this->rawCopyPageContent($thePageUid,$theNewRootID,$verTablesArray);
-                                               } else {
-                                                       $this->newlog('Something went wrong during copying branch (for versioning)',1);
-                                                       break;
-                                               }
-                                       }
-                               }       // else the page was not copied. Too bad...
-                       } else $this->newlog('Versioning type "'.$versionizeTree.'" was not allowed in workspace',1);
-               } else $this->newlog('Attempt to versionize page without permission to this table',1);
+                               // Begin to copy pages if we're allowed to:
+                       if ($this->admin || in_array('pages',$allowedTablesArray))      {
+                               if ($this->BE_USER->workspaceVersioningTypeAccess($versionizeTree))     {
+                                               // Versionize this page:
+                                       $theNewRootID = $this->versionizeRecord('pages',$uid,$label,FALSE,$versionizeTree);
+                                       if ($theNewRootID)      {
+                                               $this->rawCopyPageContent($uid,$theNewRootID,$verTablesArray);
+
+                                                       // If we're going to copy recursively...:
+                                               if ($versionizeTree>0)  {
+
+                                                               // Get ALL subpages to copy (read permissions respected - they should NOT be...):
+                                                       $CPtable = $this->int_pageTreeInfo(Array(), $uid, intval($versionizeTree), $theNewRootID);
+
+                                                               // Now copying the subpages:
+                                                       foreach($CPtable as $thePageUid => $thePagePid) {
+                                                               $newPid = $this->copyMappingArray['pages'][$thePagePid];
+                                                               if (isset($newPid))     {
+                                                                       $theNewRootID = $this->copyRecord_raw('pages',$thePageUid,$newPid);
+                                                                       $this->rawCopyPageContent($thePageUid,$theNewRootID,$verTablesArray);
+                                                               } else {
+                                                                       $this->newlog('Something went wrong during copying branch (for versioning)',1);
+                                                                       break;
+                                                               }
+                                                       }
+                                               }       // else the page was not copied. Too bad...
+                                       } else $this->newlog('The root version could not be created!',1);
+                               } else $this->newlog('Versioning type "'.$versionizeTree.'" was not allowed in workspace',1);
+                       } else $this->newlog('Attempt to versionize page without permission to this table',1);
+               } else $this->newlog('Could not read all subpages to versionize.',1);
        }
 
        /**
@@ -3034,99 +3075,109 @@ class t3lib_TCEmain    {
                        if (is_array($curVersion) && is_array($swapVersion))    {
 
                                if ($this->BE_USER->workspacePublishAccess($swapVersion['t3ver_wsid'])) {
-                                       if (!$swapIntoWS || $this->BE_USER->workspaceSwapAccess())      {
-                                               if (!is_array(t3lib_BEfunc::getRecord($table,-$id,'uid')))      {
-
-                                                               // Add "keepfields"
-                                                       $swapVerBaseArray = array();
-                                                       $curVerBaseArray = array();
-                                                       foreach($keepFields as $fN)     {
-                                                               $swapVerBaseArray[$fN] = $curVersion[$fN];
-                                                               $curVerBaseArray[$fN] = $swapVersion[$fN];
-                                                       }
-
-                                                               // Check if the swapWith record really IS a version of the original!
-                                                       if ((int)$swapVersion['pid']==-1 && (int)$curVersion['pid']>=0 && !strcmp($swapVersion['t3ver_oid'],$id))       {
-
-                                                               $sqlErrors=array();
-
-                                                                       // Step 1: Negate ID of online version:
-                                                               $sArray = $curVerBaseArray;
-                                                               $sArray['uid'] = -intval($id);
-                                                               $sArray['t3ver_oid'] = intval($swapWith);
-                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid='.intval($id),$sArray);
-                                                               if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
-
-                                                                       // Step 2: Set online ID for offline version:
-                                                               $sArray = $swapVerBaseArray;
-                                                               $sArray['uid'] = intval($id);
-                                                               $sArray['pid'] = intval($curVersion['pid']);    // Set pid for ONLINE
-                                                               $sArray['t3ver_oid'] = intval($id);
-                                                               $sArray['t3ver_wsid'] = $swapIntoWS ? intval($curVersion['t3ver_wsid']) : 0;
-                                                               $sArray['t3ver_tstamp'] = time();
-                                                               $sArray['t3ver_stage'] = 0;
-                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid='.intval($swapWith),$sArray);
-                                                               if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
-
-                                                                       // Step 3: Set offline id for the previously online version:
-                                                               $sArray = array();
-                                                               $sArray['uid'] = intval($swapWith);
-                                                               $sArray['pid'] = -1;    // Set pid for OFFLINE
-                                                               $sArray['t3ver_oid'] = intval($id);
-                                                               $sArray['t3ver_wsid'] = $swapIntoWS ? intval($swapVersion['t3ver_wsid']) : 0;
-                                                               $sArray['t3ver_tstamp'] = time();
-                                                               $sArray['t3ver_count'] = $curVersion['t3ver_count']+1;  // Increment lifecycle counter
-                                                               $sArray['t3ver_stage'] = 0;
-
-                                                               if ($table==='pages') {         // Keeping the swapmode state
-                                                                       $sArray['t3ver_swapmode'] = $swapVersion['t3ver_swapmode'];
+                                       if ($this->doesRecordExist($table,$swapWith,'show') && $this->checkRecordUpdateAccess($table,$swapWith)) {
+                                               if (!$swapIntoWS || $this->BE_USER->workspaceSwapAccess())      {
+                                                       if (!is_array(t3lib_BEfunc::getRecord($table,-$id,'uid')))      {
+
+                                                                       // Add "keepfields"
+                                                               $swapVerBaseArray = array();
+                                                               $curVerBaseArray = array();
+                                                               foreach($keepFields as $fN)     {
+                                                                       $swapVerBaseArray[$fN] = $curVersion[$fN];
+                                                                       $curVerBaseArray[$fN] = $swapVersion[$fN];
                                                                }
-                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid=-'.intval($id),$sArray);
-                                                               if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
 
-                                                                       // Checking for delete:
-                                                               if ($swapVersion['t3ver_state']==2)     {
-                                                                       if ($table == 'pages')  {
-                                                                               $this->deletePages($id);
-                                                                       } else {
-                                                                               $this->deleteRecord($table,$id, 1);
+                                                                       // Check if the swapWith record really IS a version of the original!
+                                                               if ((int)$swapVersion['pid']==-1 && (int)$curVersion['pid']>=0 && !strcmp($swapVersion['t3ver_oid'],$id))       {
+
+                                                                       $sqlErrors=array();
+
+                                                                               // Step 1: Negate ID of online version:
+                                                                       $sArray = $curVerBaseArray;
+                                                                       $sArray['uid'] = -intval($id);
+                                                                       $sArray['t3ver_oid'] = intval($swapWith);
+                                                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid='.intval($id),$sArray);
+                                                                       if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
+
+                                                                               // Step 2: Set online ID for offline version:
+                                                                       $sArray = $swapVerBaseArray;
+                                                                       $sArray['uid'] = intval($id);
+                                                                       $sArray['pid'] = intval($curVersion['pid']);    // Set pid for ONLINE
+                                                                       $sArray['t3ver_oid'] = intval($id);
+                                                                       $sArray['t3ver_wsid'] = $swapIntoWS ? intval($curVersion['t3ver_wsid']) : 0;
+                                                                       $sArray['t3ver_tstamp'] = time();
+                                                                       $sArray['t3ver_stage'] = 0;
+                                                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid='.intval($swapWith),$sArray);
+                                                                       if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
+
+                                                                               // Step 3: Set offline id for the previously online version:
+                                                                       $sArray = array();
+                                                                       $sArray['uid'] = intval($swapWith);
+                                                                       $sArray['pid'] = -1;    // Set pid for OFFLINE
+                                                                       $sArray['t3ver_oid'] = intval($id);
+                                                                       $sArray['t3ver_wsid'] = $swapIntoWS ? intval($swapVersion['t3ver_wsid']) : 0;
+                                                                       $sArray['t3ver_tstamp'] = time();
+                                                                       $sArray['t3ver_count'] = $curVersion['t3ver_count']+1;  // Increment lifecycle counter
+                                                                       $sArray['t3ver_stage'] = 0;
+
+                                                                       if ($table==='pages') {         // Keeping the swapmode state
+                                                                               $sArray['t3ver_swapmode'] = $swapVersion['t3ver_swapmode'];
+                                                                       }
+                                                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid=-'.intval($id),$sArray);
+                                                                       if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
+
+                                                                               // Checking for delete:
+                                                                       if ($swapVersion['t3ver_state']==2)     {
+                                                                               if ($table == 'pages')  {
+                                                                                       $this->deletePages($id, TRUE);  // Force delete
+                                                                               } else {
+                                                                                       $this->deleteRecord($table,$id,TRUE);   // Force delete
+                                                                               }
+                                                                       }
+                                                                               // Checking for "new-placeholder" and if found, delete it:
+                                                                       if ($curVersion['t3ver_state']==1)      {
+                                                                               if ($table == 'pages')  {
+                                                                                       $this->deletePages($swapWith, TRUE, TRUE);      // Force HARD delete!
+                                                                               } else {
+                                                                                       $this->deleteRecord($table, $swapWith, TRUE, TRUE);     // Force HARD delete!
+                                                                               }
                                                                        }
-                                                               }
 
-                                                               if (!count($sqlErrors)) {
-                                                                       $this->newlog('Swapping successful for table "'.$table.'" uid '.$id.'=>'.$swapWith);
+                                                                       if (!count($sqlErrors)) {
+                                                                               $this->newlog('Swapping successful for table "'.$table.'" uid '.$id.'=>'.$swapWith);
 
-                                                                               // SWAPPING pids for subrecords:
-                                                                       if ($table=='pages' && $swapVersion['t3ver_swapmode']>=0)       {
+                                                                                       // SWAPPING pids for subrecords:
+                                                                               if ($table=='pages' && $swapVersion['t3ver_swapmode']>=0)       {
 
-                                                                                       // Collect table names that should be copied along with the tables:
-                                                                               foreach($TCA as $tN => $tCfg)   {
-                                                                                       if ($swapVersion['t3ver_swapmode']>0 || $TCA[$tN]['ctrl']['versioning_followPages'])    {       // For "Branch" publishing swap ALL, otherwise for "page" publishing, swap only "versioning_followPages" tables
-               #debug($tN,'SWAPPING pids for subrecords:');
-                                                                                               $temporaryPid = -($id+1000000);
+                                                                                               // Collect table names that should be copied along with the tables:
+                                                                                       foreach($TCA as $tN => $tCfg)   {
+                                                                                               if ($swapVersion['t3ver_swapmode']>0 || $TCA[$tN]['ctrl']['versioning_followPages'])    {       // For "Branch" publishing swap ALL, otherwise for "page" publishing, swap only "versioning_followPages" tables
+                       #debug($tN,'SWAPPING pids for subrecords:');
+                                                                                                       $temporaryPid = -($id+1000000);
 
-                                                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN,'pid='.intval($id),array('pid'=>$temporaryPid));
-                                                                                               if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
+                                                                                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN,'pid='.intval($id),array('pid'=>$temporaryPid));
+                                                                                                       if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
 
-                                                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN,'pid='.intval($swapWith),array('pid'=>$id));
-                                                                                               if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
+                                                                                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN,'pid='.intval($swapWith),array('pid'=>$id));
+                                                                                                       if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
 
-                                                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN,'pid='.intval($temporaryPid),array('pid'=>$swapWith));
-                                                                                               if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
+                                                                                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN,'pid='.intval($temporaryPid),array('pid'=>$swapWith));
+                                                                                                       if ($GLOBALS['TYPO3_DB']->sql_error())  $sqlErrors[]=$GLOBALS['TYPO3_DB']->sql_error();
 
-                                                                                               if (count($sqlErrors))  {
-                                                                                                       $this->newlog('During Swapping: SQL errors happend: '.implode('; ',$sqlErrors),2);
+                                                                                                       if (count($sqlErrors))  {
+                                                                                                               $this->newlog('During Swapping: SQL errors happend: '.implode('; ',$sqlErrors),2);
+                                                                                                       }
                                                                                                }
                                                                                        }
                                                                                }
-                                                                       }
-                                                                               // Clear cache:
-                                                                       $this->clear_cache($table,$id);
-
-                                                               } else $this->newlog('During Swapping: SQL errors happend: '.implode('; ',$sqlErrors),2);
-                                                       } else $this->newlog('In swap version, either pid was not -1 or the t3ver_oid didn\'t match the id of the online version as it must!',2);
-                                               } else $this->newlog('Error: A record with a negative UID existed - that indicates some inconsistency in the database from prior versioning actions!',2);
-                                       } else $this->newlog('Workspace #'.$swapVersion['t3ver_wsid'].' does not support swapping.',1);
+                                                                                       // Clear cache:
+                                                                               $this->clear_cache($table,$id);
+
+                                                                       } else $this->newlog('During Swapping: SQL errors happend: '.implode('; ',$sqlErrors),2);
+                                                               } else $this->newlog('In swap version, either pid was not -1 or the t3ver_oid didn\'t match the id of the online version as it must!',2);
+                                                       } else $this->newlog('Error: A record with a negative UID existed - that indicates some inconsistency in the database from prior versioning actions!',2);
+                                               } else $this->newlog('Workspace #'.$swapVersion['t3ver_wsid'].' does not support swapping.',1);
+                                       } else $this->newlog('You cannot publish a record you do not have edit and show permissions for',1);
                                } else $this->newlog('User could not publish records from workspace #'.$swapVersion['t3ver_wsid'],1);
                        } else $this->newlog('Error: Either online or swap version could not be selected!',2);
                } else $this->newlog('Error: You cannot swap versions for a record you do not have access to edit!',1);
@@ -3142,12 +3193,19 @@ class t3lib_TCEmain     {
        function version_clearWSID($table,$id)  {
                if ($errorCode = $this->BE_USER->workspaceCannotEditOfflineVersion($table, $id))        {
                        $this->newlog('Attempt to reset workspace for record failed: '.$errorCode,1);
-               } else {
-                               // Clear workspace ID:
-                       $sArray = array();
-                       $sArray['t3ver_wsid'] = 0;
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid='.intval($id),$sArray);
-               }
+               } elseif ($this->checkRecordUpdateAccess($table,$id)) {
+                       if ($liveRec = t3lib_BEfunc::getLiveVersionOfRecord($table,$id,'uid,t3ver_state'))      {
+                                       // Clear workspace ID:
+                               $sArray = array();
+                               $sArray['t3ver_wsid'] = 0;
+                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid='.intval($id),$sArray);
+
+                                       // Clear workspace ID for live version as well because it is a new record!
+                               if ((int)$liveRec['t3ver_state']===1)   {
+                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid='.intval($liveRec['uid']),$sArray);
+                               }
+                       }
+               } else $this->newlog('Attempt to reset workspace for record failed because you do not have edit access',1);
        }
 
        /**
@@ -3161,7 +3219,7 @@ class t3lib_TCEmain       {
        function version_setStage($table,$id,$stageId)  {
                if ($errorCode = $this->BE_USER->workspaceCannotEditOfflineVersion($table, $id))        {
                        $this->newlog('Attempt to set stage for record failed: '.$errorCode,1);
-               } else {
+               } elseif ($this->checkRecordUpdateAccess($table,$id)) {
                        $stat = $this->BE_USER->checkWorkspaceCurrent();
                        if (t3lib_div::inList('admin,online,offline,reviewer,owner', $stat['_ACCESS']) || ($stageId<=1 && $stat['_ACCESS']==='member')) {
 
@@ -3171,7 +3229,7 @@ class t3lib_TCEmain       {
                                $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($id), $sArray);
                                $this->newlog('Stage for record was changed to '.$stageId);
                        } else $this->newlog('The member user tried to set a stage value "'.$stageId.'" that was not allowed',1);
-               }
+               } else $this->newlog('Attempt to set stage for record failed because you do not have edit access',1);
        }
 
 
@@ -3196,19 +3254,23 @@ class t3lib_TCEmain     {
        /**
         * Deleting a record
         * This function may not be used to delete pages-records unless the underlying records are already deleted
+        * Deletes a record regardless of versioning state (live of offline, doesn't matter, the uid decides)
+        * If both $noRecordCheck and $forceHardDelete are set it could even delete a "deleted"-flagged record!
         *
         * @param       string          Table name
         * @param       integer         Record UID
-        * @param       boolean         Flag: If $noRecordCheck is set, then the function does not check permissions
+        * @param       boolean         Flag: If $noRecordCheck is set, then the function does not check permission to delete record
+        * @param       boolean         If TRUE, the "deleted" flag is ignored if applicable for record and the record is deleted COMPLETELY!
         * @return      void
         */
-       function deleteRecord($table,$uid, $noRecordCheck)      {
+       function deleteRecord($table,$uid, $noRecordCheck=FALSE, $forceHardDelete=FALSE)        {
                global $TCA;
+
                $uid = intval($uid);
                if ($TCA[$table] && $uid)       {
-                       $deleteRow = $TCA[$table]['ctrl']['delete'];
                        if ($noRecordCheck || $this->doesRecordExist($table,$uid,'delete'))     {
-                               if ($deleteRow) {
+                               $deleteRow = $TCA[$table]['ctrl']['delete'];
+                               if ($deleteRow && !$forceHardDelete)    {
                                        $updateFields = array(
                                                $deleteRow => 1
                                        );
@@ -3227,7 +3289,6 @@ class t3lib_TCEmain       {
                                                $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',',$fileFieldArr), $table, 'uid='.intval($uid));
                                                if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres))        {
                                                        $fArray = $fileFieldArr;
-
                                                        foreach($fArray as $theField)   {       // MISSING: Support for MM file relations!
                                                                $this->extFileFunctions($table,$theField,$row[$theField],'deleteAll');          // This deletes files that belonged to this record.
                                                        }
@@ -3254,43 +3315,39 @@ class t3lib_TCEmain     {
         * Used to delete page because it will check for branch below pages and unallowed tables on the page as well.
         *
         * @param       integer         Page id
+        * @param       boolean         If TRUE, pages are not checked for permission.
+        * @param       boolean         If TRUE, the "deleted" flag is ignored if applicable for record and the record is deleted COMPLETELY!
         * @return      void
         */
-       function deletePages($uid)      {
-               if ($this->doesRecordExist('pages',$uid,'delete'))      {       // If we may at all delete this page
-                       if ($this->deleteTree)  {
-                               $brExist = $this->doesBranchExist('',$uid,$this->pMap['delete'],1);     // returns the branch
-                               if ($brExist != -1)     {       // Checks if we had permissions
-                                       if ($this->noRecordsFromUnallowedTables($brExist.$uid)) {
-                                               $uidArray = explode(',',$brExist);
-                                               while (list(,$listUid)=each($uidArray)) {
-                                                       if (trim($listUid))     {
-                                                               $this->deleteSpecificPage($listUid);
-                                                       }
-                                               }
-                                               $this->deleteSpecificPage($uid);
-                                       } else $this->log('pages',$uid,3,0,1,'Attempt to delete records from disallowed tables');
-                               } else $this->log('pages',$uid,3,0,1,'Attempt to delete pages in branch without permissions');
-                       } else {
-                               $brExist = $this->doesBranchExist('',$uid,$this->pMap['delete'],1);     // returns the branch
-                               if ($brExist == '')     {       // Checks if branch exists
-                                       if ($this->noRecordsFromUnallowedTables($uid))  {
-                                               $this->deleteSpecificPage($uid);
-                                       } else $this->log('pages',$uid,3,0,1,'Attempt to delete records from disallowed tables');
-                               } else $this->log('pages',$uid,3,0,1,'Attempt to delete page which has subpages');
+       function deletePages($uid,$force=FALSE,$forceHardDelete=FALSE)  {
+                       // Getting list of pages to delete:
+               if ($force)     {
+                       $brExist = $this->doesBranchExist('',$uid,0,1);         // returns the branch WITHOUT permission checks (0 secures that)
+                       $res = t3lib_div::trimExplode(',',$brExist.$uid,1);
+               } else {
+                       $res = $this->canDeletePage($uid);
+               }
+
+                       // Perform deletion if not error:
+               if (is_array($res))     {
+                       foreach($res as $deleteId)      {
+                               $this->deleteSpecificPage($deleteId,$forceHardDelete);
                        }
-               } else $this->log('pages',$uid,3,0,1,'Attempt to delete page without permissions');
+               } else {
+                       $this->newlog($res,1);
+               }
        }
 
        /**
         * Delete a page and all records on it.
         *
         * @param       integer         Page id
+        * @param       boolean         If TRUE, the "deleted" flag is ignored if applicable for record and the record is deleted COMPLETELY!
         * @return      void
         * @access private
         * @see deletePages()
         */
-       function deleteSpecificPage($uid)       {
+       function deleteSpecificPage($uid,$forceHardDelete=FALSE)        {
                global $TCA;
                reset ($TCA);
                $uid = intval($uid);
@@ -3299,15 +3356,55 @@ class t3lib_TCEmain     {
                                if ($table!='pages')    {
                                        $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, 'pid='.intval($uid).$this->deleteClause($table));
                                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres))     {
-                                               $this->deleteRecord($table,$row['uid'], 1);
+                                               $this->deleteRecord($table,$row['uid'], TRUE, $forceHardDelete);
                                        }
                                }
                        }
-                       $this->deleteRecord('pages',$uid, 1);
+                       $this->deleteRecord('pages',$uid, TRUE, $forceHardDelete);
                }
        }
 
+       /**
+        * Used to evaluate if a page can be deleted
+        *
+        * @param       integer         Page id
+        * @return      mixed           If array: List of page uids to traverse and delete (means OK), if string: error code.
+        */
+       function canDeletePage($uid)    {
+               if ($this->doesRecordExist('pages',$uid,'delete'))      {       // If we may at all delete this page
+                       if ($this->deleteTree)  {
+                               $brExist = $this->doesBranchExist('',$uid,$this->pMap['delete'],1);     // returns the branch
+                               if ($brExist != -1)     {       // Checks if we had permissions
+                                       if ($this->noRecordsFromUnallowedTables($brExist.$uid)) {
+                                               return t3lib_div::trimExplode(',',$brExist.$uid,1);
+                                       } else return 'Attempt to delete records from disallowed tables';
+                               } else return 'Attempt to delete pages in branch without permissions';
+                       } else {
+                               $brExist = $this->doesBranchExist('',$uid,$this->pMap['delete'],1);     // returns the branch
+                               if ($brExist == '')     {       // Checks if branch exists
+                                       if ($this->noRecordsFromUnallowedTables($uid))  {
+                                               return array($uid);
+                                       } else return 'Attempt to delete records from disallowed tables';
+                               } else return 'Attempt to delete page which has subpages';
+                       }
+               } else return 'Attempt to delete page without permissions';
+       }
 
+       /**
+        * Returns true if record CANNOT be deleted, otherwise false. Used to check before the versioning API allows a record to be marked for deletion.
+        *
+        * @param       string          Record Table
+        * @param       integer         Record UID
+        * @return      string          Returns a string IF there is an error (error string explaining). FALSE means record can be deleted
+        */
+       function cannotDeleteRecord($table,$id) {
+               if ($table==='pages')   {
+                       $res = $this->canDeletePage($id);
+                       return is_array($res) ? FALSE : $res;
+               } else {
+                       return $this->doesRecordExist($table,$id,'delete') ? FALSE : 'No permission to delete record';
+               }
+       }
 
 
 
@@ -3788,8 +3885,9 @@ class t3lib_TCEmain       {
 
                while ($dest!=0 && $loopCheck>0)        {
                        $loopCheck--;
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pid, uid', 'pages', 'uid='.intval($dest).$this->deleteClause('pages'));
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pid, uid, t3ver_oid,t3ver_wsid', 'pages', 'uid='.intval($dest).$this->deleteClause('pages'));
                        if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                               t3lib_BEfunc::fixVersioningPid('pages',$row);
                                if ($row['pid']==$id)   {
                                        return FALSE;
                                } else {
@@ -4238,7 +4336,14 @@ class t3lib_TCEmain      {
                        } else {        // Sorting number is inside the list
                                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($sortRow.',pid,uid', $table, 'uid='.abs($pid).$this->deleteClause($table));               // Fetches the record which is supposed to be the prev record
                                if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {       // There was a record
-                                       if ($row['uid']==$uid)  {       // If the record happends to be it self
+
+                                               // Look, if the record UID happens to be an offline record. If so, find its live version. Offline uids will be used when a page is versionized as "branch" so this is when we must correct - otherwise a pid of "-1" and a wrong sort-row number is returned which we don't want.
+                                       if ($lookForLiveVersion = t3lib_BEfunc::getLiveVersionOfRecord($table,$row['uid'],$sortRow.',pid,uid')) {
+                                               $row =  $lookForLiveVersion;
+                                       }
+
+                                               // If the record happends to be it self
+                                       if ($row['uid']==$uid)  {
                                                $sortNumber = $row[$sortRow];
                                        } else {
                                                $subres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
@@ -4801,11 +4906,23 @@ class t3lib_TCEmain     {
         */
        function resolvePid($table,$pid)        {
                global $TCA;
-               $pid=intval($pid);
+               $pid = intval($pid);
                if ($pid < 0)   {
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pid', $table, 'uid='.abs($pid));
                        $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
+
+                               // Look, if the record UID happens to be an offline record. If so, find its live version. Offline uids will be used when a page is versionized as "branch" so this is when we must correct - otherwise a pid of "-1" and a wrong sort-row number is returned which we don't want.
+                       if ($lookForLiveVersion = t3lib_BEfunc::getLiveVersionOfRecord($table,abs($pid),'pid')) {
+                               $row = $lookForLiveVersion;
+                       }
+
                        $pid = intval($row['pid']);
+               } elseif ($this->BE_USER->workspace!==0 && $TCA[$table]['ctrl']['versioning_followPages']) { // PID points to page, the workspace is an offline space and the table follows page during versioning: This means we must check if the PID page has a version in the workspace with swapmode set to 0 (zero = page+content) and if so, change the pid to the uid of that version.
+                       if ($WSdestPage = t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, 'pages', $pid, 'uid,t3ver_swapmode'))    {       // Looks for workspace version of page.
+                               if ($WSdestPage['t3ver_swapmode']==0)   {       // if swapmode is zero, then change pid value.
+                                       $pid = $WSdestPage['uid'];
+                               }
+                       }
                }
                return $pid;
        }
@@ -4868,7 +4985,7 @@ class t3lib_TCEmain       {
                $inList = trim($this->rmComma(trim($inList)));
                if ($inList && !$this->admin)   {
                        while (list($table) = each($TCA))       {
-                               $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid IN ('.$inList.')');
+                               $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid IN ('.$inList.')'.t3lib_BEfunc::deleteClause($table));
                                $count = $GLOBALS['TYPO3_DB']->sql_fetch_row($mres);
                                if ($count[0] && ($this->tableReadOnly($table) || !$this->checkModifyAccessList($table)))       {
                                        return FALSE;
@@ -5147,6 +5264,7 @@ class t3lib_TCEmain       {
         * @return      void            (Will exit on error)
         */
        function printLogErrorMessages($redirect)       {
+
                $res_log = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                                        '*',
                                        'sys_log',
@@ -5155,7 +5273,7 @@ class t3lib_TCEmain       {
                $errorJS = array();
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_log)) {
                        $log_data = unserialize($row['log_data']);
-                       $errorJS[] = $row[error].': '.sprintf($row['details'], $log_data[0],$log_data[1],$log_data[2],$log_data[3],$log_data[4]);
+                       $errorJS[] = $row['error'].': '.sprintf($row['details'], $log_data[0],$log_data[1],$log_data[2],$log_data[3],$log_data[4]);
                }
 
                if (count($errorJS))    {
index 5b925c5..f28c767 100755 (executable)
@@ -845,6 +845,7 @@ class t3lib_treeView {
                                                $this->table,
                                                $this->parentField.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($uid, $this->table).
                                                        t3lib_BEfunc::deleteClause($this->table).
+                                                       t3lib_BEfunc::versioningPlaceholderClause($this->table).
                                                        $this->clause,  // whereClauseMightContainGroupOrderBy
                                                '',
                                                '' //$this->orderByFields // sorting is senseless for count(*) !?!
@@ -909,6 +910,7 @@ class t3lib_treeView {
                                                $this->table,
                                                $this->parentField.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($parentId, $this->table).
                                                        t3lib_BEfunc::deleteClause($this->table).
+                                                       t3lib_BEfunc::versioningPlaceholderClause($this->table).
                                                        $this->clause,  // whereClauseMightContainGroupOrderBy
                                                '',
                                                $this->orderByFields
index 9cb31f3..4869722 100755 (executable)
@@ -631,28 +631,35 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
         *              - or record (any) is in a branch where there is a page which is a version from the workspace and where the stage is not preventing records
         *
         * @param       string          Table of record
-        * @param       array           Record, fields are at least: pid, t3ver_wsid, t3ver_stage (if versioningWS is set)
+        * @param       array           Integer (record uid) or array where fields are at least: pid, t3ver_wsid, t3ver_stage (if versioningWS is set)
         * @return      string          String error code, telling the failure state. FALSE=All ok
         */
-       function workspaceCannotEditRecord($table,$rec) {
+       function workspaceCannotEditRecord($table,$recData)     {
 
                if ($this->workspace!==0)       {       // Only test offline spaces:
-                       if ((int)$rec['pid']===-1)      {       // We are testing a "version" (identified by a pid of -1): it can be edited provided that workspace matches and versioning is enabled for the table.
-                               if (!$GLOBALS['TCA'][$table]['ctrl']['versioningWS'])   {       // No versioning, basic error, inconsistency even! Such records should not have a pid of -1!
-                                       return 'Versioning disabled for table';
-                               } elseif ((int)$rec['t3ver_wsid']!==$this->workspace)   {       // So does workspace match?
-                                       return 'Workspace ID of record didn\'t match current workspace';
-                               } else {        // So what about the stage of the version, does that allow editing for this user?
-                                       return $this->workspaceCheckStageForCurrent($rec['t3ver_stage']) ? FALSE : 'Record stage "'.$rec['t3ver_stage'].'" and users access level did not allow for editing';
-                               }
-                       } else {        // We are testing a "live" record:
-                               if ($res = $this->workspaceAllowLiveRecordsInPID($rec['pid'], $table)) {        // For "Live" records, check that PID for table allows editing
-                                               // Live records are OK in this branch, but what about the stage of branch point, if any:
-                                       return $res>0 ? FALSE : 'Stage for versioning root point and users access level did not allow for editing';     // OK
-                               } else {        // If not offline and not in versionized branch, output error:
-                                       return 'Online record was not in versionized branch!';
-                               }
+
+                       if (!is_array($recData))        {
+                               $recData = t3lib_BEfunc::getRecord($table,$recData,'pid'.($GLOBALS['TCA'][$table]['ctrl']['versioningWS']?',t3ver_wsid,t3ver_stage':''));
                        }
+
+                       if (is_array($recData)) {
+                               if ((int)$recData['pid']===-1)  {       // We are testing a "version" (identified by a pid of -1): it can be edited provided that workspace matches and versioning is enabled for the table.
+                                       if (!$GLOBALS['TCA'][$table]['ctrl']['versioningWS'])   {       // No versioning, basic error, inconsistency even! Such records should not have a pid of -1!
+                                               return 'Versioning disabled for table';
+                                       } elseif ((int)$recData['t3ver_wsid']!==$this->workspace)       {       // So does workspace match?
+                                               return 'Workspace ID of record didn\'t match current workspace';
+                                       } else {        // So what about the stage of the version, does that allow editing for this user?
+                                               return $this->workspaceCheckStageForCurrent($recData['t3ver_stage']) ? FALSE : 'Record stage "'.$recData['t3ver_stage'].'" and users access level did not allow for editing';
+                                       }
+                               } else {        // We are testing a "live" record:
+                                       if ($res = $this->workspaceAllowLiveRecordsInPID($recData['pid'], $table)) {    // For "Live" records, check that PID for table allows editing
+                                                       // Live records are OK in this branch, but what about the stage of branch point, if any:
+                                               return $res>0 ? FALSE : 'Stage for versioning root point and users access level did not allow for editing';     // OK
+                                       } else {        // If not offline and not in versionized branch, output error:
+                                               return 'Online record was not in versionized branch!';
+                                       }
+                               }
+                       } else return 'No record';
                } else {
                        return FALSE;   // OK because workspace is 0
                }
@@ -667,8 +674,8 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
                        if (is_array($recData)) {
                                if ((int)$recData['pid']===-1)  {
                                        return $this->workspaceCannotEditRecord($table,$recData);
-                               } else return "Not an offline version";
-                       } else return "No record";
+                               } else return 'Not an offline version';
+                       } else return 'No record';
                } else return 'Table does not support versioning.';
        }
 
index 925f287..98538c7 100755 (executable)
@@ -441,7 +441,12 @@ class recordList extends t3lib_recordList {
                $queryParts = array(
                        'SELECT' => $fieldList,
                        'FROM' => $table,
-                       'WHERE' => $this->pidSelect.' '.$pC.t3lib_BEfunc::deleteClause($table).' '.$addWhere.' '.$search,
+                       'WHERE' => $this->pidSelect.
+                                               ' '.$pC.
+                                               t3lib_BEfunc::deleteClause($table).
+                                               t3lib_BEfunc::versioningPlaceholderClause($table).
+                                               ' '.$addWhere.
+                                               ' '.$search,
                        'GROUPBY' => '',
                        'ORDERBY' => $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy),
                        'LIMIT' => $limit
index 76648c5..e6e858a 100755 (executable)
@@ -184,6 +184,7 @@ class SC_db_new {
                        // If a page-record was returned, the user had read-access to the page.
                if ($this->pageinfo['uid'])     {
                                // Get record of parent page
+
                        $this->pidInfo=t3lib_BEfunc::getRecord('pages',$this->pageinfo['pid']);
                                // Checking the permissions for the user with regard to the parent page: Can he create new pages, new content record, new page after?
                        if ($BE_USER->doesUserHaveAccess($this->pageinfo,8))    {
@@ -296,7 +297,11 @@ class SC_db_new {
                $tRows = array();
 
                        // New pages INSIDE this pages
-               if ($this->newPagesInto && $this->isTableAllowedForThisPage($this->pageinfo, 'pages') && $BE_USER->check('tables_modify','pages'))      {
+               if ($this->newPagesInto
+                       && $this->isTableAllowedForThisPage($this->pageinfo, 'pages')
+                       && $BE_USER->check('tables_modify','pages')
+                       && $BE_USER->workspaceCreateNewRecord($this->pageinfo['_ORIG_uid']?$this->pageinfo['_ORIG_uid']:$this->id, 'pages')
+                       )       {
 
                                // Create link to new page inside:
                        $t = 'pages';
@@ -379,7 +384,11 @@ class SC_db_new {
                }
 
                        // New pages AFTER this pages
-               if ($this->newPagesAfter && $this->isTableAllowedForThisPage($this->pidInfo,'pages') && $BE_USER->check('tables_modify','pages'))       {
+               if ($this->newPagesAfter
+                       && $this->isTableAllowedForThisPage($this->pidInfo,'pages')
+                       && $BE_USER->check('tables_modify','pages')
+                       && $BE_USER->workspaceCreateNewRecord($this->pidInfo['uid'], 'pages')
+                       )       {
 
                                // Create link to new page after
                        $t = 'pages';
index 37746ed..e1d9144 100755 (executable)
@@ -603,7 +603,7 @@ class SC_mod_user_ws_index extends t3lib_SCbase {
                                                                        $versionsInOtherWS = $this->versionsInOtherWS($table, $rec_on['uid']);
                                                                        $versionsInOtherWSWarning = $versionsInOtherWS && $GLOBALS['BE_USER']->workspace!==0 ? '<br/>'.$this->doc->icons(2).'Other version(s) in workspace '.$versionsInOtherWS : '';
                                                                        $multipleWarning = (!$mainCell && $GLOBALS['BE_USER']->workspace!==0? '<br/>'.$this->doc->icons(3).'<b>Multiple versions in same workspace!</b>' : '');
-                                                                       $verWarning = $warnAboutVersions || $warnAboutVersions_nonPages ? '<br/>'.$this->doc->icons(3).'<b>Version inside version!</b>' : '';
+                                                                       $verWarning = $warnAboutVersions || ($warnAboutVersions_nonPages && $GLOBALS['TCA'][$table]['ctrl']['versioning_followPages'])? '<br/>'.$this->doc->icons(3).'<b>Version inside version!</b>' : '';
                                                                        $verElement = $icon.
                                                                                '<a href="'.htmlspecialchars('index.php?details='.rawurlencode($table.':'.$rec_off['uid'])).'">'.
                                                                                t3lib_BEfunc::getRecordTitle($table,$rec_off,TRUE).
@@ -762,7 +762,7 @@ class SC_mod_user_ws_index extends t3lib_SCbase {
                                                )).'">'.
                                '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/insert1.gif','width="14" height="14"').' alt="" align="top" title="Publish" />'.
                                '</a>';
-                       if ($GLOBALS['BE_USER']->workspaceSwapAccess()) {
+                       if ($GLOBALS['BE_USER']->workspaceSwapAccess() && (int)$rec_on['t3ver_state']!==1 && (int)$rec_off['t3ver_state']!==2)  {
                                $actionLinks.=
                                        '<a href="'.htmlspecialchars($this->doc->issueCommand(
                                                        '&cmd['.$table.']['.$rec_on['uid'].'][version][action]=swap'.
index e85331f..7dd12a4 100755 (executable)
@@ -298,7 +298,7 @@ class tx_cms_layout extends recordList {
 
                                        // Getting children:
                                $theRows = Array();
-                               $theRows = $this->pages_getTree($theRows,$row['uid'],$delClause,'',$depth);
+                               $theRows = $this->pages_getTree($theRows,$row['uid'],$delClause.t3lib_BEfunc::versioningPlaceholderClause('pages'),'',$depth);
                                if ($GLOBALS['BE_USER']->doesUserHaveAccess($row,2))    $editUids[]=$row['uid'];
                                $out.=$this->pages_drawItem($row,$this->fieldArray);
 
@@ -780,7 +780,7 @@ class tx_cms_layout extends recordList {
                        // If page ids were found, select all sys_notes from the page ids:
                $out='';
                if (count($tree->ids))          {
-                       $delClause = t3lib_BEfunc::deleteClause('sys_note');
+                       $delClause = t3lib_BEfunc::deleteClause('sys_note').t3lib_BEfunc::versioningPlaceholderClause('sys_note');
                        $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_note', 'pid IN ('.implode(',',$tree->ids).') AND (personal=0 OR cruser='.intval($GLOBALS['BE_USER']->user['uid']).')'.$delClause);
                        $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
 
@@ -859,7 +859,7 @@ class tx_cms_layout extends recordList {
        function getTable_tt_board($id) {
 
                        // Initialize:
-               $delClause = t3lib_BEfunc::deleteClause('tt_board');
+               $delClause = t3lib_BEfunc::deleteClause('tt_board').t3lib_BEfunc::versioningPlaceholderClause('tt_board');
                $queryParts = $this->makeQueryArray('tt_board', $id, 'AND parent=0');
                $this->setTotalItems($queryParts);
                $dbCount = 0;
index 5466032..1ca0f44 100644 (file)
@@ -65,7 +65,6 @@ require_once (PATH_t3lib.'class.t3lib_tcemain.php');
 
 
 
-
 /**
  * Script Class, creating object of t3lib_TCEmain and sending the posted data to the object.
  * Used by many smaller forms/links in TYPO3, including the QuickEdit module.