[TASK] Remove unsupported functionality related to workspaces
authorBenjamin Mack <benni@typo3.org>
Thu, 6 Oct 2011 12:22:36 +0000 (14:22 +0200)
committerTolleiv Nietsch <info@tolleiv.de>
Wed, 8 Feb 2012 22:05:19 +0000 (23:05 +0100)
As only element versioning is supported since TYPO3 4.4, all
functions related to branch and page versioning that haven't
been deprecated yet, get deprecated. All related options can
safely be removed, as they don't get noticed anymore by the
current supported code.

Change-Id: Ib1c562f6d1c268e86b0c56e9037d5b754f1f312a
Resolves: #30604
Releases: 4.7
Reviewed-on: http://review.typo3.org/5591
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
t3lib/class.t3lib_befunc.php
t3lib/class.t3lib_page.php
t3lib/class.t3lib_tcemain.php
t3lib/class.t3lib_treeview.php
t3lib/class.t3lib_userauthgroup.php

index 6ff0d7a..2c140a3 100644 (file)
@@ -105,7 +105,7 @@ final class t3lib_BEfunc {
         */
        public static function getRecordWSOL($table, $uid, $fields = '*', $where = '', $useDeleteClause = TRUE, $unsetMovePointers = FALSE) {
                if ($fields !== '*') {
-                       $internalFields = t3lib_div::uniqueList($fields . ',uid,pid' . ($table == 'pages' ? ',t3ver_swapmode' : ''));
+                       $internalFields = t3lib_div::uniqueList($fields . ',uid,pid');
                        $row = self::getRecord($table, $uid, $internalFields, $where, $useDeleteClause);
                        self::workspaceOL($table, $row, -99, $unsetMovePointers);
 
@@ -343,7 +343,6 @@ final class t3lib_BEfunc {
                                        't3ver_oid' => $val['t3ver_oid'],
                                        't3ver_wsid' => $val['t3ver_wsid'],
                                        't3ver_state' => $val['t3ver_state'],
-                                       't3ver_swapmode' => $val['t3ver_swapmode'],
                                        't3ver_stage' => $val['t3ver_stage'],
                                        'backend_layout_next_level' => $val['backend_layout_next_level']
                                );
@@ -373,7 +372,7 @@ final class t3lib_BEfunc {
                        $row = $getPageForRootline_cache[$ident];
                } else {
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                               'pid,uid,title,TSconfig,is_siteroot,storage_pid,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_swapmode,t3ver_stage,backend_layout_next_level',
+                               'pid,uid,title,TSconfig,is_siteroot,storage_pid,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_stage,backend_layout_next_level',
                                'pages',
                                        'uid=' . intval($uid) . ' ' .
                                                        self::deleteClause('pages') . ' ' .
@@ -463,9 +462,6 @@ final class t3lib_BEfunc {
                        if ($record['uid'] === 0) {
                                continue;
                        }
-                       if ($record['_ORIG_pid'] && $record['t3ver_swapmode'] > 0) { // Branch points
-                               $output = ' [#VEP#]' . $output; // Adding visual token - Versioning Entry Point - that tells that THIS position was where the versionized branch got connected to the main tree. I will have to find a better name or something...
-                       }
                        $output = '/' . t3lib_div::fixed_lgd_cs(strip_tags($record['title']), $titleLimit) . $output;
                        if ($fullTitleLimit) {
                                $fullOutput = '/' . t3lib_div::fixed_lgd_cs(strip_tags($record['title']), $fullTitleLimit) . $fullOutput;
@@ -3770,7 +3766,7 @@ final class t3lib_BEfunc {
         * Recently, this function has been modified so it MAY set $row to FALSE. This happens if a version overlay with the move-id pointer is found in which case we would like a backend preview. In other words, you should check if the input record is still an array afterwards when using this function.
         *
         * @param       string          Table name
-        * @param       array           Record array passed by reference. As minimum, the "uid", "pid" and "t3ver_swapmode" (pages) fields must exist! Fake fields cannot exist since the fields in the array is used as field names in the SQL look up. It would be nice to have fields like "t3ver_state" and "t3ver_mode_id" as well to avoid a new lookup inside movePlhOL().
+        * @param       array           Record array passed by reference. As minimum, the "uid" and  "pid" fields must exist! Fake fields cannot exist since the fields in the array is used as field names in the SQL look up. It would be nice to have fields like "t3ver_state" and "t3ver_mode_id" as well to avoid a new lookup inside movePlhOL().
         * @param       integer         Workspace ID, if not specified will use $GLOBALS['BE_USER']->workspace
         * @param       boolean         If TRUE the function does not return a "pointer" row for moved records in a workspace
         * @return      void            (Passed by ref).
@@ -3826,19 +3822,11 @@ final class t3lib_BEfunc {
                                        }
 
                                                // For versions of single elements or page+content, swap UID and PID:
-                                       if ($table !== 'pages' || $wsAlt['t3ver_swapmode'] <= 0) {
-                                               $wsAlt['_ORIG_uid'] = $wsAlt['uid'];
-                                               $wsAlt['uid'] = $row['uid'];
-
-                                                       // Backend css class:
-                                               $wsAlt['_CSSCLASS'] = $table === 'pages' && $wsAlt['t3ver_swapmode'] == 0 ? 'ver-page' : 'ver-element';
-                                       } else { // This is only for page-versions with BRANCH below!
-                                               $wsAlt['_ONLINE_uid'] = $row['uid'];
-
-                                                       // Backend css class:
-                                               $wsAlt['_CSSCLASS'] = 'ver-branchpoint';
-                                               $wsAlt['_SUBCSSCLASS'] = 'ver-branch';
-                                       }
+                                       $wsAlt['_ORIG_uid'] = $wsAlt['uid'];
+                                       $wsAlt['uid'] = $row['uid'];
+
+                                               // Backend css class:
+                                       $wsAlt['_CSSCLASS'] = 'ver-element';
 
                                                // Changing input record to the workspace version alternative:
                                        $row = $wsAlt;
@@ -3962,8 +3950,10 @@ final class t3lib_BEfunc {
         * @param       string          Table name you are checking for. If you don't give the table name ONLY "branch" types are found and returned TRUE. Specifying table you might also get a positive response if the pid is a "page" versioning type AND the table has "versioning_followPages" set.
         * @param       boolean         If set, the keyword "branchpoint" or "first" is not returned by rather the "t3ver_stage" value of the branch-point.
         * @return      mixed           Returns either "branchpoint" (if branch) or "first" (if page) or FALSE if nothing. Alternatively, it returns the value of "t3ver_stage" for the branchpoint (if any)
+        * @deprecated since TYPO3 4.4, will be removed in TYPO3 4.7, as branch versioning is not supported anymore
         */
        public static function isPidInVersionizedBranch($pid, $table = '', $returnStage = FALSE) {
+               t3lib_div::logDeprecatedFunction();
                $rl = self::BEgetRootLine($pid);
                $c = 0;
 
@@ -4004,11 +3994,11 @@ final class t3lib_BEfunc {
        public static function getWorkspaceWhereClause($table, $workspaceId = NULL) {
                $whereClause = '';
 
-               if (is_null($workspaceId)) {
-                       $workspaceId = $GLOBALS['BE_USER']->workspace;
-               }
-
                if (self::isTableWorkspaceEnabled($table)) {
+                       if (is_null($workspaceId)) {
+                               $workspaceId = $GLOBALS['BE_USER']->workspace;
+                       }
+
                        $workspaceId = intval($workspaceId);
                        $pidOperator = ($workspaceId === 0 ? '!=' : '=');
                        $whereClause = ' AND ' . $table . '.t3ver_wsid=' . $workspaceId . ' AND ' . $table . '.pid' . $pidOperator . '-1';
@@ -4022,14 +4012,13 @@ final class t3lib_BEfunc {
         *
         * @param       integer         Workspace ID
         * @param       integer         Page ID
-        * @param       boolean         If set, then all tables and not only "versioning_followPages" are found (except other pages)
         * @return      array           Overview of records
         */
-       public static function countVersionsOfRecordsOnPage($workspace, $pageId, $allTables = FALSE) {
+       public static function countVersionsOfRecordsOnPage($workspace, $pageId) {
                $output = array();
                if ($workspace != 0) {
                        foreach ($GLOBALS['TCA'] as $tableName => $cfg) {
-                               if ($tableName != 'pages' && $cfg['ctrl']['versioningWS'] && ($cfg['ctrl']['versioning_followPages'] || $allTables)) {
+                               if ($tableName != 'pages' && $cfg['ctrl']['versioningWS']) {
 
                                                // Select all records from this table in the database from the workspace
                                                // This joins the online version with the offline version as tables A and B
index 1610c9d..98e6c24 100644 (file)
@@ -1155,21 +1155,14 @@ class t3lib_pageSelect {
                                        $wsAlt['_ORIG_pid'] = $wsAlt['pid']; // Keep the old (-1) - indicates it was a version...
                                        $wsAlt['pid'] = $row['pid']; // Set in the online versions PID.
 
-                                               // "element" and "page" type versions:
                                                // For versions of single elements or page+content, preserve online UID and PID (this will produce true "overlay" of element _content_, not any references)
                                                // For page+content the "_ORIG_uid" should actually be used as PID for selection of tables with "versioning_followPages" enabled.
-                                       if ($table !== 'pages' || $wsAlt['t3ver_swapmode'] <= 0) {
-                                               $wsAlt['_ORIG_uid'] = $wsAlt['uid'];
-                                               $wsAlt['uid'] = $row['uid'];
+                                       $wsAlt['_ORIG_uid'] = $wsAlt['uid'];
+                                       $wsAlt['uid'] = $row['uid'];
 
-                                                       // Translate page alias as well so links are pointing to the _online_ page:
-                                               if ($table === 'pages') {
-                                                       $wsAlt['alias'] = $row['alias'];
-                                               }
-                                       } else {
-                                                       // "branch" versions:
-                                                       // Keeping overlay uid and pid so references are changed. This is only for page-versions with BRANCH below!
-                                               $wsAlt['_ONLINE_uid'] = $row['uid']; // The UID of the versionized record is kept and the uid of the online version is stored
+                                               // Translate page alias as well so links are pointing to the _online_ page:
+                                       if ($table === 'pages') {
+                                               $wsAlt['alias'] = $row['alias'];
                                        }
 
                                                // Changing input record to the workspace version alternative:
@@ -1276,7 +1269,7 @@ class t3lib_pageSelect {
         * @see t3lib_befunc::getWorkspaceVersionOfRecord()
         */
        function getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields = '*', $bypassEnableFieldsCheck = FALSE) {
-               if ($workspace !== 0 && ($table == 'pages' || $GLOBALS['TCA'][$table]['ctrl']['versioningWS'])) {
+               if ($workspace !== 0) {
                                // Have to hardcode it for "pages" table since TCA is not loaded at this moment!
 
                                // Setting up enableFields for version record:
@@ -1363,4 +1356,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_page.php']);
 }
 
-?>
\ No newline at end of file
+?>
index 48f4fd8..529be57 100644 (file)
@@ -499,17 +499,6 @@ class t3lib_TCEmain {
                                                                        } else {
                                                                                $OK = 0;
                                                                        } // If not found in the substArray we must stop the process...
-                                                               } elseif ($pid_value >= 0 && $this->BE_USER->workspace !== 0
-                                                                       && $GLOBALS['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_value, 'uid,t3ver_swapmode')) { // Looks for workspace version of page.
-                                                                               if ($WSdestPage['t3ver_swapmode'] == 0) { // if swapmode is zero, then change pid value.
-                                                                                       $pid_value = $WSdestPage['uid'];
-                                                                               }
-                                                                       }
                                                                }
                                                                $pid_value = intval($pid_value);
 
@@ -710,40 +699,30 @@ class t3lib_TCEmain {
                                                        if (is_array($fieldArray)) {
                                                                if ($status == 'new') {
                                                                        if ($createNewVersion) { // This creates a new version of the record with online placeholder and offline version
-                                                                               $versioningType = ($table === 'pages'
-                                                                                       ? $this->BE_USER->workspaceVersioningTypeGetClosest(-1)
-                                                                                       : -1);
-                                                                               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[$GLOBALS['TCA'][$table]['ctrl']['label']] = '[PLACEHOLDER, WS#' . $this->BE_USER->workspace . ']';
-                                                                                       $this->insertDB($table, $id, $newVersion_placeholderFieldArray, FALSE); // Saving placeholder as 'original'
-
-                                                                                               // For the actual new offline version, set versioning values to point to placeholder:
-                                                                                       $fieldArray['pid'] = -1;
-                                                                                       $fieldArray['t3ver_oid'] = $this->substNEWwithIDs[$id];
-                                                                                       $fieldArray['t3ver_id'] = 1;
-                                                                                       $fieldArray['t3ver_state'] = -1; // Setting placeholder state value for version (so it can know it is currently a new version...)
-                                                                                       $fieldArray['t3ver_label'] = 'First draft version';
-                                                                                       $fieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
-                                                                                       if ($table === 'pages') { // Swap mode set to "branch" so we can build branches for pages.
-                                                                                               $fieldArray['t3ver_swapmode'] = $versioningType;
-                                                                                       }
-                                                                                       $phShadowId = $this->insertDB($table, $id, $fieldArray, TRUE, 0, TRUE); // When inserted, $this->substNEWwithIDs[$id] will be changed to the uid of THIS version and so the interface will pick it up just nice!
-                                                                                       if ($phShadowId) {
-                                                                                                       // Processes fields of the placeholder record:
-                                                                                               $this->triggerRemapAction(
-                                                                                                       $table,
-                                                                                                       $id,
-                                                                                                       array($this, 'placeholderShadowing'),
-                                                                                                       array($table, $phShadowId)
-                                                                                               );
-                                                                                                       // Hold auto-versionized ids of placeholders:
-                                                                                               $this->autoVersionIdMap[$table][$this->substNEWwithIDs[$id]] = $phShadowId;
-                                                                                       }
-                                                                               } else {
-                                                                                       $this->newlog('Versioning type "' . $versioningType . '" was not allowed, so could not create new record.', 1);
+                                                                               $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[$GLOBALS['TCA'][$table]['ctrl']['label']] = '[PLACEHOLDER, WS#' . $this->BE_USER->workspace . ']';
+                                                                               $this->insertDB($table, $id, $newVersion_placeholderFieldArray, FALSE); // Saving placeholder as 'original'
+
+                                                                                       // For the actual new offline version, set versioning values to point to placeholder:
+                                                                               $fieldArray['pid'] = -1;
+                                                                               $fieldArray['t3ver_oid'] = $this->substNEWwithIDs[$id];
+                                                                               $fieldArray['t3ver_id'] = 1;
+                                                                               $fieldArray['t3ver_state'] = -1; // Setting placeholder state value for version (so it can know it is currently a new version...)
+                                                                               $fieldArray['t3ver_label'] = 'First draft version';
+                                                                               $fieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
+                                                                               $phShadowId = $this->insertDB($table, $id, $fieldArray, TRUE, 0, TRUE); // When inserted, $this->substNEWwithIDs[$id] will be changed to the uid of THIS version and so the interface will pick it up just nice!
+                                                                               if ($phShadowId) {
+                                                                                               // Processes fields of the placeholder record:
+                                                                                       $this->triggerRemapAction(
+                                                                                               $table,
+                                                                                               $id,
+                                                                                               array($this, 'placeholderShadowing'),
+                                                                                               array($table, $phShadowId)
+                                                                                       );
+                                                                                               // Hold auto-versionized ids of placeholders:
+                                                                                       $this->autoVersionIdMap[$table][$this->substNEWwithIDs[$id]] = $phShadowId;
                                                                                }
                                                                        } else {
                                                                                $this->insertDB($table, $id, $fieldArray, FALSE, $incomingFieldArray['uid']);
@@ -2590,7 +2569,7 @@ class t3lib_TCEmain {
                                ) { //Used to check language and general editing rights
                                        $data = array();
 
-                                       $nonFields = array_unique(t3lib_div::trimExplode(',', 'uid,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,t3ver_oid,t3ver_wsid,t3ver_id,t3ver_label,t3ver_state,t3ver_swapmode,t3ver_count,t3ver_stage,t3ver_tstamp,' . $excludeFields, 1));
+                                       $nonFields = array_unique(t3lib_div::trimExplode(',', 'uid,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,t3ver_oid,t3ver_wsid,t3ver_id,t3ver_label,t3ver_state,t3ver_count,t3ver_stage,t3ver_tstamp,' . $excludeFields, 1));
 
                                                // $row = $this->recordInfo($table,$uid,'*');
                                        $row = t3lib_BEfunc::getRecordWSOL($table, $uid); // So it copies (and localized) content from workspace...
@@ -2819,7 +2798,7 @@ class t3lib_TCEmain {
                        if ($this->doesRecordExist($table, $uid, 'show')) {
 
                                        // Set up fields which should not be processed. They are still written - just passed through no-questions-asked!
-                               $nonFields = array('uid', 'pid', 't3ver_id', 't3ver_oid', 't3ver_wsid', 't3ver_label', 't3ver_state', 't3ver_swapmode', 't3ver_count', 't3ver_stage', 't3ver_tstamp', 'perms_userid', 'perms_groupid', 'perms_user', 'perms_group', 'perms_everybody');
+                               $nonFields = array('uid', 'pid', 't3ver_id', 't3ver_oid', 't3ver_wsid', 't3ver_label', 't3ver_state', 't3ver_count', 't3ver_stage', 't3ver_tstamp', 'perms_userid', 'perms_groupid', 'perms_user', 'perms_group', 'perms_everybody');
 
                                        // Select main record:
                                $row = $this->recordInfo($table, $uid, '*');
@@ -4394,11 +4373,10 @@ class t3lib_TCEmain {
         * @param       integer         Record uid to versionize
         * @param       string          Version label
         * @param       boolean         If TRUE, the version is created to delete the record.
-        * @param       integer         Indicating "treeLevel" - or versioning type - "element" (-1), "page" (0) or "branch" (>=1)
         * @return      integer         Returns the id of the new version (if any)
         * @see copyRecord()
         */
-       function versionizeRecord($table, $id, $label, $delete = FALSE, $versionizeTree = -1) {
+       function versionizeRecord($table, $id, $label, $delete = FALSE) {
                $id = intval($id);
 
                // Stop any actions if the record is marked to be deleted:
@@ -4409,85 +4387,78 @@ class t3lib_TCEmain {
 
                if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['versioningWS'] && $id > 0) {
                        if ($this->doesRecordExist($table, $id, 'show')) {
-                               if ($this->BE_USER->workspaceVersioningTypeAccess($versionizeTree)) {
 
-                                               // Select main record:
-                                       $row = $this->recordInfo($table, $id, 'pid,t3ver_id,t3ver_state');
-                                       if (is_array($row)) {
-                                               if ($row['pid'] >= 0) { // record must be online record
-                                                       if ($row['t3ver_state'] != 3) { // record must not be placeholder for moving.
-                                                               if (!$delete || !$this->cannotDeleteRecord($table, $id)) {
-
-                                                                               // Look for next version number:
-                                                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                                                               't3ver_id',
-                                                                               $table,
-                                                                               '((pid=-1 && t3ver_oid=' . $id . ') OR uid=' . $id . ')' . $this->deleteClause($table),
-                                                                               '',
-                                                                               't3ver_id DESC',
-                                                                               '1'
-                                                                       );
-                                                                       list($highestVerNumber) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-                                                                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
-
-                                                                               // Look for version number of the current:
-                                                                       $subVer = $row['t3ver_id'] . '.' . ($highestVerNumber + 1);
-
-                                                                               // 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 ($GLOBALS['TCA'][$table]['ctrl']['editlock']) {
-                                                                               $overrideArray[$GLOBALS['TCA'][$table]['ctrl']['editlock']] = 0;
-                                                                       }
-                                                                       if ($table === 'pages') {
-                                                                               $overrideArray['t3ver_swapmode'] = $versionizeTree;
-                                                                       }
+                                       // Select main record:
+                               $row = $this->recordInfo($table, $id, 'pid,t3ver_id,t3ver_state');
+                               if (is_array($row)) {
+                                       if ($row['pid'] >= 0) { // record must be online record
+                                               if ($row['t3ver_state'] != 3) { // record must not be placeholder for moving.
+                                                       if (!$delete || !$this->cannotDeleteRecord($table, $id)) {
+
+                                                                       // Look for next version number:
+                                                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                                                                       't3ver_id',
+                                                                       $table,
+                                                                       '((pid=-1 && t3ver_oid=' . $id . ') OR uid=' . $id . ')' . $this->deleteClause($table),
+                                                                       '',
+                                                                       't3ver_id DESC',
+                                                                       '1'
+                                                               );
+                                                               list($highestVerNumber) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
+                                                               $GLOBALS['TYPO3_DB']->sql_free_result($res);
+
+                                                                       // Look for version number of the current:
+                                                               $subVer = $row['t3ver_id'] . '.' . ($highestVerNumber + 1);
+
+                                                                       // 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 ($GLOBALS['TCA'][$table]['ctrl']['editlock']) {
+                                                                       $overrideArray[$GLOBALS['TCA'][$table]['ctrl']['editlock']] = 0;
+                                                               }
 
-                                                                               // 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 = t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, $table, $id, 'uid') ? FALSE : TRUE;
-                                                                       }
+                                                                       // 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 = t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, $table, $id, 'uid') ? FALSE : TRUE;
+                                                               }
 
-                                                                       if ($workspaceCheck) {
-
-                                                                                       // Create raw-copy and return result:
-                                                                                       // The information of the label to be used for the workspace record
-                                                                                       // as well as the information whether the record shall be removed
-                                                                                       // must be forwarded (creating remove placeholders on a workspace are
-                                                                                       // done by copying the record and override several fields).
-                                                                               $workspaceOptions = array();
-                                                                               if ($delete) {
-                                                                                       $workspaceOptions['delete'] = $delete;
-                                                                                       $workspaceOptions['label'] = $label;
-                                                                               }
-                                                                               return $this->copyRecord_raw($table, $id, -1, $overrideArray, $workspaceOptions);
-                                                                       } else {
-                                                                               $this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize was already a version in the workspace (wsid=' . $this->BE_USER->workspace . ')!', 1);
+                                                               if ($workspaceCheck) {
+
+                                                                               // Create raw-copy and return result:
+                                                                               // The information of the label to be used for the workspace record
+                                                                               // as well as the information whether the record shall be removed
+                                                                               // must be forwarded (creating remove placeholders on a workspace are
+                                                                               // done by copying the record and override several fields).
+                                                                       $workspaceOptions = array();
+                                                                       if ($delete) {
+                                                                               $workspaceOptions['delete'] = $delete;
+                                                                               $workspaceOptions['label'] = $label;
                                                                        }
+                                                                       return $this->copyRecord_raw($table, $id, -1, $overrideArray, $workspaceOptions);
                                                                } else {
-                                                                       $this->newlog('Record cannot be deleted: ' . $this->cannotDeleteRecord($table, $id), 1);
+                                                                       $this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize was already a version in the workspace (wsid=' . $this->BE_USER->workspace . ')!', 1);
                                                                }
                                                        } else {
-                                                               $this->newlog('Record cannot be versioned because it is a placeholder for a moving operation', 1);
+                                                               $this->newlog('Record cannot be deleted: ' . $this->cannotDeleteRecord($table, $id), 1);
                                                        }
                                                } else {
-                                                       $this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize was already a version in archive (pid=-1)!', 1);
+                                                       $this->newlog('Record cannot be versioned because it is a placeholder for a moving operation', 1);
                                                }
                                        } else {
-                                               $this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize did not exist!', 1);
+                                               $this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize was already a version in archive (pid=-1)!', 1);
                                        }
                                } else {
-                                       $this->newlog('The versioning type ' . $versionizeTree . ' mode you requested was not allowed', 1);
+                                       $this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize did not exist!', 1);
                                }
                        } else {
                                $this->newlog('You didnt have correct permissions to make a new version (copy) of this record "' . $table . '" / ' . $id, 1);
@@ -6464,22 +6435,15 @@ class t3lib_TCEmain {
                        $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.
+                               // 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 && $GLOBALS['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;
        }
index 0dfa456..32b370a 100644 (file)
@@ -878,7 +878,7 @@ class t3lib_treeView {
                                // Passing on default <td> class for subelements:
                        if (is_array($row) && $subCSSclass !== '') {
 
-                               if ($this->table === 'pages' && $this->highlightPagesWithVersions && !isset($row['_CSSCLASS']) && count(t3lib_BEfunc::countVersionsOfRecordsOnPage($this->BE_USER->workspace, $row['uid'], TRUE))) {
+                               if ($this->table === 'pages' && $this->highlightPagesWithVersions && !isset($row['_CSSCLASS']) && count(t3lib_BEfunc::countVersionsOfRecordsOnPage($this->BE_USER->workspace, $row['uid']))) {
                                        $row['_CSSCLASS'] = 'ver-versions';
                                }
 
index 748e407..fb145af 100644 (file)
@@ -739,10 +739,6 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
                        // Always for Live workspace AND if live-edit is enabled and tables are completely without versioning it is ok as well.
                if ($this->workspace === 0 || ($this->workspaceRec['live_edit'] && !$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) || $GLOBALS['TCA'][$table]['ctrl']['versioningWS_alwaysAllowLiveEdit']) {
                        return 2; // OK to create for this table.
-               } elseif (t3lib_BEfunc::isPidInVersionizedBranch($pid, $table)) { // Check if records from $table can be created with this PID: Either if inside "branch" versioning type or a "versioning_followPages" table on a "page" versioning type.
-                               // Now, check what the stage of that "page" or "branch" version type is:
-                       $stage = t3lib_BEfunc::isPidInVersionizedBranch($pid, $table, TRUE);
-                       return $this->workspaceCheckStageForCurrent($stage) ? 1 : -1;
                } else {
                        return FALSE; // If the answer is FALSE it means the only valid way to create or edit records in the PID is by versioning
                }
@@ -756,11 +752,14 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
         * @return      boolean         TRUE if OK.
         */
        function workspaceCreateNewRecord($pid, $table) {
-               if ($res = $this->workspaceAllowLiveRecordsInPID($pid, $table)) { // If LIVE records cannot be created in the current PID due to workspace restrictions, prepare creation of placeholder-record
+               if ($res = $this->workspaceAllowLiveRecordsInPID($pid, $table)) {
+                               // If LIVE records cannot be created in the current PID due to workspace restrictions, prepare creation of placeholder-record
                        if ($res < 0) {
-                               return FALSE; // Stage for versioning root point and users access level did not allow for editing
+                                       // Stage for versioning root point and users access level did not allow for editing
+                               return FALSE;
                        }
-               } elseif (!$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { // So, if no live records were allowed, we have to create a new version of this record:
+               } elseif (!$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
+                               // So, if no live records were allowed, we have to create a new version of this record:
                        return FALSE;
                }
                return TRUE;
@@ -775,7 +774,9 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
         * @return      boolean         TRUE if ok.
         */
        function workspaceAllowAutoCreation($table, $id, $recpid) {
-                       // Auto-creation of version: In offline workspace, test if versioning is enabled and look for workspace version of input record. If there is no versionized record found we will create one and save to that.
+                       // Auto-creation of version: In offline workspace, test if versioning is
+                       // enabled and look for workspace version of input record.
+                       // If there is no versionized record found we will create one and save to that.
                if ($this->workspace !== 0 // Only in draft workspaces
                        && !$this->workspaceRec['disable_autocreate'] // Auto-creation must not be disabled.
                        && $GLOBALS['TCA'][$table]['ctrl']['versioningWS'] // Table must be versionizable
@@ -790,7 +791,7 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
 
        /**
         * Checks if an element stage allows access for the user in the current workspace
-        * In workspaces 0 (Live) and -1 (Default draft) access is always granted for any stage.
+        * In live workspace (= 0) access is always granted for any stage.
         * Admins are always allowed.
         * An option for custom workspaces allows members to also edit when the stage is "Review"
         *
@@ -798,17 +799,18 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
         * @return      boolean         TRUE if user is allowed access
         */
        function workspaceCheckStageForCurrent($stage) {
-               $stage = intval($stage);
+                       // always allow for admins
                if ($this->isAdmin()) {
                        return TRUE;
                }
 
-               if ($this->workspace > 0 && t3lib_extMgm::isLoaded('workspaces')) {
+               if ($this->workspace !== 0 && t3lib_extMgm::isLoaded('workspaces')) {
+                       $stage = intval($stage);
                        $stat = $this->checkWorkspaceCurrent();
 
                                // Check if custom staging is activated
                        $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $stat['uid']);
-                       if ($workspaceRec['custom_stages'] > 0 && $stage !== 0 && $stage !== '-10') {
+                       if ($workspaceRec['custom_stages'] > 0 && $stage !== 0 && $stage !== -10) {
 
                                        // Get custom stage record
                                $workspaceStageRec = t3lib_BEfunc::getRecord('sys_workspace_stage', $stage);
@@ -828,7 +830,7 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
                                        }
                                }
                                // only owner is allowed to change records which are "ready to publish"
-                       } elseif ($stage == '-10' || $stage == '-20') {
+                       } elseif ($stage == -10 || $stage == -20) {
                                if ($stat['_ACCESS'] === 'owner') {
                                        return TRUE;
                                } else {
@@ -843,8 +845,9 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
                                }
                        }
                } else {
+                               // Always OK for live workspace.
                        return TRUE;
-               } // Always OK for live and draft workspaces.
+               }
        }
 
        /**
@@ -901,40 +904,15 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
         *                                              -1 = element
         *                                              >1 = branch (deprecated), indicating the "nesting" level
         * @return      boolean         TRUE if OK
+        * @deprecated since TYPO3 4.4, will be removed in TYPO3 4.8 as only element versioning is supported now
         */
        function workspaceVersioningTypeAccess($type) {
-               $retVal = FALSE;
+               t3lib_div::logDeprecatedFunction();
 
                $type = t3lib_utility_Math::forceIntegerInRange($type, -1);
 
-                       // Check if only element versioning is allowed:
-               if ($type != -1) {
-                       return FALSE;
-               }
-
-               if ($this->workspace > 0 && !$this->isAdmin()) {
-                       $stat = $this->checkWorkspaceCurrent();
-                       if ($stat['_ACCESS'] !== 'owner') {
-
-                               switch ((int) $type) {
-                                       case -1:
-                                               $retVal = $this->workspaceRec['vtypes'] & 1 ? FALSE : TRUE;
-                                       break;
-                                       case 0:
-                                               $retVal = $this->workspaceRec['vtypes'] & 2 ? FALSE : TRUE;
-                                       break;
-                                       default:
-                                               $retVal = $this->workspaceRec['vtypes'] & 4 ? FALSE : TRUE;
-                                       break;
-                               }
-                       } else {
-                               $retVal = TRUE;
-                       }
-               } else {
-                       $retVal = TRUE;
-               }
-
-               return $retVal;
+                       // only element versioning is allowed now
+               return $type == -1;
        }
 
        /**
@@ -943,8 +921,11 @@ abstract class t3lib_userAuthGroup extends t3lib_userAuth {
         * @see workspaceVersioningTypeAccess() for hints on $type
         * @param       integer         Versioning type to evaluation: -1, 0, >1
         * @return      integer         Returning versioning type
+        * @deprecated since TYPO3 4.4, will be removed in TYPO3 4.8 as only element versioning is supported now
         */
        function workspaceVersioningTypeGetClosest($type) {
+               t3lib_div::logDeprecatedFunction();
+
                $type = t3lib_utility_Math::forceIntegerInRange($type, -1);
 
                if ($this->workspace > 0) {