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

ChangeLog
t3lib/class.t3lib_tceforms.php

index f50b72d..e09af78 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-09-18  Steffen Gebert  <steffen@steffen-gebert.de>
 
        * Fixed bug #5983: Undefined variable is used in t3lib_BEfunc::exec_foreign_table_where_query (Thanks to Oliver Klee)
index fa5f593..6506bb4 100644 (file)
@@ -6074,12 +6074,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;
                                }