Fixed bug #3908: DisplayCond => VERSION:IS:false always returns true (Thanks to Danie...
authorBenni Mack <benni.mack@typo3.org>
Sun, 19 Sep 2010 11:55:08 +0000 (11:55 +0000)
committerBenni Mack <benni.mack@typo3.org>
Sun, 19 Sep 2010 11:55:08 +0000 (11:55 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-2@8814 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tceforms.php

index 70d3bdd..1f162aa 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-09-19  Benjamin Mack  <benni@typo3.org>
+
+       * Fixed bug #3908: DisplayCond => VERSION:IS:false always returns true (Thanks to Daniel Poetzinger)
+
 2010-08-12  Steffen Kamper  <steffen@typo3.org>
 
        * Fixed bug #3819: t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT') delivers wrong value in Backend
index d104879..0d0e4f4 100755 (executable)
@@ -5710,12 +5710,28 @@ class t3lib_TCEforms    {
                                $output = $GLOBALS['BE_USER']->isAdmin() ? TRUE : FALSE;
                        break;
                        case 'VERSION':
-                               switch((string)$parts[1])       {
+                               switch((string)$parts[1]) {
                                        case 'IS':
-                                               if (strtolower($parts[2])=='true')      {
-                                                       $output = intval($row['pid'])==-1 ? TRUE : FALSE;
-                                               } elseif (strtolower($parts[2])=='false') {
-                                                       $output = !(intval($row['pid'])==-1) ? TRUE : FALSE;
+                                               $isNewRecord = (intval($row['uid']) > 0 ? FALSE : TRUE);
+
+                                                       // detection of version can be done be detecting the workspace of the user
+                                               $isUserInWorkspace = ($GLOBALS['BE_USER']->workspace > 0 ? TRUE : FALSE);
+                                               if (intval($row['pid']) == -1 || intval($row['_ORIG_pid']) == -1) {
+                                                       $isRecordDetectedAsVersion = TRUE;
+                                               } else {
+                                                       $isRecordDetectedAsVersion = FALSE;
+                                               }
+
+                                                       // New records in a workspace are not handled as a version record
+                                                       // if it's no new version, we detect versions like this: 
+                                                       // -- if user is in workspace: always true
+                                                       // -- if editor is in live ws: only true if pid == -1
+                                               $isVersion = ($isUserInWorkspace || $isRecordDetectedAsVersion) && !$isNewRecord;
+
+                                               if (strtolower($parts[2]) == 'true') {
+                                                       $output = $isVersion;
+                                               } else if (strtolower($parts[2]) == 'false') {
+                                                       $output = !$isVersion;
                                                }
                                        break;
                                }