* Implemented additional, simple API for logging to sys_log plus extended the sys...
authorKasper Skårhøj <kasper@typo3.org>
Wed, 26 Oct 2005 09:38:43 +0000 (09:38 +0000)
committerKasper Skårhøj <kasper@typo3.org>
Wed, 26 Oct 2005 09:38:43 +0000 (09:38 +0000)
* Implemented more workspace related features. In particular scripts like t3lib_tcemain and t3lib_userauthgroup have been heavily modified!

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@828 709f56b5-9817-0410-a4d7-c38de5d9e867

29 files changed:
ChangeLog
TODO.txt
t3lib/class.t3lib_bedisplaylog.php
t3lib/class.t3lib_befunc.php
t3lib/class.t3lib_page.php
t3lib/class.t3lib_tceforms.php
t3lib/class.t3lib_tcemain.php
t3lib/class.t3lib_treeview.php
t3lib/class.t3lib_tstemplate.php
t3lib/class.t3lib_userauth.php
t3lib/class.t3lib_userauthgroup.php
t3lib/config_default.php
t3lib/stddb/tables.sql
t3lib/stddb/tbl_be.php
typo3/alt_shortcut.php
typo3/class.show_rechis.inc
typo3/db_new.php
typo3/mod/user/ws/index.php
typo3/mod/web/perm/index.php
typo3/sysext/belog/class.tx_belog_webinfo.php
typo3/sysext/belog/mod/index.php
typo3/sysext/cms/ext_tables.php
typo3/sysext/cms/ext_tables.sql
typo3/sysext/cms/layout/class.tx_cms_layout.php
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/lang/locallang_csh_sysws.xml
typo3/sysext/version/cm1/index.php
typo3/template.php

index ebb6ef8..495950a 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-10-26  Kasper Skårhøj  <kasper2005@typo3.com>
+
+       * Implemented additional, simple API for logging to sys_log plus extended the sys-log with workspace awareness.
+       * Implemented more workspace related features. In particular scripts like t3lib_tcemain and t3lib_userauthgroup have been heavily modified!
+
 2005-10-21  Bernhard Kraft  <kraftb@kraftb.at>
 
        * Fixed a bug in t3lib/class.t3lib_page.php which broke the Direct Mailer
        * Fixed a bug in t3lib/jsfunc.menu.js (base URL was also prepended when link is already absolute)
        * Fixed bug #200: fe_adminLib: hard-coded Form URL, should be typolink
 
-2005-10-17  Kasper Skårhøj  <kasper2005@typo3.com>
+2005-10-17  Kasper Skaarhoj  <kasper2005@typo3.com>
 
        * Fixed wrong page-not-found header from "Status: 404 ..." to "HTTP/1.0 404..."
 
 2005-10-15  Michael Stucki  <michael@typo3.org>
 
-       * Added a hook for adding new items in alt_topmenu_dummy.php (requested by Stig N. Færch for his "roles" extension)
+       * Added a hook for adding new items in alt_topmenu_dummy.php (requested by Stig N. Fch for his "roles" extension)
        * Added a JavaScript to the backend which makes it possible to use tabulator keys in textareas. Can be disabled by setting $BE_USER->uc['disableTabInTextarea'].
        * Added template support to indexed_search. Many thanks to Udo von Eynern for his great work!
        * Many other changes to indexed_search. For details, see typo3/sysext/indexed_search/ChangeLog.
 
        * Fixed bug #1594: In t3lib_matchCondition->match() it could be the case that $this->altRootline was not allways an array, but it is supposed to be an array. Therefore at the beginning of t3lib_matchCondition->match() the variable type is checked and an empty array is created if needed.
 
-2005-10-07  Kasper Skårhøj  <kasper2005@typo3.com>
+2005-10-07  Kasper Skaarhoj  <kasper2005@typo3.com>
 
        * Two small friday-afternoon-party changes that I wanted to have fun with a few times: a) In the shortcut frame the "Edit Page ID" field will now let you search the whole database using the list module, b) the list module will wrap any value that is a URL or email address with a link.
 
-2005-10-04  Kasper Skårhøj  <kasper2005@typo3.com>
+2005-10-04  Kasper Skaarhoj  <kasper2005@typo3.com>
 
        * Added initial support for workspaces in core.
        * !!! Notice that all versioning features for tables are now enabled by the [ctrl] directive "versioningWS" and not "versioning". You will have to change this for all custom usages. At the same time you will have to add additional fields that are now mandatory for versioning to work. This is documented in the yet not published TYPO3 Core API for next version. Until the versioning API is final it is recommended to be very careful to apply versioning to custom tables.
 
        * t3lib/class.t3lib_querygenerator.php: Fixed broken database search, originally caused by DBAL changes.
 
-2005-05-22  Kasper Skårhøj  <kasper@typo3.com>
+2005-05-22  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added loginscreen image and colorscheme, upgraded version number.
 
        * Fixed missing email address label if none specified in class.tslib_content.php
        * Fixed missing replacement of "@" in spamProtectEmailAddresses mode in class.tslib_content.php
 
-2005-06-08  Kasper Skårhøj  <kasper@typo3.com>
+2005-06-08  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added TYPO3_CONF_VARS[SYS][USdateFormat] configuration option to turn date-entering into MM-DD-YYYY in backend. Go US!
 
 
        * Fixed bug #0000930: The delete button in QuickEdit mode lead to a 404 message. Thanks to Sebastian Kurfuerst.
 
-2005-05-09  Kasper Skårhøj  <kasper@typo3.com>
+2005-05-09  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Closed Indexed Search before 3.8.0 launch: Despite my hopes I had to significantly lower my ambitions for this release; I couldn't find time to complete the overhaul but had to just patch up any immediate problems and make it work for the 3.8.0 release. The TODO list inside is updated with the remaining tasks which is due for 4.0.0 late summer. If "Indexing Configurations" supporting indexing of external files, URLs and individual records have been mentioned earlier in this changelog or on the featurelist I can inform that the incomplete implementation has been disabled and postponed for 4.0.
 
-2005-05-04  Kasper Skårhøj  <kasper@typo3.com>
+2005-05-04  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added Hindi language
        * Added feature to table-wizard: Will create 5 new rows when adding rows in the bottom of table (configurable)
 
        * Added type path to getText function
 
-2005-04-29  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-29  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added default limit (10kb) on frontend user session data (set by TYPO3_CONF_VARS[FE][maxSessionDataSize]) and added a check that session data is saved only if a cookie is actually set. This closes a quite obvious hole for DoS attacks where requesting a TYPO3 URL something like "...index.php?id=1&recs[foo][bar]=[up to 2000 chars]" would fill 2kb of data into fe_session_data no questions asked. It is not a security problem but thousand such request (with eg. "ab") would mean 2 megabyte of junk in the database... Spamming that table is now considerably more complicated. However this setting might break applications storing large amounts of user session data, but for the average shopping plugin it should be unaffected.
 
-2005-04-29  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-29  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Applied fixes to t3lib_extMgm in order to prevent possible fatal errors where only local extensions would be loaded, resulting in a complete failure of the system (aka "...the cms extension is not loaded" bug). It is unknown if it fixes such problems since the bug is not repeatable.
 
-2005-04-28  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-28  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added API in tslib_pibase for checking availability of the cHash value when plugins are running as USER cObjects. This is a VERY IMPORTANT thing for plugin writers to acquaint themselves with. I suggest reading the article "The Mysteries of &cHash" which was written about this tricky issue.
 
 
        * Added parameter to function in t3lib_install that enables you to write to other localconf's than the canonical.
 
-2005-04-28  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-28  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added search in Extension Manager for extensions locally.
 
 
        * Fixed bug #0000727: Changed some labels for editing Page Header in page and list view
 
-2005-04-27  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-27  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Updated install tool test images again after Stuckis suggestions. Now validates perfectly with this TYPO3 using his debian packages "graphicsmagick" and "graphicsmagick-im-compat"
 
-2005-04-27  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-27  Kasper Skaarhoj  <kasper@typo3.com>
 
        * More implementation of locallang-xml support in frontend
        * Implemented substitution of glossary terms in view_help.php. Glossary is available when the extension "t3glossary" is installed (yet to be released)
 
-2005-04-27  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-27  Kasper Skaarhoj  <kasper@typo3.com>
 
        * When using frontend editing with pop-up window the save-and-view button will not change focus of the windows but keep the editing window on top while reloading the page for preview behind. (Works in any case editing happens in a pop-up window)
 
-2005-04-21 => 04-26  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-21 => 04-26  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added a runaway brake to t3lib_div::expandList(): Ranges are limited to 1000 values per range.
        * Added authentication services (from sysext/sv/) to the core.
        * Re-added images in install tool with binary flag (bug #972).
        * Changed some uses of require to require_once to fix bug #958.
 
-2005-04-12  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-12  Kasper Skaarhoj  <kasper@typo3.com>
 
        * changed install tool comparison images
 
 
        * Added modfunc2 to sysext/indexed_search which offers statistics of entered search words.
 
-2005-04-06  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-06  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Removed all "unsigned" attributes from .sql files in the core and implemented a complete list of those fields for which it has been removed in the t3lib_install class. By default the install tool will NOT detect that these fields should be changed to signed integers since if the field is found in the list in the install class this difference will be ignored. The reason is that it will be 200+ ALTER TABLe changes and the significance is mostly cosmetic. However if somebody wants to actually do the conversion they can switch an internal variable in the t3lib_install class to TRUE and the install tool WILL convert...
 
-2005-04-06  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-06  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Extended a comment of a function in t3lib_extMgm
 
        * Added a preliminary way for moving containers in a flexform section in TCEforms + TCEmain. Before you could only delete containers.
        * Added Sebastian Kurfuerst's collapsable modules feature for the backend's module bar
 
-2005-04-04  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-04  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added to-top/up/down/to_bottom bottoms for the select/group element. up/down will show up by default, to-top and to-bottom will appear automatically when the SIZE of the selector is >= 5.
 
 
        * Fixed a stupid error in the display-empty-tags function
 
-2005-04-01  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-01  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Updated all years from 2004 to 2005
        * Updated all function indexeds in top of scripts (no actual code changes done!)
 
-2005-04-01  Kasper Skårhøj  <kasper@typo3.com>
+2005-04-01  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added Bernhard Krafts security improvement for server validated challenge value.
        * Added "Esperanto" as language - now we are at 41 backend languages.
        * Fixed bug #0000335: in class.t3lib_extfilefunc.php: If $this->dont_use_exec_commands was set, it was impossible to delete any directories, which is now possible again. It's still impossible to delete direcories recursively though.
        * Fixed bug #0000280: pi_list_query() produced wrong query when $orderBy paramater was not given.
 
-2005-03-10  Kasper Skårhøj  <kasper@typo3.com>
+2005-03-10  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added feature that connects cache-control headers with whether user-logins are allowed in a branch or not. Makes mixing of cached and dynamic user-dependant content easier.
 
-2005-03-08  Kasper Skårhøj  <kasper@typo3.com>
+2005-03-08  Kasper Skaarhoj  <kasper@typo3.com>
 
        * New feature for page records: Frontend Login Mode. Makes it possible to disable (and enable later) frontend logins for branches of the page tree. Disabling will make it look like no user is authenticated. This feature is very useful if you wish a highly performant website using cache control headers while specifying sections where user logins are accepted (for dynamic content)
        * Implemented a bunch of hooks in tslib_fe
        * Fixed a typo in the User TSconfig reference in ext_tables_static+adt.sql
        * !!! Renamed t3lib_stdGraphic->imageCreateFromGif into imageCreateFromFile. The old function will remain for providing backwards compatibility.
 
-2005-02-17  Kasper Skårhøj  <kasper@typo3.com>
+2005-02-17  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added 3 hooks for each hardcoded function in css_styled_content so extensions can be written which provides alternative renderings without XCLASSING.
 
-2005-02-15  Kasper Skårhøj  <kasper@typo3.com>
+2005-02-15  Kasper Skaarhoj  <kasper@typo3.com>
 
        * The indexed-search lexer has been updated so it supports "printjoins" (characters like ' or - which are allowed inside of words) and there is also support for Chinese/Japanese/Korean (CJK) indexing/searching.
 
-2005-02-14  Kasper Skårhøj  <kasper@typo3.com>
+2005-02-14  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Large number of updates to system extension indexed_search, in particular to the frontend search plugin which is now ready for implementation of templating engine by workgroup. still missing work on the lexer to support CJK content.
 
 
        * Added a check to class t3lib_htmlmail to check if postfix version 1.x is used. If this is the case the -f parameter is not used for call to mail(). This should fix the problem with mails not being sent when using Postfix as MTA...
 
-2005-01-21  Kasper Skårhøj  <kasper@typo3.com>
+2005-01-21  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added a new feature to force all UIDs in the "impexp" extension.
 
-2005-01-14  Kasper Skårhøj  <kasper@typo3.com>
+2005-01-14  Kasper Skaarhoj  <kasper@typo3.com>
 
        * import/export: CSH for the whole module, localization of all labels
 
-2005-01-02  Kasper Skårhøj  <kasper@typo3.com>
+2005-01-02  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added Karsten D.s patches for DBAL.
 
-2004-12-20  Kasper Skårhøj  <kasper@typo3.com>
+2004-12-20  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Changed "config.disableContentLengthHeader" over to "enableContentLengthHeader" because a default content-length header might introduce some weird and hard-to-debug situation for people.
        * Added possibility to enable cache-control headers on frontend output; This allows a site to be cached by client browsers and proxies. See TSref for configuration ("config.sendCacheHeaders")
        * Fixed bug that gave inconsistent SYS_LASTCHANGED values whether a page was gotten from cache or generated.
        * Added check for explicitAllow/Deny in the content element wizard (during a trainride from Allerd in S-Tog line A to Nrreport - thats all it took).
 
-2004-12-17  Kasper Skårhøj  <kasper@typo3.com>
+2004-12-17  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Mainly: Did tons of improvements on the import/export module (system extension "impexp").
                Main features:
        * Added support for having temporary files in typo3temp/ prefixed with a meaningful prefix, typically coming from the menu title, original image name etc.
 
 
-2004-11-28  Kasper Skårhøj  <kasper@typo3.com>
+2004-11-28  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Main feature: Lots of updates on Indexed Search extension. The changes are mainly in the indexer, not the search plugin. The work is NOT FINISHED yet and don't update a production site with this work! One main thing to be aware of is that all indexing is done internally as utf-8. You should flush your old index tables before running the new one.
        * Fixed bug in t3lib_cs::utf8_strtrunc() (or so)... do'h Martin!
        * TYPO3_CONF_VARS[BE][adminOnly] is now an integer value (was boolean by mistake)
        * Added missing description of 3rd parameter for the crop function in class.tslib_content.php
 
-2004-11-18  Kasper Skårhøj  <kasper@typo3.com>
+2004-11-18  Kasper Skaarhoj  <kasper@typo3.com>
 
        * !!! Moved ALL core localizations into language packs found in extensions prefixed "csh_[language key]". The consequence of this is that the backend will work in english until the proper language pack is installed for the language the user has selected. This step is taken to make backend localization more scalable and prevent the huge memory problems we have with ll-XML and 3.7.0. The "csh_*" extensions are NOT available in TER at the moment, but the whole bunch can be downloaded from http://130.228.0.33/t3dl/src/all_39_language_packs_as_local_extensions.tgz
 
 
        * Implemented #0000508: Minor performance improvement in an if clause in t3lib_stdgraphic, thanks to Volker Graubaum.
 
-2004-11-17  Kasper Skårhøj  <kasper@typo3.com>
+2004-11-17  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Converted locallang*.php to locallang*.xml in new system extensions.
 
 
        * Fixed bug #0000416: Removing spurious DEFAULT '0' in SQL create table statements of uid columns right before they're executed in t3lib_install.
 
-2004-11-16  Kasper Skårhøj  <kasper@typo3.com>
+2004-11-16  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Moved the remaining global extensions to sysext/ which were selected to be system extension.
        * Added configuration option in TYPO3_CONF_VARS[FE][lifetime] so the frontend users cookies can be set to a lifetime in seconds. Currently the cookie lasts only for the browser session and not more.
 
-2004-11-15  Kasper Skårhøj  <kasper@typo3.com>
+2004-11-15  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Merged all changes from "TYPO3_3-7" branch
        * Changed to version 3.8.0-dev
        * Release of TYPO3 3.7.0
        * Increased version number to 3.7.0
 
-2004-09-24  Kasper Skårhøj  <kasper@typo3.com>
+2004-09-24  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Updated backend localizations for 3.7.0 Release
        * Tagging the release with "TYPO3_3-7-0"
 
        * Fixed bug #0000111: Install tool now allows for database name, password and username to contain any kind of chars (not limited to alphanumerical any more).
 
-2004-09-14  Kasper Skårhøj  <kasper@typo3.com>
+2004-09-14  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Updated my email address from "kasper@typo3.com" (which is closed and will stay that way) to "kasperYYYY@typo3.com" which programmers should be able to figure out...
        * Updated all JavaDoc comments and function/class indexes in files, preparing for 3.7.0RC
 
-2004-09-13  Kasper Skårhøj  <kasper@typo3.com>
+2004-09-13  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added CSH for Web>Info/Localization Overview
 
-2004-09-13  Kasper Skårhøj  <kasper@typo3.com>
+2004-09-13  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Changed little more in uniqueList, among others that a fixed number of paramters are supported only now!
 
 
        * Fixed bug in t3lib_div::uniqueList that was caused when t3lib_div::uniqueArray was replaced with array_unique. Obviously array_unique doesn't remove empty values from the array but t3lib_div::uniqueArray did! Please take care of this if you still use this deprecated function in your extension!
 
-2004-09-11  Kasper Skårhøj  <kasper@typo3.com>
+2004-09-11  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Updated changelog for 09/09
        * Fixed bug in stdgraphic::fontResize that made it go into eternal loops if the size could not be obtained in the lower end, basically when fontsize reached zero...
        * Fixed problem with empty URLs in menu generation. Empty URLs may occur when a realurl points to the frontpage (which is a blank suffix to the base url). In such cases the URL now becomes the baseUrl of the site (if that is configured!). This should fix it very specifically for all realurl cases.
        * Fixed install tools incapability to delete files with certain prefixes in typo3temp/ folder.
 
-2004-09-09  Kasper Skårhøj  <kasper@typo3.com>
+2004-09-09  Kasper Skaarhoj  <kasper@typo3.com>
 Sorry for writing these changelog entries with a delay of two days. I write them based on a CVS patch and it took ages to make that from a parking lot in Suresnes, Paris, 4 am in the morning. Its becoming harder to find a stable hotspot in Paris I think... But here we go:
        * Changed all HTTP_*_VARS to $_* superglobals. Also raised PHP requirement version to 4.1.0
        * Added wrapping functions to array browser class. Also updated the Configuration module to use these features so you can now click a key and get a string served ready to implement in eg. localconf.php
@@ -783,34 +788,34 @@ Sorry for writing these changelog entries with a delay of two days. I write them
 
        * Fixed bug #292 concerning Return path in class.t3lib_mailer.php. The fix has a seperate solution for windows and Unix. The unix fix does however not work with safe_mode enabled. Do not know how to overcome this. Perhaps an environment variable for sendmail can be specified? The fix for windows works OK with safe_mode on since, it does not rely on passing parameter directly to the mailer tranport agent (Sendmail or postfix), but instead sets the php variable sendmail_from, which has no effect on Unix systemt.
 
-2004-09-02  Kasper Skårhøj  <kasper@typo3.com>
+2004-09-02  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed a few basic PHP5 problems (aiming at PHP5 support in 3.7.0)
 
-2004-09-02  Kasper Skårhøj  <kasper@typo3.com>
+2004-09-02  Kasper Skaarhoj  <kasper@typo3.com>
 
        * BTW; Just created a hook for page indexing which "indexed_search" will also be using in near future - BUT at the time of this writing it will require a new version of indexed_search for you and that is NOT ready yet - so indexed_search will NOT work for you anymore before you get the new version of this extension!
 
-2004-09-02  Kasper Skårhøj  <kasper@typo3.com>
+2004-09-02  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added Catalan, Bosnian and Korean languages.
 
-2004-08-29  Kasper Skårhøj  <kasper@typo3.com>
+2004-08-29  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added a wildcard like option for values in the "language" condition in frontend (matchcondition class). Can now match any language found in the HTTP_ACCEPT_LANGUAGE value.
 
-2004-08-29  Kasper Skårhøj  <kasper@typo3.com>
+2004-08-29  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added "lockIP" setting for backend users - this will solve the problem that some has reported about backend users not being able to login with 3.7.0...
        * Added new HMENU special type, "language", which can generate a language selector using the "&L" variable directly.
        * Added option for HMENU (protectLvar) so menu items linking to pages that are not translated will have their "&L" var set to zero, thus reverting to the default language.
        * Corrected a bug in menu generation: Spacers for TMENU had a link around it - this was a bug, correct now. No links on spacer elements!
 
-2004-08-26  Kasper Skårhøj  <kasper@typo3.com>
+2004-08-26  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Adding editlock icon in Web>Access
 
-2004-08-26  Kasper Skårhøj  <kasperYYYY@typo3.com>
+2004-08-26  Kasper Skaarhoj  <kasperYYYY@typo3.com>
 
        * Bugfix: in browse_links where the record listing contained links to clickmenus:
        * Added "Save and View" support for records which has another language set; For instance content elements and page overlay records will now view the page with the "&L=xx" parameter set to the language they represent.
@@ -825,7 +830,7 @@ Sorry for writing these changelog entries with a delay of two days. I write them
        * Changed calling order of TSFE->getCompressedTCarray() in "index_ts.php": Now it loads before ->getConfigArray(). Should be no difference to anyone except internal processing in tslib_fe which can now access the array a little before it usually could.
        * Added t3lib_cs::convArray() for charset conversion of array contents.
 
-2004-08-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-08-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Implemented versioning API in tcemain plus other places. Still not functional for the broad public (will be in 3.8.0). Missing conceptual testing, implementation in the backend interface (still to be discussed how that is best done and fitting workflow) and not at all in the frontend.
        * Tables configured for versioning by default is pages, tt_content, pages_language_overlay and sys_template
@@ -841,7 +846,7 @@ Sorry for writing these changelog entries with a delay of two days. I write them
                The new version of the Kickstarter that uses these new ways of interaction has the new extension key 'kickstarter' and is already available from typo3xdev CVS.
                The old version of the Kickstarter having the key 'extrep_wizard' is not used anymore.
 
-2004-08-21  Kasper Skårhøj  <kasper@typo3.com>
+2004-08-21  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added support for backend initialization in PHP shell scripts. Interesting for deamons, cronjobs etc where you want a PHP script to run from shell but with a full backend environment. Documented in next version of Inside TYPO3.
        * Configurable multiplication of DB field size (useful for resizing database for UTf-8 support)
@@ -875,7 +880,7 @@ Sorry for writing these changelog entries with a delay of two days. I write them
 
        * Corrected wrong parameter order for some implode function calls.
 
-2004-08-07  Kasper Skårhøj  <kasper@typo3.com>
+2004-08-07  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added three new permission modes for backend users: 1) Localization access control, 2) Access control on value level (for instance allow/deny individual selectorbox values), 3) API for custom permission options.
        * Implemented control of these modes in tcemain, tceforms and alt_doc.php + QuickEdit. Still need to implement it for edit icons around, but this is not critical, mostly a usability issue.
@@ -884,15 +889,15 @@ Sorry for writing these changelog entries with a delay of two days. I write them
        * Finished the accessListRenderMode(s) (see 4/8 below)
        * Still unsettled about various default settings related to these new options, but will discuss on dev-list.
 
-2004-08-04  Kasper Skårhøj  <kasper@typo3.com>
+2004-08-04  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added new rendering modes for the "select" type in TCA: You can now render multiple-select lists as either a SINGLE selector box with multiple value selection OR as a list of checkboxes. For mozilla even the icons are rendered nicely in the option tags. Check out the backend user group configurations. Work is still in progress.
 
-2004-08-04  Kasper Skårhøj  <kasper@typo3.com>
+2004-08-04  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added TYPo3_CONF_VARS[FE][lockHashKeyWords] so it is optional to lock FE user sessions to HTTP_USER_AGENT
 
-2004-08-03  Kasper Skårhøj  <kasper@typo3.com>
+2004-08-03  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added and Changed features around page languages. More to come including a document guiding people about charsets and localization.
 
@@ -900,7 +905,7 @@ Sorry for writing these changelog entries with a delay of two days. I write them
 
        * Added support for other transfer encodings in the dmailer class. Will start to move the t3lib_directmailer class out of the core and into the direct_mail extension.
 
-2004-07-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-07-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added the Core CVS rules to repository at "misc/core_cvs_rules.txt". ALL Contributers to the CORE CVS SHOULD READ AND FOLLOW THIS!
 
@@ -921,7 +926,7 @@ Sorry for writing these changelog entries with a delay of two days. I write them
 
        * Fixed bug #0000191: Small typo in German translation
 
-2004-06-28  Kasper Skårhøj  <kasper@typo3.com>
+2004-06-28  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Moved creation of menu graphics, scaled images, gifbuilder images and temporary image files into subfolders of typo3temp/
        * Fixed case-folding-cache-file bug in t3lib_cs...
@@ -931,7 +936,7 @@ Sorry for writing these changelog entries with a delay of two days. I write them
 
        * Fixed bug #0000119: Another fe_adminLib htmlspecialchars() issue
 
-2004-06-19  Kasper Skårhøj  <kasper@typo3.com>
+2004-06-19  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Moved CSH locallang-XML labels into extensions prefixed "csh_".
 
@@ -956,51 +961,51 @@ Sorry for writing these changelog entries with a delay of two days. I write them
        * Fixed bug #0000070: Number of files (file count) displayed in file list module was one number too high ("5 Files" although 4 only exist). Updated typo3/class.file_list.inc
        * Changed one line in media/scripts/plaintextLib.inc which caused a "page not found" in some e-mail clients.
 
-2004-06-06  Kasper Skårhøj  <kasper@typo3.com>
+2004-06-06  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Changed all locallang files from "lang" system extension into the new locallang-XML format instead. Includes changes to a bunch of core scripts which had to include the new files with an API function from the $LANG object.
 
-2004-06-06  Kasper Skårhøj  <kasper@typo3.com>
+2004-06-06  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added "groupChangeMask" option in TYPO3_CONF_VARS - makes it possible to set which group newly created files and folders will get. (Thanks to Stucki)
 
-2004-06-03  Kasper Skårhøj  <kasper@typo3.com>
+2004-06-03  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added API for configuring tables (ending on "cache") that are flushed together with "Clear All Cache".
        * Fixed that the Admin Panel is always on top (z-index : 0;
 
-2004-06-03  Kasper Skårhøj  <kasper@typo3.com>
+2004-06-03  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added base url to typo3 error dialog in frontend. Means it shows logo when using realurls now.
        * Added "READFILE:" prefix for pageNotFound handler in frontend; This will read the contents of an html file and output with substitution of a few marker strings.
        * Added feature in page tree; Temporary mounting a point in the users page tree as root. (available in the "More options..." - needs upgrade of that extension as well...).
        * Fixed frontend edit icons under real-url conditions. They didn't work in MSIE. Had to prefix them with base url.
 
-2004-05-29  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-29  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed bug; All page types (doktype) was shown to uses even if they were not all in their list of possible type values.
 
-2004-05-29  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-29  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Created a new DEFAULT backend module called "manual". It shows a TOC of CSH items from the system. This will provide a "user sensitive" manual inside of TYPO3 with localized content to the extend that translators has translated CSH labels in the system. The vision is that the Documentation Team will develop CSH content so far that this will become a really good inline reference for users of TYPO3. Also, extension authors are encouraged to implement CSH for their tables and backend modules and let that be the user manual for their products!
 
-2004-05-28  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-28  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added new CSH entries at various places using a new method in t3lib_BEfunc. The CSH entries are still empty and needs to be completed.
 
-2004-05-28  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-28  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added visual response to backend module selection in the menus; The class attribute of the menu items is changed when a module is selected. The default stylesheet is modified so this results in the current module being highlighted in the menu.
 
-2004-05-27  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-27  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed various things in file processing, t3lib_extFileFunc et al.
 
-2004-05-24  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-24  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added API for custom RTE transformations. Documented in upcoming "TYPO3 Core API".
 
-2004-05-20  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-20  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed remaining issues with styles in the backend regarding the TCEforms. There has been added additional possibilities of styling forms, now with classes in stylesheets, using $TBE_STYLES to set them up. Documentation of $TBE_STYLES for TCeforms has been updated in TYPo3 Core Api as well.
 
@@ -1010,196 +1015,196 @@ Sorry for writing these changelog entries with a delay of two days. I write them
                #83: On non open_basedir'ed systems check if IM executables exist before trying to execut them.
                #95: Use ini_get() instead of get_cfg_var()
 
-2004-05-19  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-19  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed stylesheet issues in Extension Manager.
 
-2004-05-19  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-19  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Finally fixed typo3/show_item.php and typo3/wizard_colorpicker.php scripts for TYPO3 3.6.0 compliance. Now only extensions and some t3lib/ are missing clean-up.
 
-2004-05-18  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-18  Kasper Skaarhoj  <kasper@typo3.com>
        * Added t3lib_cs::specCharsToASCII() for converting special chars (like umlauts) to their double-byte alternatives in ASCII (like au, oe etc...). Function is NOT finished at all, only added so I could use it for the conversion of filenames in simulateStaticDocuments.
        * TypoScript charset compatibility extended: tslib_cObj::caseshift(), tslib_cObj::substring(), tslib_cObj::crop() uses functions in t3lib_cs now. Also stdWrap.strftime will automatically convert localized string from locale charset (guessed by t3lib_cs) to renderCharset.
        * !!! website charset is now taken from "forceCharset" by default (if found) and in any case the http-header with text/html and charset is sent UNLESS you disable it with "config.disableCharsetHeader=1". You will probably have to disable this header if you are using TYPO3 for XML feeds or wap-pages.
        * Added "config.renderCharset" option: This is the charset of the content while rendered in the frontend engine. If different from "metaCharset" a conversion must happen before output to browser. Both renderCharset and metaCharset takes their default values from TYPO3_CONF_VARS[BE][forceCharset] if found, otherwise they default to "iso-8859-1". Also "metaCharset" takes "renderCharset" as default - and if metaCharset is different from renderCharset a conversion will happen on output.
 
-2004-05-18  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-18  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Created new function, t3lib_div::fixed_lgd_cs(), which should be used in the backend wherever a string is shortend for visual display. This function will truncate the string according to the backend charset (which should of course be set by forceCharset to a fixed value). This new function has also been substituted numerous places in the source of course (hence all the script updates).
 
-2004-05-17  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-17  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Moved "install" extension to be a sys extension in sysext/
 
-2004-05-17  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-17  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Corrected some bugs in t3lib_cs while writing a unit test for it.
 
-2004-05-15  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-15  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Splitted the Install Tool interface parts out from t3lib_install into the class tx_install (in extension "install"). Only things left are logic to update localconf.php files and manage SQL / Database (for Extension Manager).
 
-2004-05-11  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-11  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Changed version number to 3.7.0-dev according to newly adopted major.minor.patch version numbering model.
 
-2004-05-11  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-11  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Merged branch changes from "TYPO3_3-6-0"; Mainly bugfixes by ingmar.
 
-2004-05-11  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-11  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Rolled back browser detection in matchcondition class.
 
-2004-05-07  Kasper Skårhøj  <kasper@typo3.com>
+2004-05-07  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added "relPathprefix" to TEMPLATE cObject and also added support for relative path substitution of references in url() wrappers in <style> tags. This will also fix THAT problem reported for automaketemplate.
 
-2004-04-30  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-30  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Merged TYPO3_3-6-0 branch changes by robert into HEAD. See 3.6.0 branch change log if you want.
 
-2004-04-27  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-27  Kasper Skaarhoj  <kasper@typo3.com>
 
        * TAG: "TYPO3_3-6-0RC2", BRANCH "TYPO3_3-6-0"
 
-2004-04-26  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-26  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added possibility to prefix references to wizard scripts with "EXT:" for reference to wizard scripts in extension.
 
-2004-04-26  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-26  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added prefix to relative file reference in @import style sheet
 
-2004-04-26  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-26  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed bug where DB mounts for a user which has been deleted would still show up in the page tree.
 
-2004-04-26  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-26  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed bug with pageNotFound handling.
 
-2004-04-26  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-26  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added a PAGE Tsconfig option to disable the automatic clearing of page cache when records are edited.
 
-2004-04-26  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-26  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Updated "cms" extension with most recent labels from TYPO3.org
 
-2004-04-26  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-26  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Updated "lang" extension with most recent labels from TYPO3.org
 
-2004-04-26  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-26  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added Latvian, Japanese and Vietnamese languages
 
-2004-04-24  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-24  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added to TypoScript object browser that the title text of the object links contains information about in which lines in the TypoScript body code that a certain object path is set, cleared, copied.
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added "removeBadHTML" option to stdWrap - this can help to avoid XSS dangerous HTML.
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added feature in TYpoScript data type "getText" to get values from GET arrays via "GPvar" key word. Now you can specify ".date = GPvar : tx_myext|mode|index" to get value of &tx_myext[mode][index]
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added option "$TYPO3_CONF_VARS["GFX"]["gdlib_2"] = 'no_imagecopyresized_fix';" to avoid using the imagecopyresized workaround in stdgraphic class which has failed for some. Whether the workaround is needed anymore is not certain. Some people say it works fine without.
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added TypoScript condition "hostname" for matching hostnames for IP addresses.
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added API for configuring extra tables/fields for listing in Web > Page
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added option "mod.web_list.clickTitleMode = edit/info/show" to determine alternative behaviours of title links in the Web > List module.
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added Page TSconfig option "mod.web_list.listOnlyInSingleTableView = 1" which makes the List module list only the table names by default. You have to click the table name to get the single-table view before records show up. This is useful for pages containing many records from many tables.
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added refresh button to taskcenter (not in core CVS)
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added "Login failure" message in backend login box
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added to user authentication that the HTTP_USER_AGENT is hashed and a part of the session lookup (in other words, if the HTTP_USER_AGENT stays constant the session stays as well). Also added possibility of configuring that the IP adresse used to lock down sessions is only part 1,2,3 or 4 (all) used. Mainly this is easily configurable for frontend users (which has had the "security level" set to "2" now instead of disabled totally!). For backend users I didn't make configuration options in TYPO3_CONF_VARS - just wanted to know if people needed it there first (not to bloat options....)
 
-2004-04-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added possibility of jumping directly to editing a page in the backend. You specify "alt_main.php?edit=[page id]" and you will be brought directly to the page edit module.
 
-2004-04-22  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-22  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added in RTE link box: Searched *into* Content ELements of type Text and Text w/Image after anchors (<a name="...">) and lists them as well with content elements to which an anchor link can be made.
 
-2004-04-22  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-22  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added configuration options for what level of pages cache is cleared when you edit a page header. You can not get children and grand-parents cleared as well. (TCEMAIN.clear..... in Page TSconfig)
 
-2004-04-21  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-21  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added "altText" and "titleText" attributes to the IMGMAP object (used for IMGMENU: Now you can add values to the alt and title attributes of image maps).
        * Added "ATagTitle" attribute for TMENU / GMENU so the menu links can have a title attribute for accessible websites.
        * Added "allStdWrap" attributes for TMENUITEM/GMENU item states. + some other properties requested.
 
-2004-04-21  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-21  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added features around "includeCSS" TypoScript property for PAGE objects: "import" and "alternate" attributes (booleans) are now supported.
 
-2004-04-20  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-20  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Changed a bunch of things, added a few new features to make TYPO3 accessible. One significant thing was the attributes "altText", "titleText" and "longdescURL" for IMAGE, IMGTEXT, FILE and ->filelink() in TypoScript.
 
-2004-04-20  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-20  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Completed changes for XHTML compliance requests from the Accessibility group. Mainly adding support for more XHTML types, adding attributes like xml:lang to <html> tag, support for "dir" attributes in HTML tags, support for writing inline styles and JavaScript to a temporary file to keep a clean HTML <head> section...
 
-2004-04-19  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-19  Kasper Skaarhoj  <kasper@typo3.com>
 
        * "minItems", "maxItems" and "begin" has been added as properties to MENU objects (like TMENU, GMENU, IMGMENU etc) so you can set these values for the individual menus (as they probably should have been in the first place...).
 
-2004-04-19  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-19  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added a checkbox to the page header in the "cms" extension called "Hide in menu". With this checkbox the page is excluded from menus on the totally same terms as doktype=5 ("Not in menu") does. The implementation is believed to be complete (although there might be some places overlooked). The checkbox renders the doktype 5 "Not in menu" obsolete; the idea is that the checkbox should be used in the future. Finally - if anyone read this far - I prophecise, that within two weeks from this moment someone will approach me and want to have a visual response to the "Hide in menu" checkbox in the icon; currently the page icon does NOT change it looks (and it would be very doubtful if we could justify making it change...).
 
-2004-04-19  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-19  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added new FORM cObject type, "label", which inserts a label instead of a field. Also fixed ordering problem when the "dataArray" attribute of FORM is used (now renders the form in the numerical order of the elements instead of order of appearance).
 
-2004-04-19  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-19  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed incompatibility between Mount Points and property "overrideId" in menus.
 
-2004-04-19  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-19  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added support for JavaScript regular expression evaluation in FORM cObject. Means that fields in formmails can now be checked for a pattern and not only for "required".
 
-2004-04-19  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-19  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added possibility to copy database/file elements attached to records; You can now click the icon of these elements in the editing forms and get a (limited) context menu for these elements.
        * Fixed some other bugs around.
 
-2004-04-16  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-16  Kasper Skaarhoj  <kasper@typo3.com>
 
        * fixed detection of schemes (http://, ftp:// etc) in "typolinks". Now email addresses are detected only if NOT prepended with a scheme. Also the presence of a scheme will make typolink function detect the input as a plain URL which should just be passed through untouched.
 
-2004-04-14  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-14  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Mount Points (Mount pages) reworking:
 Changelog:
@@ -1232,90 +1237,90 @@ Fixed bugs in Mount Points / Status:
                * Affected files: t3lib/class.t3lib_stdgraphic.php, typo3/sysext/cms/ext_tables.sql
                * Tested by Ingmar, Michael and Robert
 
-2004-04-01  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-01  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed problem with domain look-up when an extra "/" was added to eg. "typo3.com//" -> showing "typo3.org" instead
 
-2004-04-01  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-01  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed some browser detection bugs in t3lib_matchcondition and t3lib_div. Not necessarily exhaustive! For instance a report on Netscape 7.2 being wrongly detected may not be resolved (need teh value of HTTP_USER_AGENT to solve it since I do not have netscape 7.2!)
 
-2004-04-01  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-01  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added full safety for the internal TYPO3 formmail; email addresses in the fields "recipient" and "recipient_copy" are encrypted in the transfer and the "formmail" interface is safe for spam-misuse (since a proper recipient address cannot be forged automatically).
          !!! If someone is using the "formmail" API from other renderers than the FORM cObject in TypoScript you will have to set the recipient address to the encrypted value by default OR alternatively disabled the check by TYPO3_CONF_VARS[FE][strictFormmail] = FALSE
 
-2004-04-01  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-01  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added Jens Ellerbrocks suggestion for "postUserFuncInt" in stdWrap.
 
-2004-04-01  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-01  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added some file icons from Ben and Emile
 
-2004-04-01  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-01  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added "General Plugin" to content elmeent wizard list.
 
-2004-04-01  Kasper Skårhøj  <kasper@typo3.com>
+2004-04-01  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed SSL problem and many other minor things
 
-2004-03-31  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-31  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed spam-protection of email adresses inserted by "mailto:..." in text.
 
-2004-03-31  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-31  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed another small bug in detection of simulateStaticDocuments.
 
-2004-03-31  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-31  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed distinction between ' and " in EM.
 
-2004-03-31  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-31  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Removed "onblur" handler in "browser.php" - had no great significance apparently and bugged people on Mac.
 
-2004-03-31  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-31  Kasper Skaarhoj  <kasper@typo3.com>
 
        * In t3lib_div::linkThisUrl(), remove "?" if no parameters were found.
 
-2004-03-31  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-31  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added "config.doctype = none" support - omits any doctype in the frontend.
 
-2004-03-31  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-31  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed an error for form wizard (and others...) where the return URL would be wrong if the wizard was activated right after having saved a new record (would like back to a new record again).
        * Further, I added the option of xmlOutput from the table and form wizards. This option is configured in the wizard setup. There is NO frontend rendering supporting the XML format yet. But it might be very handy (and recommended) for other applications wanting to use the table and formwizards.
 
-2004-03-31  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-31  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Changed the way simulateStaticDocuments are resolved
 
-2004-03-28  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-28  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Changed "t3lib_div::calluserFunc" and t3lib_div::getUserObj to use "&" as token for persistent (global) objects rather than ">" - PLEASE UPDATE YOUR CODE if you happend to use these features already (less than a week old).
 
-2004-03-24  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-24  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added <span title=""> to path in backend modules in Web main module; you can now see the full path (non-truncated) as title text.
 
-2004-03-24  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-24  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added RTE API and changed the "rte" extension to use that.
        * Added t3lib_div::getUserObj() which returns an OBJECT , instead of executing a method call like callUserFunc() does.
 
-2004-03-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed problem in Extension Manager where files and directories was not written with correct permissions. I also added t3lib_div::mkdir() general function for creating directories.
 
-2004-03-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Fixed bug that page tree didn't unfold when entering page id in the shortcut frame.
 
-2004-03-23  Kasper Skårhøj  <kasper@typo3.com>
+2004-03-23  Kasper Skaarhoj  <kasper@typo3.com>
 
        * Added a checkbox for be-users to disable IP locking. This is useful if you have backend users complaining about being thrown off sessions.
 
@@ -1361,7 +1366,7 @@ Made changes to class.tslib_content.php:
 - added title="" when neccessary, ie. all cleargifs havin an alt="" parameter now also have a title=""
 
 
-Kasper Skårhøj, 6/2:
+Kasper Skaarhoj, 6/2:
  - Added processing option to RTE, "proc.plainImageMode"
  - Added options for select and group types in TCA to set the selector box style.
  - Added $altPageId parameter to function linkTP*() in tslib_pibase + pi_list_linkSingle()
@@ -1370,7 +1375,7 @@ Kasper Sk
  - Implemented pop-up window size selector in link wizard
 
 
-Kasper Skårhøj
+Kasper Skaarhoj
        * Removed "mininews" from global extensions - that was an error in RC1
        * Removed global extensions "beuser_tracking/ classic_welcome/ design_components/ tt_links/" from main distribtion. They are either obsolete or irrelevant and it has been considered responsible to remove them like this.
 
@@ -1396,13 +1401,13 @@ Changed all usage of t3lib_div::GPvar('SET') to t3lib_div::GPvar('SET',1) (strip
 
        * Added and changed some features related to the replacement of default page module by a custom one (templavoila). See t3lib_positionmap, t3lib_tsfebeuserauth, alt_shortcut, alt_clickmenu
 
-2003-12-16  Kasper Skårhøj
+2003-12-16  Kasper Skaarhoj
 
        * Added new languages labels for cms and lang extensions // increased version number to 3.6.0RC1
 
-2003-12-16  Kasper Skårhøj
+2003-12-16  Kasper Skaarhoj
        * Changed order of DOCTYPE and XML declaration for XHTML support (for standards compliance mode detection in MSIE)
-2003-10-24  Kasper Skårhøj
+2003-10-24  Kasper Skaarhoj
        * Moved changelog.txt to ChangeLog ("cvs compliant")
 TYPO3 3.6.0-dev
 PHP:
index 4cc5c5d..3bb7cf7 100755 (executable)
--- a/TODO.txt
+++ b/TODO.txt
@@ -27,8 +27,6 @@ TCEmain
 - CHARSET:
        - Note: No charset conversion is done in TCEmain. It is expected that the content enters TCEmain in the charset of the backend in general.
 - LOGGING:
-       - Finally define the API to the "sys_log" table!
-               - Add detection of workspace
        - Rewrite log-display, support writing to text-files, syslog on unix (API?)
                - Reports/Monitoring: Show/send-by-email daily reports over accumulated activity (grouped by workspace/user/pagetree section/modules etc) [Richard at Dassault wanted this]
                        - Activity of individual users in a summary form
@@ -37,7 +35,6 @@ TCEmain
        - Finish the logging of TCEmain actions (delete/copy)
        - Versioning: sys history/sys_log track the "uid" of a record and version swapping will invalidate the integrity of this! How to deal with?
        - Centralized logging:
-               - Create a core API for logging data from all kinds of places in the system. (substituting the current sys_log?)
                - Create an extension which shows how the log data can be stored in a) database, b) files
                - extension "logit" / PEAR::log package?
 - INTEGRITY / CLEAN_UP / REFERENCE TRACKING:
@@ -51,6 +48,10 @@ TCEmain
                        - Used for import/export module and anywhere else where we are looking up references!
                        - Basis for integrity checks
                        - clearing caching more effectively
+                       - Could be used for MM look-ups on those "unfortunate" comma-list fields?
+               - Offers API to "fix references" if a record carries lost references
+               - Offers way to map a reference to another one ("search/replace")
+               - Offers way to compare actual references in record and those indexed so we can see if there was inconsistency
        - Record clean-up functionality
                - Remove references to deleted records (also deleted-to-recycler records? Maybe "deleted-to-recycler" references are important to remove in order to make sure "recycler" records are not selected!) (refs to MM for both tables/files)
                - Remove references to lost files etc.
@@ -78,7 +79,6 @@ TCEmain
        - Tools > User Admin:
                - Features helping to configure roles/users?
        - Versioning:
-               - Versioning must work for non-admins!
                - Backend user access to elements is based on the access restrictions for the official element (except pages?). This must be implemented on core level.
 - TCEforms/TCEmain available for frontend
        - Makes portal features easier to create
@@ -112,6 +112,7 @@ TCEmain
 - BUG:
        - if a file is uploaded (directly in the form) and there is an upper limit to the number of files which is then exceeded, the uploaded file is STILL copied to the upload folder and will thus be listed as "Files with no references at all (delete them!):"
        - TCEmain: If there is a comma in the filename supplied as an uploaded file it will confuse the handling of files because the comma is also used to split the filename from each other. (29/04/2003). This is a problem with Inter-Photo Netprint where files uploaded by FTP with comma in the name will not be attached as they should. I think the solution should be found in TCEmain so any filename can be supplied as uploaded.
+       - "editlock" is only implemented for pages at the moment which it should be so for records according to TYPO3 Core API.
 - IDEA: check for potential dangerous php-extension
 
 
@@ -137,7 +138,6 @@ TCEmain/TCEforms for FlexForms:
        - Displaying partial branch of the data structure (and to a certain level)
        - FlexForms cannot be possible if the record is not saved? No, should be ok, BUT a data source can of course not be referenced from another field since that fields value is NOT actually there! So only for fixed references to flex form definitions can this be done.
        - If you have a multiple selector field (or checkbox array) an array of objects could be forced to reflect exactly the fieldnames there 1-1 thus giving us configuration option possibilites per field! For newloginbox extension: You set up a selector box with multiple choice where you can select fields from the fe_users table to display. In an array of elements in the DS you configure that the VALUE of that field is dictating that the same number of objects should be shown for configuration of each field. A "hidden" value would point each object to which value from the field it was for! The same would be very useful for M-M lists of records.
-       - Implement "<displayCond>EXT:templavoila:LOADED:true</displayCond>" for flexforms. (needed for mininews!!)
        - Implement CSH for FF fields.
        - Localization of FlexForms:
                - Permissions for specific language as well!
@@ -301,158 +301,101 @@ SQLengine (t3lib_sqlengine):
 Versioning/Workspaces:
 *******************************
 
-- "They are also the only ones who can eventually publish the workspace content (except "admin" users)."
-- "If set, records from tables where versioning is not enabled can still be edited "live" inside the workspace."
-- "Admin user is the only one who can publish": Add that field, add flag in workspace table that "publish workspace gradually"
-       - "t3ver_stage" (only draft content in custom workspace): 0 = being edited (editing possible for members), 1 = pending for review (edit possible for reviewer), 2 = ready for publish (editing possible for admin), -1 = rejected, ready for editing (using sys-log for notice)
-
-Next steps for workspaces:
-- Overlays implemented in backend
-- Permissions / UIDs reflected in buttons and clickmenus.
-- Frontend previews done
-
-- Clean-up of TCEmain/logging/permissions [in particular for versioning/workspaces!]
-       - Perform as much logic and re-mapping in tcemain as possible so applications doesn't have to (for instance re-mapping of source and target uids in paste operations.)
-
-
-Testing:
-       t3lib_BEfunc::getFlexFormDS(), workspaceOL/fixVersioningPid ??
-       Page and (User) TSconfig?
-       Mounts points and versionized branches?
-       TemplateRecord previews?
-       - Apply versioning to other tables than the current.
+- 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"
+----------------------------
+- 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?
+       - What about template::getVersionSelector()
+
+Backend preview:
+- Check overlay implementation across core backend:
+       - Modules, click-menu
+       - Permissions / UIDs reflected in buttons and clickmenus.
        - check page trees around for display of color backgrounds...
        - check editing icons, overlays in various modules.
-       - Workspace access to Filelist module ?? (Should be OK)
-       - copy/cut/paste between versionized branches and other places (new pages).
-       - delete something twice?
-       template::getVersionSelector()
-       - overview of permissions handling?
-       - samspil med version module?
-
-Dassault:
-       - Change "class.user_3dsplm_fakepage.php"
-
-Manual:
-- Overview
-       - Concept:
-               - Workspace is Container for draft versions => Solves all issues of previewing, managing versions, overviews, comparisons etc.
-               - All is draft, consequence; a) works only with versionizable records, b) no files can be managed in fileadmin (unless exception accepted for custom workspaces)! => Safe playground
-               - Must work transparently for user => No training needed.
-               - THE implementation of versioning!
-       - state, not process!
-       - Define:
-               - lifecycle
-               - workspace
-               - publish/swap  workspace
-               - versioning modes: element, page, branch
-       - Modes:
-               - Live mode (online):
-                       - Editing live content
-                       - Like TYPO3 always was, however users can be excluded from online mode now.
-               - Draft mode (offline):
-                       - Editing draft versions of content
-                       - All editors can publish individual content or whole workspace at any time
-                       - Usage: AdHoc needs for trusted editors etc.
-               - Custom mode:
-                       - Editing draft versions of content
-                       - Workspace owner is only person to publish (highest review authority) and edit workspace properties
-                       - Workspace options: filemounts, reviewers, publishing time, Db mount
-                       - Usage: For specific projects on a sitebranch, for simple review-cycle needs etc.
-- Using Workspaces
-       - Transparency in action
-       - Colors for feedback
-       - What is "[#VEP#]" in the path (visually)
-       - Workspace manager
-       - Setting up users (draft/live etc)
-               - "options.pageTree.onlineWorkspaceInfo"
-       - Preview in frontend by workspace ID
-- API
-       Intro:
-               - "versioningWS" instead of "versioning" in TCA
-                       workspace 0 = online (live)
-                       workspace -1 = offline (draft)
-                       workspace > 0 = custom (projects)
-                       workspace -99 = none selected at all.
-                       [-99 is ERROR (none available), -1 is offline, 0 is online, >0 is custom workspaces.]
-       API:
-               Frontend:
-                       Preview issues:
-                               - Challenge: Previewing elements which are disabled by enableFields in the online version but not necessarily in offline versions! Also, new records with "t3ver_state" set to 1 (placeholder" must be filtered out as well - but not when previewed!
-                               - Solution:
-                                       - Disable enableFields()/->where_del_hidden and check for them in versionOL on input record!
-                               - Implementation:
-                                       - Any place where enableFields() are not used for selecting in frontend, the t3ver_state==1 flag must be checked in online display - otherwise placeholder records might be selected!
-                                       ->versionOL(): Check if record has enable-fields that prevents display and if so, unset!
-                                       ->fixVersioningPid(): For tracing back (getRootLine())
-                                       ->getWorkspaceVersionOfRecord()
-                               - Scenarios for preview that is not planned to be implemented:
-                                       - Searching will probably never work in offline mode: All SQL selection happens on online records and the overlay is applied only after.
-                                       - It is impossible to preview "count(*)" selections since we would have to traverse all records and pass them through versionOL() before we could count on the result!
-                                       - In tslib_fe::getPageShortcut() sys_page->getMenu() is called with an additional WHERE clause which will not respect if those fields are changed for a future version. This could be the case other places where getmenu() is used (but a search shows it is not a big problem). In this case we will for now accept that a wrong shortcut destination can be experienced during previews.
-                                       - Whenever a SQL query is made which also selects on other fields than enableFields, THEN it is out of control to preview. See the example described above (tslib_fe::getPageShortcut)
-               Backend modules:
-                       $MCONF['workspaces'] = online,offline,custom
-               Backend, overlay/checking:
-                       t3lib_BEfunc::workspaceOL()
-                       t3lib_BEfunc::fixVersioningPid()
-                       t3lib_BEfunc::isPidInVersionizedBranch
-                       t3lib_BEfunc::getWorkspaceVersionOfRecord
-                       t3lib_BEfunc::selectVersionsOfRecord()
-
-                       BE_USER:
-                       ->workspaceEditState
-                       ->workspaceTestPID
-                       ->workspaceInit()
-                       ->checkWorkspace()
-                       ->setWorkspace()
-                       ->setWorkspacePreview()
-                       ->getDefaultWorkspace()
-
-View/Preview:
-- Frontend:
-       - 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!
-       OK - Workspace is used to set frontend in preview mode and display versions
-       ?!      - TEST: Mounts points and versionized branches?
-       ?       - tslib_content::getPidList(); TEST Mount points / Use offline UID values for "page" swapmodes; This is probably more natural for preview cases.
-       ?       - versionOL() implementations missing:
-                       - tslib_pibase::pi_getCategoryTableContents()
-                       - tslib_content::checkPidArray()
-                       - tslib_content::checkPid()
-                       - tslib_content::exec_mm_query()/-_uidList() [These seems NOT to be used anymore!]
-       - Difficult frontend previews:
-               - All fields selected upon in frontend:
-                       - $TCA[$table]['ctrl']['languageField'] and $TCA[$table]['ctrl']['transOrigPointerField']
-                       - field: pages_language_overlay:sys_language_uid
-                       - field: pages:doktype (used for selection many places!) - but then we cannot make mounts points etc! (?)
-               - Suggested solution:
-                       - Setting a workspace-readonly flag for such values!
-                       - However,
-                               - menu previews are bypassing the problem already,
-                               - page shortcut has trouble but is known,
-                               - mount points will not be possible to preview (?)
-                               - For new translations we might have the problem, for existing translations probably not since it is unlikely that the fields $TCA[$table]['ctrl']['languageField'] and $TCA[$table]['ctrl']['transOrigPointerField'] at changed later!
-                       - For new records, maybe the placeholder record is updated along with offline version? (At least for non-file fields). This would solve the problem of build translations in a workspace and also offer the preview as working!
-
-       - In tslib_fe, this->contentPid is set to "_ORIG_UID" when a versionized page have swapmode set to "0". However this is not completely correct to do: Strictly the "_ORIG_UID" value should be used for tables where "versioning_followPages" is set and for others not. However this is a working quick-fix to display content elements at least!
-               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?
-- Backend:
-       - Page TSconfig, Access evaluation, TCEmain/ TCEforms, Flexforms etc: When to fixVersioningPid() / versionOL()?
-       - Quick Edit?
+- Page module:
+       - Colored backgrounds in Page module
+       - 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"
+
+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!
+?!     - TEST: Mounts points and versionized branches?
+?      - tslib_content::getPidList(); TEST Mount points / Use offline UID values for "page" swapmodes; This is probably more natural for preview cases.
+?      - versionOL() implementations missing:
+               - tslib_pibase::pi_getCategoryTableContents()
+               - tslib_content::checkPidArray()
+               - tslib_content::checkPid()
+               - tslib_content::exec_mm_query()/-_uidList() [These seems NOT to be used anymore!]
+- Difficult frontend previews:
+       - All fields selected upon in frontend:
+               - $TCA[$table]['ctrl']['languageField'] and $TCA[$table]['ctrl']['transOrigPointerField']
+               - field: pages_language_overlay:sys_language_uid
+               - field: pages:doktype (used for selection many places!) - but then we cannot make mounts points etc! (?)
+       - Suggested solution:
+               - Setting a workspace-readonly flag for such values!
+               - However,
+                       - menu previews are bypassing the problem already,
+                       - page shortcut has trouble but is known,
+                       - mount points will not be possible to preview (?)
+                       - For new translations we might have the problem, for existing translations probably not since it is unlikely that the fields $TCA[$table]['ctrl']['languageField'] and $TCA[$table]['ctrl']['transOrigPointerField'] are changed later!
+               - For new records, maybe the placeholder record is updated along with offline version? (At least for non-file fields). This would solve the problem of build translations in a workspace and also offer the preview as working!
+- In tslib_fe, this->contentPid is set to "_ORIG_UID" when a versionized page have swapmode set to "0". However this is not completely correct to do: Strictly the "_ORIG_UID" value should be used for tables where "versioning_followPages" is set and for others not. However this is a working quick-fix to display content elements at least!
+       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:
-- Details view for versions
-       - versions inside branch?
-       - display change log for specific element
-       - warning if page is worked on in other workspace
-       - preview links on items
-       - Difference view in online mode as well.
-       - Publishing must be possible ONLY if Online mode is available for a user?
-- Workspace list
+- 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...?)
-- TEMPORARY? Disabled backend reloading when changing workspace.
-- Click menu implementation of: Diff-view, raise level / publish. => Guess this is what the versioning element should hold!
+- 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)
+
+Preview modes with no BE login; For single pages, for whole workspace?
+       - Can bypass hidden pages, fe_groups, set workspace
+       - Works for certain timespan
+       - Sets cookie
+       - Respects permissions of backend users issuing that permission!?
 
 Workflows:
 - Workflows can regard a whole workspace!
@@ -460,39 +403,20 @@ Workflows:
        - Publishing workspace / Setting publishing time
        - Freezing/unfreezing workspace
 
-Swapping:
-       - (Support for) swapping using temporary file (instead of using negative ID)
-       - When swapping; Check "unique" fields (like pages.alias) etc.
-       - permissions?
-       - Problem: When a page+content or branch is versionized, the records that the user is NOT allowed to create/edit are NOT versionized. That mean that records are swapped out that should not be! Imagine if a user has no access to page language overlay but creates a new page+content. Then only page and tt_content is versionized but when swapped the page_language_overlay records are lost since none exist in the versionized page!
-
-Various Notes:
-- Pages-versioning and the impact of NOT swapping tt_content element uids:
-       - Loose anchor-points, manually made (could be hack-fixed by some intelligent copying tracking)
-       - TemplaVoila references to elements from other pages (will break, however bad practice to reference elements not in some sort of central library which will NEVER be page-versioned anyways)
-       - Insert-records could potentially do the same
-       - Impact assesment: Low.
-       - Clean-up module (in templavoila?) could also track such things
-       - Problems for non-templavoila sites would be low.
-    - What about a page alias?
-
-- Trunk/Branch:
-       - Requirement: Intelligent swapping of "sub-element" ids that CAN be traced back to the original!
-
-- MySQL:
+Documentation:
+- Finish chapter "Using versioning and workspaces" in "Inside TYPO3" with screenshots etc.
+
+-----LATER:
+
+- Branch versioning:
+       - Intelligent swapping of "sub-element" ids that CAN be traced back to the original? (solution to loosing anchor point and inter-version references?)
+- MySQL/DBAL:
        - 4.0.14 fails with -1 uid! (4.0.18 is ok eg.)
        - Correction possible:
                -> ALTER TABLE jlajlajla AUTO_INCREMENT = 123
        - Problems with other RDBMS because ID values cannot be changed at all!
-
-Preview modes with no BE login; For single pages, for whole workspace?
-- Can bypass hidden pages, fe_groups, set workspace
-- Works for certain timespan
-- Sets cookie
-- Respects permissions of backend users issuing that permission!?
-
-
-
+- Swapping consequences:
+       - UID references for such as the sys_history and sys_log table are misleading.
 
 
 *************************
index 80fbea5..2ea4d81 100644 (file)
@@ -84,13 +84,17 @@ class t3lib_BEDisplayLog {
        var $lastTypeLabel = '';
        var $lastActionLabel = '';
 
-       var $detailsOn = 1;     // If detailsOn, %s is substituted with values from the data-array (see getDetails())
-       var $stripPath = 1;     // This strips the path from any value in the data-array when the data-array is parsed through stripPath()
+       var $detailsOn = 1;                     // If detailsOn, %s is substituted with values from the data-array (see getDetails())
+       var $stripPath = 1;                     // This strips the path from any value in the data-array when the data-array is parsed through stripPath()
        var $errorSign = Array(
                1 => '!',
                2 => 'Sys!',
                3 => 'Secur!'
        );
+       var $wsArray = array(
+               0 => 'LIVE',
+               -1 => 'Draft',
+       );
 
        var $be_user_Array = array();           // Username array (set externally)
 
@@ -129,13 +133,15 @@ class t3lib_BEDisplayLog {
         * Get user name label for log listing
         *
         * @param       integer         be_user uid
+        * @param       integer         Workspace ID
         * @return      string          If username is different from last username then the username, otherwise "."
         */
-       function getUserLabel($code)    {
-               if ($this->lastUserLabel!=$code)        {
-                       $this->lastUserLabel=$code;
+       function getUserLabel($code,$workspace=0)       {
+               if ($this->lastUserLabel!=$code.'_'.$workspace) {
+                       $this->lastUserLabel=$code.'_'.$workspace;
                        $label = $this->be_user_Array[$code]['username'];
-                       return $label ? $label : '['.$code.']';
+                       $ws = $this->wsArray[$workspace];
+                       return ($label ? $label : '['.$code.']').'@'.($ws?$ws:$workspace);
                } else return '.';
        }
 
@@ -198,7 +204,9 @@ class t3lib_BEDisplayLog {
                $newRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
                if (is_array($newRow))  {
                        $text.=' Changes in fields: <em>'.$newRow['fieldlist'].'</em>.';
-                       $text.=' <a href="'.htmlspecialchars($GLOBALS['BACK_PATH'].'show_rechis.php?sh_uid='.$newRow['uid'].'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'"><b>->His</b></a>';
+                       $text.=' <a href="'.htmlspecialchars($GLOBALS['BACK_PATH'].'show_rechis.php?sh_uid='.$newRow['uid'].'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
+                                       '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/history2.gif','width="13" height="12"').' title="Show History" alt="" />'.
+                                       '</a>';
                }
 
                return $text;
@@ -220,11 +228,11 @@ class t3lib_BEDisplayLog {
         * Formats input string in red-colored font tags
         *
         * @param       string          Input value
+        * @param       integer         Error value
         * @return      string          Input wrapped in red font-tag and bold
-        * @obsolete
         */
-       function getErrorFormatting($sign)      {
-               return '<font color="red"><b>'.$sign.'</b></font>';
+       function getErrorFormatting($sign, $error=0)    {
+               return $GLOBALS['SOBE']->doc->icons($error>=2 ? 3:2).$sign;
        }
 
        /**
@@ -239,7 +247,7 @@ class t3lib_BEDisplayLog {
                        $data=$this->stripPath($data);
                }
 
-               return $this->getDetails($row['type'].'_'.$row['action'].'_'.$row['details_nr'],$row['details'],$data,$row['uid']).' ('.$row['details_nr'].')';
+               return $this->getDetails($row['type'].'_'.$row['action'].'_'.$row['details_nr'],$row['details'],$data,$row['uid']).($row['details_nr']>0?' (msg#'.$row['type'].'.'.$row['action'].'.'.$row['details_nr'].')':'');
        }
 
        /**
index 7531240..d9a556c 100755 (executable)
@@ -515,7 +515,7 @@ class t3lib_BEfunc  {
                while ($uid!=0 && $loopCheck>0) {
                        $loopCheck--;
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                               'pid,uid,title,TSconfig,is_siteroot,storage_pid,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_swapmode',
+                               'pid,uid,title,TSconfig,is_siteroot,storage_pid,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_swapmode,t3ver_stage',
                                'pages',
                                'uid='.intval($uid).' '.
                                        t3lib_BEfunc::deleteClause('pages').' '.
@@ -550,6 +550,7 @@ class t3lib_BEfunc  {
                                $output[$c]['t3ver_wsid'] = $val['t3ver_wsid'];
                                $output[$c]['t3ver_state'] = $val['t3ver_state'];
                                $output[$c]['t3ver_swapmode'] = $val['t3ver_swapmode'];
+                               $output[$c]['t3ver_stage'] = $val['t3ver_stage'];
                        }
                }
 
@@ -789,6 +790,7 @@ class t3lib_BEfunc  {
                        } else {
                                $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);
                                        list($pageinfo['_thePath'],$pageinfo['_thePathFull']) = t3lib_BEfunc::getRecordPath(intval($pageinfo['uid']), $perms_clause, 15, 1000);
                                        return $pageinfo;
                                }
@@ -3039,7 +3041,7 @@ class t3lib_BEfunc        {
         * Principle; Record online! => Find offline?
         *
         * @param       string          Table name
-        * @param       array           Record array passed by reference. As minimum, the "uid", "pid" and "t3ver_swapmode" (pages) fields must exist!
+        * @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.
         * @param       integer         Workspace ID, if not specified will use $GLOBALS['BE_USER']->workspace
         * @return      void            (Passed by ref).
         * @see fixVersioningPid()
@@ -3118,9 +3120,11 @@ class t3lib_BEfunc       {
         * 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.
         *
         * @param       integer         Page id inside of which you want to edit/create/delete something.
-        * @return      boolean         Returns true if PID was in versionized branch.
+        * @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)
         */
-       function isPidInVersionizedBranch($pid, $table='')      {
+       function isPidInVersionizedBranch($pid, $table='',$returnStage=FALSE)   {
                $rl = t3lib_BEfunc::BEgetRootLine($pid);
                $c = 0;
 
@@ -3128,9 +3132,9 @@ class t3lib_BEfunc        {
                        if ($rec['_ORIG_pid']==-1)      {
                                        // In any case: is it a branchpoint, then OK...
                                if ($rec['t3ver_swapmode']>0)   {
-                                       return 'branchpoint';   // OK, we are in a versionized branch
-                               } elseif ($c==0 && $rec['t3ver_swapmode']==0 && $table && $GLOBALS['TCA'][$table]['ctrl']['versioning_followPages'])    {       // First level: So either $table must be versioning_followPages
-                                       return 'first'; // OK, we are in a versionized branch
+                                       return $returnStage ? (int)$rec['t3ver_stage'] : 'branchpoint'; // OK, we are in a versionized branch
+                               } elseif ($c==0 && $rec['t3ver_swapmode']==0 && $table && $GLOBALS['TCA'][$table]['ctrl']['versioning_followPages'])    {       // First level: So $table must be versioning_followPages
+                                       return $returnStage ? (int)$rec['t3ver_stage'] : 'first';       // OK, we are in a versionized branch
                                }
                        }
                        $c++;
index 70103f6..27affb3 100755 (executable)
  *
  *
  *
- *  108: class t3lib_pageSelect
- *  133:     function init($show_hidden)
+ *  109: class t3lib_pageSelect
+ *  134:     function init($show_hidden)
  *
  *              SECTION: Selecting page records
- *  179:     function getPage($uid, $disableGroupAccessCheck=FALSE)
- *  195:     function getPage_noCheck($uid)
- *  211:     function getFirstWebPage($uid)
- *  229:     function getPageIdFromAlias($alias)
- *  245:     function getPageOverlay($pageInput,$lUid=-1)
- *  309:     function getRecordOverlay($table,$row,$sys_language_content,$OLmode='')
+ *  184:     function getPage($uid, $disableGroupAccessCheck=FALSE)
+ *  200:     function getPage_noCheck($uid)
+ *  216:     function getFirstWebPage($uid)
+ *  234:     function getPageIdFromAlias($alias)
+ *  250:     function getPageOverlay($pageInput,$lUid=-1)
+ *  314:     function getRecordOverlay($table,$row,$sys_language_content,$OLmode='')
  *
  *              SECTION: Page related: Menu, Domain record, Root line
- *  405:     function getMenu($uid,$fields='*',$sortField='sorting',$addWhere='')
- *  443:     function getDomainStartPage($domain, $path='',$request_uri='')
- *  491:     function getRootLine($uid, $MP='', $ignoreMPerrors=FALSE)
- *  612:     function getPathFromRootline($rl,$len=20)
- *  633:     function getExtURL($pagerow,$disable=0)
- *  657:     function getMountPointInfo($pageId, $pageRec=FALSE, $prevMountPids=array(), $firstPageUid=0)
+ *  410:     function getMenu($uid,$fields='*',$sortField='sorting',$addWhere='')
+ *  448:     function getDomainStartPage($domain, $path='',$request_uri='')
+ *  496:     function getRootLine($uid, $MP='', $ignoreMPerrors=FALSE)
+ *  617:     function getPathFromRootline($rl,$len=20)
+ *  638:     function getExtURL($pagerow,$disable=0)
+ *  662:     function getMountPointInfo($pageId, $pageRec=FALSE, $prevMountPids=array(), $firstPageUid=0)
  *
  *              SECTION: Selecting records in general
- *  734:     function checkRecord($table,$uid,$checkPage=0)
- *  768:     function getRawRecord($table,$uid,$fields='*')
- *  792:     function getRecordsByField($theTable,$theField,$theValue,$whereClause='',$groupBy='',$orderBy='',$limit='')
+ *  739:     function checkRecord($table,$uid,$checkPage=0)
+ *  773:     function getRawRecord($table,$uid,$fields='*')
+ *  797:     function getRecordsByField($theTable,$theField,$theValue,$whereClause='',$groupBy='',$orderBy='',$limit='')
  *
  *              SECTION: Caching and standard clauses
- *  844:     function getHash($hash,$expTime=0)
- *  867:     function storeHash($hash,$data,$ident)
- *  885:     function deleteClause($table)
- *  904:     function enableFields($table,$show_hidden=-1,$ignore_array=array())
+ *  849:     function getHash($hash,$expTime=0)
+ *  872:     function storeHash($hash,$data,$ident)
+ *  890:     function deleteClause($table)
+ *  910:     function enableFields($table,$show_hidden=-1,$ignore_array=array(),$noVersionPreview=FALSE)
+ *  979:     function getMultipleGroupsWhereClause($field, $table)
  *
  *              SECTION: Versioning Preview
- *  998:     function fixVersioningPid($table,&$rr)
- * 1039:     function versionOL($table,&$row,$TEMPCHECK=0)
- * 1093:     function getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields='*')
+ * 1026:     function fixVersioningPid($table,&$rr)
+ * 1066:     function versionOL($table,&$row)
+ * 1121:     function getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields='*')
  *
- * TOTAL FUNCTIONS: 23
+ * TOTAL FUNCTIONS: 24
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
@@ -902,6 +903,7 @@ class t3lib_pageSelect {
         * @param       string          Table name found in the $TCA array
         * @param       integer         If $show_hidden is set (0/1), any hidden-fields in records are ignored. NOTICE: If you call this function, consider what to do with the show_hidden parameter. Maybe it should be set? See tslib_cObj->enableFields where it's implemented correctly.
         * @param       array           Array you can pass where keys can be "disabled", "starttime", "endtime", "fe_group" (keys from "enablefields" in TCA) and if set they will make sure that part of the clause is not added. Thus disables the specific part of the clause. For previewing etc.
+        * @param       boolean         If set, enableFields will be applied regardless of any versioning preview settings which might otherwise disable enableFields
         * @return      string          The clause starting like " AND ...=... AND ...=..."
         * @see tslib_cObj::enableFields(), deleteClause()
         */
@@ -967,6 +969,14 @@ class t3lib_pageSelect {
                return $query;
        }
 
+       /**
+        * Creating where-clause for checking group access to elements in enableFields function
+        *
+        * @param       string          Field with group list
+        * @param       string          Table name
+        * @return      string          AND sql-clause
+        * @see enableFields()
+        */
        function getMultipleGroupsWhereClause($field, $table)   {
                $memberGroups = t3lib_div::intExplode(',',$GLOBALS['TSFE']->gr_list);
                $orChecks=array();
@@ -1065,8 +1075,9 @@ 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 strictly speaking be used as PID for selection of tables with "versioning_followPages" enabled.
+                                               // 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'];
@@ -1075,7 +1086,9 @@ class t3lib_pageSelect {
                                                if ($table==='pages')   {
                                                        $wsAlt['alias'] = $row['alias'];
                                                }
-                                       } else {        // Keeping overlay uid and pid so references are changed. This is only for page-versions with BRANCH below!
+                                       } 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
                                        }
 
@@ -1111,13 +1124,12 @@ class t3lib_pageSelect {
 
                if ($workspace!==0 && ($table=='pages' || $TCA[$table]['ctrl']['versioningWS']))        {       // Have to hardcode it for "pages" table since TCA is not loaded at this moment!
 
-                               // Setting up enableFields for record:
+                               // Setting up enableFields for version record:
                        if ($table=='pages')    {
                                $enFields = $this->versioningPreview_where_hid_del;
                        } else {
                                $enFields = $this->enableFields($table,-1,array(),TRUE);
                        }
-#debug($enFields,$table);
 
                                // Select workspace version of record, only testing for deleted.
                        list($newrow) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
@@ -1131,7 +1143,6 @@ class t3lib_pageSelect {
 
                                // If version found, check if it could have been selected with enableFields on as well:
                        if (is_array($newrow))  {
-#debug(array($newrow,$enFields));
                                if ($GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
                                        'uid',
                                        $table,
@@ -1140,20 +1151,20 @@ class t3lib_pageSelect {
                                                t3ver_wsid='.intval($workspace).
                                                $enFields
                                )) {
-                                       return $newrow; // Return row
+                                       return $newrow; // Return offline version, tested for its enableFields.
                                } else {
-                                       return -1;      // Unset row!
+                                       return -1;      // Return -1 because version was de-selected due to its enableFields.
                                }
                        } else {
-                                       // Otherwise, check if online version can be selected with full enable fields and if so, return 1:
+                                       // OK, so no workspace version was found. Then check if online version can be selected with full enable fields and if so, return 1:
                                if ($GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
                                        'uid',
                                        $table,
                                        'uid='.intval($uid).$enFields
                                ))      {
-                                       return 1;       // Means search was done.
+                                       return 1;       // Means search was done, but no version found.
                                } else {
-                                       return -1;      // Unset row!
+                                       return -1;      // Return -1 because the current record was de-selected due to its enableFields.
                                }
                        }
                }
index 20c5ef3..eb4bee0 100755 (executable)
@@ -4944,6 +4944,17 @@ class t3lib_TCEforms     {
                                        $output = TRUE;
                                }
                        break;
+                       case 'VERSION':
+                               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;
+                                               }
+                                       break;
+                               }
+                       break;
                }
 
                return $output;
index cd25c27..54faede 100755 (executable)
@@ -28,7 +28,7 @@
  * Contains the TYPO3 Core Engine
  *
  * $Id$
- * Revised for TYPO3 3.6 August/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.9 October 2005 by Kasper Skaarhoj
  *
  * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
  *
  *
  *
- *  199: class t3lib_TCEmain
- *  288:     function start($data,$cmd,$altUserObject='')
- *  321:     function setMirror($mirror)
- *  346:     function setDefaultsFromUserTS($userTS)
- *  369:     function process_uploads($postFiles)
- *  399:     function process_uploads_traverseArray(&$outputArr,$inputArr,$keyToSet)
+ *  218: class t3lib_TCEmain
+ *  335:     function start($data,$cmd,$altUserObject='')
+ *  370:     function setMirror($mirror)
+ *  395:     function setDefaultsFromUserTS($userTS)
+ *  418:     function process_uploads($postFiles)
+ *  456:     function process_uploads_traverseArray(&$outputArr,$inputArr,$keyToSet)
  *
  *              SECTION: PROCESSING DATA
- *  435:     function process_datamap()
- *  628:     function fillInFieldArray($table,$id,$fieldArray,$incomingFieldArray,$realPid,$status,$tscPID)
- *  819:     function checkModifyAccessList($table)
- *  831:     function isRecordInWebMount($table,$id)
- *  845:     function isInWebMount($pid)
- *  862:     function checkRecordUpdateAccess($table,$id)
- *  887:     function checkRecordInsertAccess($insertTable,$pid,$action=1)
- *  923:     function isTableAllowedForThisPage($page_uid, $checkTable)
- *  958:     function doesRecordExist($table,$id,$perms)
- * 1021:     function doesRecordExist_pageLookUp($id, $perms)
- * 1047:     function doesBranchExist($inList,$pid,$perms, $recurse)
- * 1082:     function pageInfo($id,$field)
- * 1102:     function recordInfo($table,$id,$fieldList)
- * 1119:     function getRecordProperties($table,$id)
- * 1132:     function getRecordPropertiesFromRow($table,$row)
- * 1151:     function setTSconfigPermissions($fieldArray,$TSConfig_p)
- * 1167:     function newFieldArray($table)
- * 1198:     function overrideFieldArray($table,$data)
- * 1211:     function assemblePermissions($string)
+ *  492:     function process_datamap()
+ *  789:     function fillInFieldArray($table,$id,$fieldArray,$incomingFieldArray,$realPid,$status,$tscPID)
  *
  *              SECTION: Evaluation of input values
- * 1261:     function checkValue($table,$field,$value,$id,$status,$realPid,$tscPID)
- * 1321:     function checkValue_SW($res,$value,$tcaFieldConf,$table,$id,$curValue,$status,$realPid,$recFID,$field,$uploadedFiles,$tscPID)
- * 1367:     function checkValue_input($res,$value,$tcaFieldConf,$PP,$field='')
- * 1405:     function checkValue_check($res,$value,$tcaFieldConf,$PP)
- * 1428:     function checkValue_radio($res,$value,$tcaFieldConf,$PP)
- * 1454:     function checkValue_group_select($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field)
- * 1554:     function checkValue_group_select_file($valueArray,$tcaFieldConf,$curValue,$uploadedFileArray,$status,$table,$id,$recFID)
- * 1707:     function checkValue_flex($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field)
- * 1765:     function checkValue_flexArray2Xml($array)
- * 1782:     function _DELETE_FLEX_FORMdata(&$valueArrayToRemoveFrom,$deleteCMDS)
+ * 1009:     function checkValue($table,$field,$value,$id,$status,$realPid,$tscPID)
+ * 1069:     function checkValue_SW($res,$value,$tcaFieldConf,$table,$id,$curValue,$status,$realPid,$recFID,$field,$uploadedFiles,$tscPID)
+ * 1115:     function checkValue_input($res,$value,$tcaFieldConf,$PP,$field='')
+ * 1153:     function checkValue_check($res,$value,$tcaFieldConf,$PP)
+ * 1176:     function checkValue_radio($res,$value,$tcaFieldConf,$PP)
+ * 1202:     function checkValue_group_select($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field)
+ * 1302:     function checkValue_group_select_file($valueArray,$tcaFieldConf,$curValue,$uploadedFileArray,$status,$table,$id,$recFID)
+ * 1455:     function checkValue_flex($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field)
+ * 1528:     function checkValue_flexArray2Xml($array)
+ * 1545:     function _DELETE_FLEX_FORMdata(&$valueArrayToRemoveFrom,$deleteCMDS)
+ * 1567:     function _MOVE_FLEX_FORMdata(&$valueArrayToMoveIn, $moveCMDS, $direction)
  *
  *              SECTION: Helper functions for evaluation functions.
- * 1830:     function getUnique($table,$field,$value,$id,$newPid=0)
- * 1868:     function checkValue_input_Eval($value,$evalArray,$is_in)
- * 1956:     function checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,$type)
- * 1989:     function checkValue_group_select_explodeSelectGroupValue($value)
- * 2012:     function checkValue_flex_procInData($dataPart,$dataPart_current,$uploadedFiles,$dataStructArray,$pParams,$callBackFunc='')
- * 2051:     function checkValue_flex_procInData_travDS(&$dataValues,$dataValues_current,$uploadedFiles,$DSelements,$pParams,$callBackFunc,$structurePath)
+ * 1629:     function getUnique($table,$field,$value,$id,$newPid=0)
+ * 1667:     function checkValue_input_Eval($value,$evalArray,$is_in)
+ * 1755:     function checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,$type)
+ * 1788:     function checkValue_group_select_explodeSelectGroupValue($value)
+ * 1811:     function checkValue_flex_procInData($dataPart,$dataPart_current,$uploadedFiles,$dataStructArray,$pParams,$callBackFunc='')
+ * 1850:     function checkValue_flex_procInData_travDS(&$dataValues,$dataValues_current,$uploadedFiles,$DSelements,$pParams,$callBackFunc,$structurePath)
+ *
+ *              SECTION: PROCESSING COMMANDS
+ * 1996:     function process_cmdmap()
+ *
+ *              SECTION: Cmd: Copying
+ * 2140:     function copyRecord($table,$uid,$destPid,$first=0,$overrideValues=array(),$excludeFields='')
+ * 2248:     function copyPages($uid,$destPid)
+ * 2303:     function copySpecificPage($uid,$destPid,$copyTablesArray,$first=0)
+ * 2337:     function copyRecord_raw($table,$uid,$pid,$overrideArray=array())
+ * 2399:     function rawCopyPageContent($old_pid,$new_pid,$copyTablesArray)
+ * 2423:     function insertNewCopyVersion($table,$fieldArray,$realPid)
+ * 2474:     function copyRecord_procBasedOnFieldType($table,$uid,$field,$value,$row,$conf)
+ * 2530:     function copyRecord_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2)
+ * 2558:     function copyRecord_procFilesRefs($conf, $uid, $value)
+ *
+ *              SECTION: Cmd: Moving, Localizing
+ * 2627:     function moveRecord($table,$uid,$destPid)
+ * 2777:     function localize($table,$uid,$language)
+ *
+ *              SECTION: Cmd: Versioning
+ * 2852:     function versionizeRecord($table,$id,$label,$delete=FALSE,$versionizeTree=-1)
+ * 2929:     function versionizePages($uid,$label,$versionizeTree)
+ * 2986:     function version_swap($table,$id,$swapWith,$swapIntoWS=0)
+ * 3134:     function version_clearWSID($table,$id)
+ * 3154:     function version_setStage($table,$id,$stageId)
+ *
+ *              SECTION: Cmd: Deleting
+ * 3195:     function deleteRecord($table,$uid, $noRecordCheck)
+ * 3249:     function deletePages($uid)
+ * 3283:     function deleteSpecificPage($uid)
+ *
+ *              SECTION: Cmd: Helper functions
+ * 3324:     function remapListedDBRecords()
+ * 3401:     function remapListedDBRecords_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2)
+ * 3427:     function remapListedDBRecords_procDBRefs($conf, $value, $MM_localUid)
+ *
+ *              SECTION: Access control / Checking functions
+ * 3491:     function checkModifyAccessList($table)
+ * 3503:     function isRecordInWebMount($table,$id)
+ * 3517:     function isInWebMount($pid)
+ * 3531:     function checkRecordUpdateAccess($table,$id)
+ * 3555:     function checkRecordInsertAccess($insertTable,$pid,$action=1)
+ * 3589:     function isTableAllowedForThisPage($page_uid, $checkTable)
+ * 3622:     function doesRecordExist($table,$id,$perms)
+ * 3684:     function doesRecordExist_pageLookUp($id, $perms)
+ * 3710:     function doesBranchExist($inList,$pid,$perms,$recurse)
+ * 3744:     function tableReadOnly($table)
+ * 3756:     function tableAdminOnly($table)
+ * 3768:     function isReferenceField($conf)
+ * 3780:     function destNotInsideSelf($dest,$id)
+ * 3811:     function getExcludeListArray()
+ * 3834:     function doesPageHaveUnallowedTables($page_uid,$doktype)
+ *
+ *              SECTION: Information lookup
+ * 3883:     function pageInfo($id,$field)
+ * 3903:     function recordInfo($table,$id,$fieldList)
+ * 3922:     function getRecordProperties($table,$id)
+ * 3935:     function getRecordPropertiesFromRow($table,$row)
  *
  *              SECTION: Storing data to Database Layer
- * 2204:     function updateDB($table,$id,$fieldArray)
- * 2250:     function compareFieldArrayWithCurrentAndUnset($table,$id,$fieldArray)
- * 2304:     function insertDB($table,$id,$fieldArray,$newVersion=FALSE,$suggestedUid=0)
- * 2376:     function checkStoredRecord($table,$id,$fieldArray,$action)
- * 2412:     function dbAnalysisStoreExec()
- * 2428:     function removeRegisteredFiles()
- * 2445:     function clear_cache($table,$uid)
- * 2549:     function getPID($table,$uid)
+ * 3978:     function updateDB($table,$id,$fieldArray)
+ * 4026:     function insertDB($table,$id,$fieldArray,$newVersion=FALSE,$suggestedUid=0,$dontSetNewIdIndex=FALSE)
+ * 4094:     function checkStoredRecord($table,$id,$fieldArray,$action)
+ * 4131:     function setHistory($table,$id,$logId)
+ * 4170:     function clearHistory($table,$id,$keepEntries=10,$maxAgeSeconds=604800)
  *
- *              SECTION: PROCESSING COMMANDS
- * 2592:     function process_cmdmap()
- * 2680:     function moveRecord($table,$uid,$destPid)
- * 2824:     function copyRecord($table,$uid,$destPid,$first=0,$overrideValues=array(),$excludeFields='')
- * 2933:     function copyRecord_raw($table,$uid,$pid,$overrideArray=array())
- * 2989:     function insertNewCopyVersion($table,$fieldArray,$realPid)
- * 3040:     function copyRecord_procBasedOnFieldType($table,$uid,$field,$value,$row,$conf)
- * 3093:     function copyRecord_localize($table,$uid,$language)
- * 3152:     function copyRecord_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2)
- * 3180:     function copyRecord_procFilesRefs($conf, $uid, $value)
- * 3231:     function copyPages($uid,$destPid)
- * 3286:     function copySpecificPage($uid,$destPid,$copyTablesArray,$first=0)
- * 3316:     function versionizeRecord($table,$id,$label)
- * 3369:     function versionizePages($uid,$label)
- * 3426:     function rawCopyPageContent($old_pid,$new_pid,$copyTablesArray)
- * 3451:     function version_swap($table,$id,$swapWith)
- * 3575:     function int_pageTreeInfo($CPtable,$pid,$counter, $rootID)
- * 3596:     function compileAdminTables()
- * 3613:     function fixUniqueInPid($table,$uid)
- * 3649:     function fixCopyAfterDuplFields($table,$uid,$prevUid,$update, $newData=array())
- * 3674:     function extFileFields ($table)
- * 3700:     function getCopyHeader($table,$pid,$field,$value,$count,$prevTitle='')
- * 3729:     function prependLabel($table)
- * 3746:     function resolvePid($table,$pid)
- * 3764:     function clearPrefixFromValue($table,$value)
- * 3775:     function remapListedDBRecords()
- * 3858:     function remapListedDBRecords_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2)
- * 3884:     function remapListedDBRecords_procDBRefs($conf, $value, $MM_localUid)
- * 3929:     function extFileFunctions($table,$field,$filelist,$func)
- * 3961:     function deleteRecord($table,$uid, $noRecordCheck)
- * 4019:     function deletePages($uid)
- * 4061:     function deleteSpecificPage($uid)
- * 4085:     function noRecordsFromUnallowedTables($inList)
+ *              SECTION: Misc functions
+ * 4219:     function getSortNumber($table,$uid,$pid)
+ * 4285:     function resorting($table,$pid,$sortRow, $return_SortNumber_After_This_Uid)
+ * 4316:     function setTSconfigPermissions($fieldArray,$TSConfig_p)
+ * 4333:     function newFieldArray($table)
+ * 4365:     function overrideFieldArray($table,$data)
+ * 4381:     function compareFieldArrayWithCurrentAndUnset($table,$id,$fieldArray)
+ * 4427:     function assemblePermissions($string)
+ * 4444:     function rmComma($input)
+ * 4454:     function convNumEntityToByteValue($input)
+ * 4476:     function destPathFromUploadFolder($folder)
+ * 4486:     function deleteClause($table)
+ * 4502:     function getTCEMAIN_TSconfig($tscPID)
+ * 4517:     function getTableEntries($table,$TSconfig)
+ * 4530:     function getPID($table,$uid)
+ * 4543:     function dbAnalysisStoreExec()
+ * 4559:     function removeRegisteredFiles()
+ * 4571:     function removeCacheFiles()
+ * 4596:     function int_pageTreeInfo($CPtable,$pid,$counter, $rootID)
+ * 4617:     function compileAdminTables()
+ * 4634:     function fixUniqueInPid($table,$uid)
+ * 4670:     function fixCopyAfterDuplFields($table,$uid,$prevUid,$update, $newData=array())
+ * 4695:     function extFileFields($table)
+ * 4721:     function getCopyHeader($table,$pid,$field,$value,$count,$prevTitle='')
+ * 4750:     function prependLabel($table)
+ * 4767:     function resolvePid($table,$pid)
+ * 4785:     function clearPrefixFromValue($table,$value)
+ * 4800:     function extFileFunctions($table,$field,$filelist,$func)
+ * 4830:     function noRecordsFromUnallowedTables($inList)
  *
- *              SECTION: MISC FUNCTIONS
- * 4147:     function getSortNumber($table,$uid,$pid)
- * 4212:     function resorting($table,$pid,$sortRow, $return_SortNumber_After_This_Uid)
- * 4241:     function rmComma ($input)
- * 4251:     function convNumEntityToByteValue($input)
- * 4273:     function destPathFromUploadFolder ($folder)
- * 4284:     function destNotInsideSelf ($dest,$id)
- * 4310:     function getExcludeListArray()
- * 4334:     function doesPageHaveUnallowedTables($page_uid,$doktype)
- * 4367:     function deleteClause($table)
- * 4383:     function tableReadOnly($table)
- * 4395:     function tableAdminOnly($table)
- * 4409:     function getInterfacePagePositionID($uid)
- * 4442:     function isReferenceField($conf)
- * 4452:     function getTCEMAIN_TSconfig($tscPID)
- * 4466:     function getTableEntries($table,$TSconfig)
- * 4480:     function setHistory($table,$id,$logId)
- * 4517:     function clearHistory($table,$id,$keepEntries=10,$maxAgeSeconds=604800)
- * 4565:     function log($table,$recuid,$action,$recpid,$error,$details,$details_nr=0,$data=array(),$event_pid=-1,$NEWid='')
- * 4579:     function printLogErrorMessages($redirect)
- * 4641:     function clear_cacheCmd($cacheCmd)
- * 4717:     function removeCacheFiles()
+ *              SECTION: Clearing cache
+ * 4872:     function clear_cache($table,$uid)
+ * 4981:     function clear_cacheCmd($cacheCmd)
  *
- * TOTAL FUNCTIONS: 101
+ *              SECTION: Logging
+ * 5087:     function log($table,$recuid,$action,$recpid,$error,$details,$details_nr=-1,$data=array(),$event_pid=-1,$NEWid='')
+ * 5104:     function newlog($message, $error=0)
+ * 5114:     function printLogErrorMessages($redirect)
+ *
+ * TOTAL FUNCTIONS: 104
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
@@ -188,105 +209,131 @@ require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
  * - $GLOBALS['TCA'] must exist
  * - $GLOBALS['LANG'] (languageobject) may be preferred, but not fatal.
  *
- * Note: Seems like many instances of array_merge() in this class are candidates for t3lib_div::array_merge() if integer-keys will some day make trouble...
- *
- * tce_db.php for further comments and SYNTAX! Also see document 'Inside TYPO3' for details.
+ * tce_db.php for further comments and SYNTAX! Also see document 'TYPO3 Core API' for details.
  *
  * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
  */
 class t3lib_TCEmain    {
-       var $log_table = 'sys_log';
 
-       var $checkStoredRecords = 1;    // This will read the record after having updated or inserted it. If anything is not properly submitted an error is written to the log. This feature consumes extra time by selecting records
-       var $checkStoredRecords_loose=1;        // If set, values '' and 0 will equal each other when the stored records are checked.
-       var $sortIntervals = 256;               // The interval between sorting numbers used with tables with a 'sorting' field defined. Min 1
 
-       var $deleteTree = 0;                    // Boolean. If this is set, then a page is deleted by deleting the whole branch under it (user must have deletepermissions to it all). If not set, then the page is delete ONLY if it has no branch
-       var $copyTree = 0;                              // int. If 0 then branch is NOT copied. If 1 then pages on the 1st level is copied. If 2 then pages on the second level is copied ... and so on
-       var $versionizeTree = 0;                // int. If 0 then branch is NOT versionized. If 1 then pages on the 1st level is versionized. If 2 then pages on the second level is versionized ... and so on
-       var $neverHideAtCopy = 0;               // Boolean. If set, then the 'hideAtCopy' flag for tables will be ignored.
-       var $reverseOrder=0;                    // boolean. If set, the dataarray is reversed in the order, which is a nice thing if you're creating a whole new bunch of records.
-       var $copyWhichTables = '*';             // This list of tables decides which tables will be copied. If empty then none will. If '*' then all will (that the user has permission to of course)
-       var $stripslashes_values=1;             // If set, incoming values in the data-array have their slashes stripped. ALWAYS SET THIS TO ZERO and supply an unescaped data array instead. This switch may totally disappear in future versions of this class!
-       var $storeLogMessages=1;                // If set, the default log-messages will be stored. This should not be necessary if the locallang-file for the log-display is properly configured. So disabling this will just save some database-space as the default messages are not saved.
-       var $enableLogging=1;                   // If set, actions are logged.
+               // *********************
+               // Public variables you can configure before using the class:
+               // *********************
 
-       var $callBackObj;                               // Call back object for flex form traversation. Useful when external classes wants to use the iteration functions inside tcemain for traversing a FlexForm structure.
+       var $storeLogMessages = TRUE;                   // Boolean: If true, the default log-messages will be stored. This should not be necessary if the locallang-file for the log-display is properly configured. So disabling this will just save some database-space as the default messages are not saved.
+       var $enableLogging = TRUE;                              // Boolean: If true, actions are logged to sys_log.
+       var $reverseOrder = FALSE;                              // Boolean: If true, the datamap array is reversed in the order, which is a nice thing if you're creating a whole new bunch of records.
+       var $checkSimilar = TRUE;                               // Boolean: If true, only fields which are different from the database values are saved! In fact, if a whole input array is similar, it's not saved then.
+       var $stripslashes_values = TRUE;                // Boolean: If true, incoming values in the data-array have their slashes stripped. ALWAYS SET THIS TO ZERO and supply an unescaped data array instead. This switch may totally disappear in future versions of this class!
+       var $checkStoredRecords = TRUE;                 // Boolean: This will read the record after having updated or inserted it. If anything is not properly submitted an error is written to the log. This feature consumes extra time by selecting records
+       var $checkStoredRecords_loose = TRUE;   // Boolean: If set, values '' and 0 will equal each other when the stored records are checked.
+       var $deleteTree = FALSE;                                // Boolean. If this is set, then a page is deleted by deleting the whole branch under it (user must have deletepermissions to it all). If not set, then the page is deleted ONLY if it has no branch
+       var $neverHideAtCopy = FALSE;                   // Boolean. If set, then the 'hideAtCopy' flag for tables will be ignored.
+       var $dontProcessTransformations=FALSE;  // Boolean: If set, then transformations are NOT performed on the input.
 
-//     var $history=1;                                 // Bit-array: Bit0: History on/off. DEPENDS on checkSimilar to be set!
-       var $checkSimilar=1;                    // Boolean: If set, only fields which are different from the database values are saved! In fact, if a whole input array is similar, it's not saved then.
-       var $dontProcessTransformations=0;      // Boolean: If set, then transformations are NOT performed on the input.
-#      var $disableRTE = 0;                    // Boolean: If set, the RTE is expected to have been disabled in the interface which submitted information. Thus transformations related to the RTE is not done.
-
-       var $pMap = Array(              // Permission mapping
-               'show' => 1,                    // 1st bit
-               'edit' => 2,                    // 2nd bit
-               'delete' => 4,                  // 3rd bit
-               'new' => 8,                             // 4th bit
-               'editcontent' => 16             // 5th bit
-       );
-       var $defaultPermissions = array(                // Can be overridden from $TYPO3_CONF_VARS
-               'user' => 'show,edit,delete,new,editcontent',
-               'group' => 'show,edit,new,editcontent',
-               'everybody' => ''
-       );
+       var $copyWhichTables = '*';                             // String. Comma-list. This list of tables decides which tables will be copied. If empty then none will. If '*' then all will (that the user has permission to of course)
 
+       var $copyTree = 0;                                              // Integer. If 0 then branch is NOT copied. If 1 then pages on the 1st level is copied. If 2 then pages on the second level is copied ... and so on
 
-       var $alternativeFileName=array();               // Use this array to force another name onto a file. Eg. if you set ['/tmp/blablabal'] = 'my_file.txt' and '/tmp/blablabal' is set for a certain file-field, then 'my_file.txt' will be used as the name instead.
+       var $defaultValues = array();                   // Array [table][fields]=value: New records are created with default values and you can set this array on the form $defaultValues[$table][$field] = $value to override the default values fetched from TCA. If ->setDefaultsFromUserTS is called UserTSconfig default values will overrule existing values in this array (thus UserTSconfig overrules externally set defaults which overrules TCA defaults)
+       var $overrideValues = array();                  // Array [table][fields]=value: You can set this array on the form $overrideValues[$table][$field] = $value to override the incoming data. You must set this externally. You must make sure the fields in this array are also found in the table, because it's not checked. All columns can be set by this array!
+       var $alternativeFileName = array();             // Array [filename]=alternative_filename: Use this array to force another name onto a file. Eg. if you set ['/tmp/blablabal'] = 'my_file.txt' and '/tmp/blablabal' is set for a certain file-field, then 'my_file.txt' will be used as the name instead.
        var $data_disableFields=array();                // If entries are set in this array corresponding to fields for update, they are ignored and thus NOT updated. You could set this array from a series of checkboxes with value=0 and hidden fields before the checkbox with 1. Then an empty checkbox will disable the field.
-       var $defaultValues=array();                             // You can set this array on the form $defaultValues[$table][$field] = $value to override the default values fetched from TCA. You must set this externally.
-       var $overrideValues=array();                    // You can set this array on the form $overrideValues[$table][$field] = $value to override the incoming data. You must set this externally. You must make sure the fields in this array are also found in the table, because it's not checked. All columns can be set by this array!
        var $suggestedInsertUids=array();               // Use this array to validate suggested uids for tables by setting [table]:[uid]. This is a dangerous option since it will force the inserted record to have a certain UID. The value just have to be true, but if you set it to "DELETE" it will make sure any record with that UID will be deleted first (raw delete). The option is used for import of T3D files when synchronizing between two mirrored servers. As a security measure this feature is available only for Admin Users (for now)
 
-               // *********
-               // internal
-               // *********
-       var $fileFunc;          // May contain an object
-       var $last_log_id;
+       var $callBackObj;                                               // Object. Call back object for flex form traversation. Useful when external classes wants to use the iteration functions inside tcemain for traversing a FlexForm structure.
+
+
+
+
+               // *********************
+               // Internal variables (mapping arrays) which can be used (read-only) from outside
+               // *********************
+       var $autoVersionIdMap = Array();                        // Contains mapping of auto-versionized records.
+       var $substNEWwithIDs = Array();                         // When new elements are created, this array contains a map between their "NEW..." string IDs and the eventual UID they got when stored in database
+       var $substNEWwithIDs_table = Array();           // Like $substNEWwithIDs, but where each old "NEW..." id is mapped to the table it was from.
+       var $copyMappingArray_merged = Array();         // This array is the sum of all copying operations in this class. May be READ from outside, thus partly public.
+       var $copiedFileMap = Array();                           // A map between input file name and final destination for files being attached to records.
+       var     $errorLog = Array();                                    // Errors are collected in this variable.
+
+
+
+               // *********************
+               // Internal Variables, do not touch.
+               // *********************
+
+               // Variables set in init() function:
        var $BE_USER;           // The user-object the script uses. If not set from outside, this is set to the current global $BE_USER.
        var $userid;            // will be set to uid of be_user executing this script
        var $username;          // will be set to username of be_user executing this script
        var $admin;                     // will be set if user is admin
-       var $exclude_array;     // the list of <table>-<fields> that cannot be edited. This is compiled from TCA/exclude-flag combined with non_exclude_fields for the user.
-
-       var $data = Array();
-       var $datamap = Array();
-       var $cmd = Array();
-       var $cmdmap = Array();
-       var $uploadedFileArray = array();
-
-       var $cachedTSconfig = array();
-       var $substNEWwithIDs = Array();
-       var $substNEWwithIDs_table = Array();
-       var $autoVersionIdMap = array();                        // Contains mapping of auto-versionized records.
-       var $recUpdateAccessCache = Array();    // Used by function checkRecordUpdateAccess() to store whether a record is updateable or not.
-       var $recInsertAccessCache = Array();
-       var $isRecordInWebMount_Cache=array();
-       var $isInWebMount_Cache=array();
+
+       var $defaultPermissions = array(                // Can be overridden from $TYPO3_CONF_VARS
+               'user' => 'show,edit,delete,new,editcontent',
+               'group' => 'show,edit,new,editcontent',
+               'everybody' => ''
+       );
+
+       var $exclude_array;                     // The list of <table>-<fields> that cannot be edited by user. This is compiled from TCA/exclude-flag combined with non_exclude_fields for the user.
+       var $datamap = Array();         // Set with incoming data array
+       var $cmdmap = Array();          // Set with incoming cmd array
+
+               // Internal static:
+       var $pMap = Array(              // Permission mapping
+               'show' => 1,                    // 1st bit
+               'edit' => 2,                    // 2nd bit
+               'delete' => 4,                  // 3rd bit
+               'new' => 8,                             // 4th bit
+               'editcontent' => 16             // 5th bit
+       );
+       var $sortIntervals = 256;                                       // Integer: The interval between sorting numbers used with tables with a 'sorting' field defined. Min 1
+
+               // Internal caching arrays
+       var $recUpdateAccessCache = Array();            // Used by function checkRecordUpdateAccess() to store whether a record is updateable or not.
+       var $recInsertAccessCache = Array();            // User by function checkRecordInsertAccess() to store whether a record can be inserted on a page id
+       var $isRecordInWebMount_Cache=array();          // Caching array for check of whether records are in a webmount
+       var $isInWebMount_Cache=array();                        // Caching array for page ids in webmounts
+       var $cachedTSconfig = array();                          // Caching for collecting TSconfig for page ids
        var $pageCache = Array();                                       // Used for caching page records in pageInfo()
-       var $copyMappingArray = Array();                        // Use by the copy action to track the ids of new pages so subpages are correctly inserted!
-       var $copyMappingArray_merged = Array();         // This array is the sum of all copying operations in this class. May be READ from outside, thus partly public.
-       var $registerDBList=array();
-       var $dbAnalysisStore=array();
-       var $removeFilesStore=array();
-       var $copiedFileMap=array();
+       var $checkWorkspaceCache = Array();                     // Array caching workspace access for BE_USER
 
+               // Other arrays:
+       var $dbAnalysisStore=array();                           // For accumulation of MM relations that must be written after new records are created.
+       var $removeFilesStore=array();                          // For accumulation of files which must be deleted after processing of all input content
+       var $uploadedFileArray = array();                       // Uploaded files, set by process_uploads()
+       var $registerDBList=array();                            // Used for tracking references that might need correction after operations
+       var $copyMappingArray = Array();                        // Used by the copy action to track the ids of new pages so subpages are correctly inserted! THIS is internally cleared for each executed copy operation! DO NOT USE THIS FROM OUTSIDE! Read from copyMappingArray_merged instead which is accumulating this information.
+
+               // Various
+       var $fileFunc;                                                          // For "singleTon" file-manipulation object
        var $checkValue_currentRecord=array();          // Set to "currentRecord" during checking of values.
 
 
+
+
+
+
+
+
+
+
+
+
+
        /**
         * Initializing.
         * For details, see 'TYPO3 Core API' document.
         * This function does not start the processing of data, but merely initializes the object
         *
         * @param       array           Data to be modified or inserted in the database
-        * @param       array           Commands to copy, move, delete records.
+        * @param       array           Commands to copy, move, delete, localize, versionize records.
         * @param       object          An alternative userobject you can set instead of the default, which is $GLOBALS['BE_USER']
         * @return      void
         */
        function start($data,$cmd,$altUserObject='')    {
+
                        // Initializing BE_USER
                $this->BE_USER = is_object($altUserObject) ? $altUserObject : $GLOBALS['BE_USER'];
                $this->userid = $this->BE_USER->user['uid'];
@@ -300,7 +347,7 @@ class t3lib_TCEmain {
                if (isset($defaultPermissions['everybody']))            {$this->defaultPermissions['everybody'] = $defaultPermissions['everybody'];}
 
                        // generates the excludelist, based on TCA/exclude-flag and non_exclude_fields for the user:
-               $this->exclude_array = ($this->admin) ? array() : $this->getExcludeListArray();
+               $this->exclude_array = $this->admin ? array() : $this->getExcludeListArray();
 
                        // Setting the data and cmd arrays
                if (is_array($data)) {
@@ -314,7 +361,8 @@ class t3lib_TCEmain {
        }
 
        /**
-        * [Describe function...]
+        * Function that can mirror input values in datamap-array to other uid numbers.
+        * Example: $mirror[table][11] = '22,33' will look for content in $this->datamap[table][11] and copy it to $this->datamap[table][22] and $this->datamap[table][33]
         *
         * @param       array           This array has the syntax $mirror[table_name][uid] = [list of uids to copy data-value TO!]
         * @return      void
@@ -373,7 +421,7 @@ class t3lib_TCEmain {
 
                                // Editing frozen:
                        if ($this->BE_USER->workspace!==0 && $this->BE_USER->workspaceRec['freeze'])    {
-                               $this->log('',0,4,0,1,'All editing in this workspace has been frozen!');
+                               $this->newlog('All editing in this workspace has been frozen!',1);
                                return FALSE;
                        }
 
@@ -446,7 +494,7 @@ class t3lib_TCEmain {
 
                        // Editing frozen:
                if ($this->BE_USER->workspace!==0 && $this->BE_USER->workspaceRec['freeze'])    {
-                       $this->log('',0,4,0,1,'All editing in this workspace has been frozen!');
+                       $this->newlog('All editing in this workspace has been frozen!',1);
                        return FALSE;
                }
 
@@ -458,7 +506,7 @@ class t3lib_TCEmain {
                        }
                }
 
-                       // Organize tables so that the pages-table are always processed first. This is required if you want to make sure that content pointing to a new page will be created.
+                       // Organize tables so that the pages-table is always processed first. This is required if you want to make sure that content pointing to a new page will be created.
                $orderOfTables = Array();
                if (isset($this->datamap['pages']))     {               // Set pages first.
                        $orderOfTables[]='pages';
@@ -474,7 +522,7 @@ class t3lib_TCEmain {
                foreach($orderOfTables as $table)       {
                                /* Check if
                                        - table is set in $TCA,
-                                       - table is NOT readOnly,
+                                       - table is NOT readOnly
                                        - the table is set with content in the data-array (if not, there's nothing to process...)
                                        - permissions for tableaccess OK
                                */
@@ -506,6 +554,7 @@ class t3lib_TCEmain {
                                                $createNewVersion = FALSE;
                                                $recordAccess = FALSE;
                                                $old_pid_value = '';
+                                               $resetRejected = FALSE;
                                                if (!t3lib_div::testInt($id)) {               // Is it a new record? (Then Id is a string)
                                                        $fieldArray = $this->newFieldArray($table);     // Get a fieldArray with default values
                                                        if (isset($incomingFieldArray['pid']))  {       // A pid must be set for new records.
@@ -519,8 +568,8 @@ class t3lib_TCEmain {
                                                                        if (isset($this->substNEWwithIDs[$pid_value]))  {       // Trying to find the correct numerical value as it should be mapped by earlier processing of another new record.
                                                                                $old_pid_value = $pid_value;
                                                                                $pid_value=intval($negFlag*$this->substNEWwithIDs[$pid_value]);
-                                                                       } else {$OK = 0;}       // If not found in the substArray we must stop the proces...
-                                                               } elseif ($pid_value>=0 && $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 o (zero = page+content) and if so, change the pid to the uid of that version.
+                                                                       } else {$OK = 0;}       // If not found in the substArray we must stop the process...
+                                                               } elseif ($pid_value>=0 && $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_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'];
@@ -550,17 +599,26 @@ class t3lib_TCEmain       {
                                                                }
                                                        }
                                                        $theRealPid = $fieldArray['pid'];
+
                                                                // Now, check if we may insert records on this pid.
                                                        if ($theRealPid>=0)     {
                                                                $recordAccess = $this->checkRecordInsertAccess($table,$theRealPid);             // Checks if records can be inserted on this $pid.
+                                                               if ($recordAccess)      {
 
-                                                                       // If records cannot be created in the current PID due to workspace restrictions, prepare creation of placeholder-record
-                                                               if ($recordAccess && !$this->BE_USER->workspaceTestPID($theRealPid,$table))     {
-                                                                       if ($TCA[$table]['ctrl']['versioningWS'])       {
-                                                                               $createNewVersion = TRUE;
-                                                                       } else {
-                                                                               $recordAccess = FALSE;
-                                                                               $this->log($table,$id,2,0,1,'Record could not be created in this workspace in this branch');
+                                                                       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);
+                                                                               }
+                                                                       } 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);
+                                                                               }
                                                                        }
                                                                }
                                                        } else {
@@ -577,46 +635,41 @@ class t3lib_TCEmain       {
                                                                $recordAccess = $this->BE_USER->recordEditAccessInternals($table,$id);
                                                                if (!$recordAccess)             {
                                                                        $propArr = $this->getRecordProperties($table,$id);
-                                                                       $this->log($table,$id,2,0,1,"recordEditAccessInternals() check failed. [".$this->BE_USER->errorMsg."]",2,array($propArr['header'],$table.':'.$id),$propArr['event_pid']);
+                                                                       $this->newlog("recordEditAccessInternals() check failed. [".$this->BE_USER->errorMsg."]",1);
                                                                } else {        // Here we fetch the PID of the record that we point to...
-                                                                       $tempdata = $this->recordInfo($table,$id,'pid'.($TCA[$table]['ctrl']['versioningWS']?',t3ver_wsid':''));
+                                                                       $tempdata = $this->recordInfo($table,$id,'pid'.($TCA[$table]['ctrl']['versioningWS']?',t3ver_wsid,t3ver_stage':''));
                                                                        $theRealPid = $tempdata['pid'];
 
+                                                                               // Prepare the reset of the rejected flag if set:
+                                                                       if ($TCA[$table]['ctrl']['versioningWS'] && $tempdata['t3ver_stage']<0) {
+                                                                               $resetRejected = TRUE;
+                                                                       }
+
                                                                                // Checking access in case of offline workspace:
-                                                                       if ($errorCode = $this->BE_USER->workspaceEditState($table,$theRealPid,$tempdata['t3ver_wsid']))        {
+                                                                       if ($errorCode = $this->BE_USER->workspaceCannotEditRecord($table,$tempdata))   {
+                                                                               $recordAccess = FALSE;          // Versioning is required and it must be offline version!
 
                                                                                        // 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 ($TCA[$table]['ctrl']['versioningWS']
-                                                                                               && $theRealPid >= 0
-                                                                                               && !t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, $table, $id, 'uid'))   {       // If offline workspace:
-                                                                                       if (!$this->BE_USER->workspaceRec['disable_autocreate'])        {
-                                                                                               $tce = t3lib_div::makeInstance('t3lib_TCEmain');
-                                                                                               $tce->stripslashes_values = 0;
-
-                                                                                                       // Setting up command for creating a new version of the record:
-                                                                                               $cmd = array();
-                                                                                               $cmd[$table][$id]['version'] = array(
-                                                                                                       'action' => 'new',
-                                                                                                       'treeLevels' => -1,     // Default is to create a version of the individual records...
-                                                                                                       'label' => 'Auto-created for WS #'.$this->BE_USER->workspace
-                                                                                               );
-                                                                                               $tce->start(array(),$cmd);
-                                                                                               $tce->process_cmdmap();
-
-                                                                                               if ($tce->copyMappingArray[$table][$id])        {
-                                                                                                       $id = $this->autoVersionIdMap[$table][$id] = $tce->copyMappingArray[$table][$id];
-                                                                                               } else {
-                                                                                                       $this->log($table,$id,2,0,1,"Auto-creation of version failed!");
-                                                                                                       $recordAccess = FALSE;          // Versioning is required and it must be offline version!
-                                                                                               }
-                                                                                       } else {
-                                                                                               $this->log($table,$id,2,0,1,"Auto-creation of version not allowed in workspace!");
-                                                                                               $recordAccess = FALSE;          // Versioning is required and it must be offline version!
-                                                                                       }
-                                                                               } else {
-                                                                                       $this->log($table,$id,2,0,1,"Could not be edited in offline workspace in the branch where found (failure state ".$errorCode.").",2,array($propArr['header'],$table.':'.$id),$propArr['event_pid']);
-                                                                                       $recordAccess = FALSE;          // Versioning is required and it must be offline version!
-                                                                               }
+                                                                               if ($this->BE_USER->workspaceAllowAutoCreation($table,$id,$theRealPid)) {
+                                                                                       $tce = t3lib_div::makeInstance('t3lib_TCEmain');
+                                                                                       $tce->stripslashes_values = 0;
+
+                                                                                               // Setting up command for creating a new version of the record:
+                                                                                       $cmd = array();
+                                                                                       $cmd[$table][$id]['version'] = array(
+                                                                                               'action' => 'new',
+                                                                                               'treeLevels' => -1,     // Default is to create a version of the individual records...
+                                                                                               'label' => 'Auto-created for WS #'.$this->BE_USER->workspace
+                                                                                       );
+                                                                                       $tce->start(array(),$cmd);
+                                                                                       $tce->process_cmdmap();
+                                                                                       $this->errorLog = array_merge($this->errorLog,$tce->errorLog);
+
+                                                                                       if ($tce->copyMappingArray[$table][$id])        {
+                                                                                               $id = $this->autoVersionIdMap[$table][$id] = $tce->copyMappingArray[$table][$id];
+                                                                                               $recordAccess = TRUE;
+                                                                                       } else $this->newlog("Could not be edited in offline workspace in the branch where found (failure state: '".$errorCode."'). Auto-creation of version failed!",1);
+                                                                               } else $this->newlog("Could not be edited in offline workspace in the branch where found (failure state: '".$errorCode."'). Auto-creation of version not allowed in workspace!",1);
                                                                        }
                                                                }
                                                        }
@@ -628,18 +681,25 @@ class t3lib_TCEmain       {
                                                        // **************************************
                                                if ($recordAccess)      {
 
-                                                       list($tscPID) = t3lib_BEfunc::getTSCpid($table,$id,$old_pid_value ? $old_pid_value : $fieldArray['pid']);       // Here the "pid" is sent IF NOT the old pid was a string pointing to a place in the subst-id array.
+                                                       list($tscPID) = t3lib_BEfunc::getTSCpid($table,$id,$old_pid_value ? $old_pid_value : $fieldArray['pid']);       // Here the "pid" is set IF NOT the old pid was a string pointing to a place in the subst-id array.
                                                        $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
                                                        if ($status=='new' && $table=='pages' && is_array($TSConfig['permissions.']))   {
                                                                $fieldArray = $this->setTSconfigPermissions($fieldArray,$TSConfig['permissions.']);
                                                        }
-                                                       if ($createNewVersion)  $newVersion_placeholderFieldArray = $fieldArray;
+                                                       if ($createNewVersion)  {
+                                                               $newVersion_placeholderFieldArray = $fieldArray;
+                                                       }
+
+                                                               // Processing of all fields in incomingFieldArray and setting them in $fieldArray
                                                        $fieldArray = $this->fillInFieldArray($table,$id,$fieldArray,$incomingFieldArray,$theRealPid,$status,$tscPID);
 
                                                                // NOTICE! All manipulation beyond this point bypasses both "excludeFields" AND possible "MM" relations / file uploads to field!
 
+                                                               // Forcing some values unto field array:
                                                        $fieldArray = $this->overrideFieldArray($table,$fieldArray);    // NOTICE: This overriding is potentially dangerous; permissions per field is not checked!!!
-                                                       if ($createNewVersion)  $newVersion_placeholderFieldArray = $this->overrideFieldArray($table,$newVersion_placeholderFieldArray);
+                                                       if ($createNewVersion)  {
+                                                               $newVersion_placeholderFieldArray = $this->overrideFieldArray($table,$newVersion_placeholderFieldArray);
+                                                       }
 
                                                                // Setting system fields
                                                        if ($status=='new')     {
@@ -658,6 +718,9 @@ class t3lib_TCEmain {
                                                                $fieldArray[$TCA[$table]['ctrl']['tstamp']]=time();
                                                                if ($createNewVersion)  $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['tstamp']]=time();
                                                        }
+                                                       if ($resetRejected)     {
+                                                               $fieldArray['t3ver_stage'] = 0;
+                                                       }
 
                                                                // Hook: processDatamap_postProcessFieldArray
                                                        foreach($hookObjectsArr as $hookObj)    {
@@ -671,21 +734,24 @@ 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
-                                                                               $newVersion_placeholderFieldArray['t3ver_label'] = 'INITIAL PLACEHOLDER';
-                                                                               $newVersion_placeholderFieldArray['t3ver_state'] = 1;   // Setting placeholder state value for temporary record
-                                                                               $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['label']] = '[PLACEHOLDER]';
-                                                                               $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_label'] = 'First offline 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'] = 1;
-                                                                               }
-                                                                               $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!
+                                                                               $versioningType = $table==='pages' ? $this->BE_USER->workspaceVersioningTypeGetClosest(t3lib_div::intInRange($TYPO3_CONF_VARS['BE']['newPagesVersioningType'],-1,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[$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_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;
+                                                                                       }
+                                                                                       $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!
+                                                                               } else $this->newlog('Versioning type "'.$versioningType.'" was not allowed, so could not create new record.',1);
                                                                        } else {
                                                                                $this->insertDB($table,$id,$fieldArray,FALSE,$incomingFieldArray['uid']);
                                                                        }
@@ -815,6 +881,7 @@ class t3lib_TCEmain {
                                                case 't3ver_state':
                                                case 't3ver_swapmode':
                                                case 't3ver_count':
+                                               case 't3ver_stage':
                                                case 't3ver_tstamp':
                                                        // t3ver_label is not here because it CAN be edited as a regular field!
                                                break;
@@ -910,1412 +977,619 @@ class t3lib_TCEmain    {
                return $fieldArray;
        }
 
-       /**
-        * Checking group modify_table access list
-        *
-        * Returns true if the user has general access to modify the $table
-        *
-        * @param       [type]          $table: ...
-        * @return      [type]          ...
-        */
-       function checkModifyAccessList($table)  {
-               $res = ($this->admin || (!$this->tableAdminOnly($table) && t3lib_div::inList($this->BE_USER->groupData['tables_modify'],$table)));
-               return $res;
-       }
 
-       /**
-        * [Describe function...]
-        *
-        * @param       [type]          $table: ...
-        * @param       [type]          $id: ...
-        * @return      [type]          ...
-        */
-       function isRecordInWebMount($table,$id) {
-               if (!isset($this->isRecordInWebMount_Cache[$table.':'.$id]))    {
-                       $recP=$this->getRecordProperties($table,$id);
-                       $this->isRecordInWebMount_Cache[$table.':'.$id]=$this->isInWebMount($recP['event_pid']);
-               }
-               return $this->isRecordInWebMount_Cache[$table.':'.$id];
-       }
 
-       /**
-        * [Describe function...]
-        *
-        * @param       [type]          $pid: ...
-        * @return      [type]          ...
-        */
-       function isInWebMount($pid)     {
-               if (!isset($this->isInWebMount_Cache[$pid]))    {
-                       $this->isInWebMount_Cache[$pid]=$this->BE_USER->isInWebMount($pid);
-               }
-//debug($this->isInWebMount_Cache);
-               return $this->isInWebMount_Cache[$pid];
-       }
 
-       /**
-        * Checks if user may update a certain record.
+
+
+
+
+
+
+
+
+       /*********************************************
         *
-        * Returns true if the user may update the record given by $table and $id
+        * Evaluation of input values
         *
-        * @param       [type]          $table: ...
-        * @param       [type]          $id: ...
-        * @return      [type]          ...
-        */
-       function checkRecordUpdateAccess($table,$id)    {
-               global $TCA;
-               $res = 0;
-               if ($TCA[$table] && intval($id)>0)      {
-                       if (isset($this->recUpdateAccessCache[$table][$id]))    {       // If information is cached, return it
-                               return $this->recUpdateAccessCache[$table][$id];
-                               // Check if record exists and 1) if 'pages' the page may be edited, 2) if page-content the page allows for editing
-                       } elseif ($this->doesRecordExist($table,$id,'edit'))    {
-                               $res = 1;
-                       }
-                       $this->recUpdateAccessCache[$table][$id]=$res;  // Cache the result
-               }
-               return $res;
-       }
+        ********************************************/
 
        /**
-        * Checks if user may insert a certain record.
-        *
-        * Returns true if the user may insert a record from table $insertTable on page $pid
+        * Evaluates a value according to $table/$field settings.
+        * This function is for real database fields - NOT FlexForm "pseudo" fields.
+        * NOTICE: Calling this function expects this: 1) That the data is saved! (files are copied and so on) 2) That files registered for deletion IS deleted at the end (with ->removeRegisteredFiles() )
         *
-        * @param       [type]          $insertTable: ...
-        * @param       [type]          $pid: ...
-        * @param       [type]          $action: ...
-        * @return      [type]          ...
+        * @param       string          Table name
+        * @param       string          Field name
+        * @param       string          Value to be evaluated. Notice, this is the INPUT value from the form. The original value (from any existing record) must be manually looked up inside the function if needed - or taken from $currentRecord array.
+        * @param       string          The record-uid, mainly - but not exclusively - used for logging
+        * @param       string          'update' or 'new' flag
+        * @param       integer         The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
+        * @param       integer         $tscPID
+        * @return      array           Returns the evaluated $value as key "value" in this array. Can be checked with isset($res['value']) ...
         */
-       function checkRecordInsertAccess($insertTable,$pid,$action=1)   {
-               global $TCA;
-               $res = 0;
-               $pid = intval($pid);
-               if ($pid>=0)    {
-                       if (isset($this->recInsertAccessCache[$insertTable][$pid]))     {       // If information is cached, return it
-                               return $this->recInsertAccessCache[$insertTable][$pid];
-                       } else {
-                                       // If either admin and root-level or if page record exists and 1) if 'pages' you may create new ones 2) if page-content, new content items may be inserted on the $pid page
-                               if ( (!$pid && $this->admin) || $this->doesRecordExist('pages',$pid,($insertTable=='pages'?$this->pMap['new']:$this->pMap['editcontent'])) )    {               // Check permissions
-                                       if ($this->isTableAllowedForThisPage($pid, $insertTable))       {
-                                               $res = 1;
-                                               $this->recInsertAccessCache[$insertTable][$pid]=$res;   // Cache the result
-                                       } else {
-                                               $propArr = $this->getRecordProperties('pages',$pid);
-                                               $this->log($insertTable,$pid,$action,0,1,"Attempt to insert record on page '%s' (%s) where this table, %s, is not allowed",11,array($propArr['header'],$pid,$insertTable),$propArr['event_pid']);
+       function checkValue($table,$field,$value,$id,$status,$realPid,$tscPID)  {
+               global $TCA, $PAGES_TYPES;
+               t3lib_div::loadTCA($table);
+
+               $res = Array(); // result array
+               $recFID = $table.':'.$id.':'.$field;
+
+                       // Processing special case of field pages.doktype
+               if ($table=='pages' && $field=='doktype')       {
+                               // If the user may not use this specific doktype, we issue a warning
+                       if (! ($this->admin || t3lib_div::inList($this->BE_USER->groupData['pagetypes_select'],$value)))        {
+                               $propArr = $this->getRecordProperties($table,$id);
+                               $this->log($table,$id,5,0,1,"You cannot change the 'doktype' of page '%s' to the desired value.",1,array($propArr['header']),$propArr['event_pid']);
+                               return $res;
+                       };
+                       if ($status=='update')  {
+                                       // This checks 1) if we should check for disallowed tables and 2) if there are records from disallowed tables on the current page
+                               $onlyAllowedTables = isset($PAGES_TYPES[$value]['onlyAllowedTables']) ? $PAGES_TYPES[$value]['onlyAllowedTables'] : $PAGES_TYPES['default']['onlyAllowedTables'];
+                               if ($onlyAllowedTables) {
+                                       $theWrongTables = $this->doesPageHaveUnallowedTables($id,$value);
+                                       if ($theWrongTables)    {
+                                               $propArr = $this->getRecordProperties($table,$id);
+                                               $this->log($table,$id,5,0,1,"'doktype' of page '%s' could not be changed because the page contains records from disallowed tables; %s",2,array($propArr['header'],$theWrongTables),$propArr['event_pid']);
+                                               return $res;
                                        }
-                               } else {
-                                       $propArr = $this->getRecordProperties('pages',$pid);
-                                       $this->log($insertTable,$pid,$action,0,1,"Attempt to insert a record on page '%s' (%s) from table '%s' without permissions. Or non-existing page.",12,array($propArr['header'],$pid,$insertTable),$propArr['event_pid']);
                                }
                        }
                }
+
+                       // Get current value:
+               $curValueRec = $this->recordInfo($table,$id,$field);
+               $curValue = $curValueRec[$field];
+
+                       // Getting config for the field
+               $tcaFieldConf = $TCA[$table]['columns'][$field]['config'];
+
+                       // Preform processing:
+               $res = $this->checkValue_SW($res,$value,$tcaFieldConf,$table,$id,$curValue,$status,$realPid,$recFID,$field,$this->uploadedFileArray[$table][$id][$field],$tscPID);
+
                return $res;
        }
 
        /**
-        * Checks is a table is allowed on a certain page.
-        *
-        * $checkTable is the tablename
-        * $page_uid is the uid of the page to check
+        * Branches out evaluation of a field value based on its type as configured in TCA
+        * Can be called for FlexForm pseudo fields as well, BUT must not have $field set if so.
         *
-        * @param       [type]          $page_uid: ...
-        * @param       [type]          $checkTable: ...
-        * @return      [type]          ...
+        * @param       array           The result array. The processed value (if any!) is set in the "value" key.
+        * @param       string          The value to set.
+        * @param       array           Field configuration from TCA
+        * @param       string          Table name
+        * @param       integer         Return UID
+        * @param       [type]          $curValue: ...
+        * @param       [type]          $status: ...
+        * @param       integer         The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
+        * @param       [type]          $recFID: ...
+        * @param       string          Field name. Must NOT be set if the call is for a flexform field (since flexforms are not allowed within flexforms).
+        * @param       [type]          $uploadedFiles: ...
+        * @param       [type]          $tscPID: ...
+        * @return      array           Returns the evaluated $value as key "value" in this array.
         */
-       function isTableAllowedForThisPage($page_uid, $checkTable)      {
-               global $TCA, $PAGES_TYPES;
-               $page_uid = intval($page_uid);
+       function checkValue_SW($res,$value,$tcaFieldConf,$table,$id,$curValue,$status,$realPid,$recFID,$field,$uploadedFiles,$tscPID)   {
 
-                       // Check if rootLevel flag is set and we're trying to insert on rootLevel - and reversed - and that the table is not "pages" which are allowed anywhere.
-               if (($TCA[$checkTable]['ctrl']['rootLevel'] xor !$page_uid) && $TCA[$checkTable]['ctrl']['rootLevel']!=-1 && $checkTable!='pages')      {
-                       return false;
-               }
+               $PP = array($table,$id,$curValue,$status,$realPid,$recFID,$tscPID);
 
-                       // Check root-level
-               if (!$page_uid) {
-                       if ($this->admin)       {
-                               return true;
-                       }
-               } else {
-                               // Check non-root-level
-                       $doktype = $this->pageInfo($page_uid,'doktype');
-                       $allowedTableList = isset($PAGES_TYPES[$doktype]['allowedTables']) ? $PAGES_TYPES[$doktype]['allowedTables'] : $PAGES_TYPES['default']['allowedTables'];
-                       $allowedArray = t3lib_div::trimExplode(',',$allowedTableList,1);
-                       if (strstr($allowedTableList,'*') || in_array($checkTable,$allowedArray))       {               // If all tables or the table is listed as a allowed type, return true
-                               return true;
-                       }
-               }
+               switch ($tcaFieldConf['type']) {
+                       case 'text':
+                       case 'passthrough':
+                       case 'user':
+                               $res['value'] = $value;
+                       break;
+                       case 'input':
+                               $res = $this->checkValue_input($res,$value,$tcaFieldConf,$PP,$field);
+                       break;
+                       case 'check':
+                               $res = $this->checkValue_check($res,$value,$tcaFieldConf,$PP);
+                       break;
+                       case 'radio':
+                               $res = $this->checkValue_radio($res,$value,$tcaFieldConf,$PP);
+                       break;
+                       case 'group':
+                       case 'select':
+                               $res = $this->checkValue_group_select($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field);
+                       break;
+                       case 'flex':
+                               if ($field)     {       // FlexForms are only allowed for real fields.
+                                       $res = $this->checkValue_flex($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field);
+                               }
+                       break;
+                       default:
+                               #debug(array($tcaFieldConf,$res,$value),'NON existing field type:');
+                       break;
+               }
+
+               return $res;
        }
 
        /**
-        * Checks if record exists
-        *
-        * Returns true if the record given by $table, $id and $perms
+        * Evaluate "input" type values.
         *
-        * @param       string          Record table name
-        * @param       integer         Record UID
-        * @param       mixed           Permission restrictions to observe: Either an integer that will be bitwise AND'ed or a string, which points to a key in the ->pMap array
-        * @return      [type]          ...
+        * @param       array           The result array. The processed value (if any!) is set in the "value" key.
+        * @param       string          The value to set.
+        * @param       array           Field configuration from TCA
+        * @param       array           Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
+        * @param       string          Field name
+        * @return      array           Modified $res array
         */
-       function doesRecordExist($table,$id,$perms)     {
-               global $TCA;
+       function checkValue_input($res,$value,$tcaFieldConf,$PP,$field='')      {
+               list($table,$id,$curValue,$status,$realPid,$recFID) = $PP;
 
-               $res = 0;
-               $id = intval($id);
+                       // Secures the string-length to be less than max. Will probably make problems with multi-byte strings!
+               if (intval($tcaFieldConf['max'])>0)     {$value = substr($value,0,intval($tcaFieldConf['max']));}
 
-                       // Processing the incoming $perms (from possible string to integer that can be AND'ed)
-               if (!t3lib_div::testInt($perms))        {
-                       if ($table!='pages')    {
-                               switch($perms)  {
-                                       case 'edit':
-                                       case 'delete':
-                                       case 'new':
-                                               $perms = 'editcontent';         // This holds it all in case the record is not page!!
-                                       break;
-                               }
-                       }
-                       $perms = intval($this->pMap[$perms]);
-               } else {
-                       $perms = intval($perms);
+                       // Checking range of value:
+               if ($tcaFieldConf['range'] && $value!=$tcaFieldConf['checkbox'])        {       // If value is not set to the allowed checkbox-value then it is checked against the ranges
+                       if (isset($tcaFieldConf['range']['upper'])&&$value>$tcaFieldConf['range']['upper'])     {$value=$tcaFieldConf['range']['upper'];}
+                       if (isset($tcaFieldConf['range']['lower'])&&$value<$tcaFieldConf['range']['lower'])     {$value=$tcaFieldConf['range']['lower'];}
                }
 
-               if (!$perms)    {debug('Internal ERROR: no permissions to check for non-admin user.');}
-
-                       // For all tables: Check if record exists:
-                       // Notice: If $perms are 0 (zero) no perms-clause is added!
-               if (is_array($TCA[$table]) && $id>0 && ($this->isRecordInWebMount($table,$id) || $this->admin)) {
-                       if ($table != 'pages')  {
-
-                                       // Find record without checking page:
-                               $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,pid', $table, 'uid='.intval($id).$this->deleteClause($table));
-                               $output = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres);
-                               t3lib_BEfunc::fixVersioningPid($table,$output);
-
-                                       // If record found, check page as well:
-                               if (is_array($output))  {
-
-                                               // Looking up the page for record:
-                                       $mres = $this->doesRecordExist_pageLookUp($output['pid'], $perms);
-                                       $pageRec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres);
+                       // Process evaluation settings:
+               $evalCodesArray = t3lib_div::trimExplode(',',$tcaFieldConf['eval'],1);
+               $res = $this->checkValue_input_Eval($value,$evalCodesArray,$tcaFieldConf['is_in']);
 
-                                               // Return true if either a page was found OR if the PID is zero AND the user is ADMIN (in which case the record is at root-level):
-                                       if (is_array($pageRec) || (!$output['pid'] && $this->admin))    {
-                                               return TRUE;
-                                       }
-                               }
-                               return FALSE;
-                       } else {
-                               $mres = $this->doesRecordExist_pageLookUp($id, $perms);
-                               return $GLOBALS['TYPO3_DB']->sql_num_rows($mres);
+                       // Process UNIQUE settings:
+               if ($field && $realPid>=0)      {       // Field is NOT set for flexForms - which also means that uniqueInPid and unique is NOT available for flexForm fields! Also getUnique should not be done for versioning and if PID is -1 ($realPid<0) then versioning is happening...
+                       if ($res['value'] && in_array('uniqueInPid',$evalCodesArray))   {
+                               $res['value'] = $this->getUnique($table,$field,$res['value'],$id,$realPid);
+                       }
+                       if ($res['value'] && in_array('unique',$evalCodesArray))        {
+                               $res['value'] = $this->getUnique($table,$field,$res['value'],$id);
                        }
                }
+
+               return $res;
        }
 
        /**
-        * Looks up a page based on permissions.
+        * Evaluates 'check' type values.
         *
-        * @param       integer         Page id
-        * @param       integer         Permission integer
-        * @return      pointer         MySQL result pointer (from exec_SELECTquery())
-        * @access private
-        * @see doesRecordExist()
+        * @param       array           The result array. The processed value (if any!) is set in the 'value' key.
+        * @param       string          The value to set.
+        * @param       array           Field configuration from TCA
+        * @param       array           Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
+        * @return      array           Modified $res array
         */
-       function doesRecordExist_pageLookUp($id, $perms)        {
-               global $TCA;
+       function checkValue_check($res,$value,$tcaFieldConf,$PP)        {
+               list($table,$id,$curValue,$status,$realPid,$recFID) = $PP;
 
-               return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                       'uid',
-                       'pages',
-                       'uid='.intval($id).
-                               $this->deleteClause('pages').
-                               ($perms && !$this->admin ? ' AND '.$this->BE_USER->getPagePermsClause($perms) : '').
-                               (!$this->admin && $TCA['pages']['ctrl']['editlock'] && ($perms & (2+4+16)) ? ' AND '.$TCA['pages']['ctrl']['editlock'].'=0':'') // admin users don't need check
-               );
+               $itemC = count($tcaFieldConf['items']);
+               if (!$itemC)    {$itemC=1;}
+               $maxV = pow(2,$itemC);
+
+               if ($value<0)   {$value=0;}
+               if ($value>$maxV)       {$value=$maxV;}
+               $res['value'] = $value;
+
+               return $res;
        }
 
        /**
-        * Checks if a whole branch of pages exists
-        *
-        * Tests the branch under $pid (like doesRecordExist). It doesn't test the page with $pid as uid. Use doesRecordExist() for this purpose
-        * Returns an ID-list or "" if OK. Else -1 which means that somewhere there was no permission (eg. to delete).
-        * if $recurse is set, then the function will follow subpages. This MUST be set, if we need the idlist for deleting pages or else we get an incomplete list
+        * Evaluates 'radio' type values.
         *
-        * @param       [type]          $inList: ...
-        * @param       [type]          $pid: ...
-        * @param       [type]          $perms: ...
-        * @param       [type]          $recurse: ...
-        * @return      [type]          ...
+        * @param       array           The result array. The processed value (if any!) is set in the 'value' key.
+        * @param       string          The value to set.
+        * @param       array           Field configuration from TCA
+        * @param       array           Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
+        * @return      array           Modified $res array
         */
-       function doesBranchExist($inList,$pid,$perms, $recurse) {
-               global $TCA;
-               $pid = intval($pid);
-               $perms = intval($perms);
-               if ($pid>=0)    {
-                       $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                               'uid, perms_userid, perms_groupid, perms_user, perms_group, perms_everybody',
-                                               'pages',
-                                               'pid='.intval($pid).$this->deleteClause('pages'),
-                                               '',
-                                               'sorting'
-                                       );
-                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres))     {
-                               if ($this->admin || $this->BE_USER->doesUserHaveAccess($row,$perms))    {       // IF admin, then it's OK
-                                       $inList.=$row['uid'].',';
-                                       if ($recurse)   {       // Follow the subpages recursively...
-                                               $inList = $this->doesBranchExist($inList, $row['uid'], $perms, $recurse);
-                                               if ($inList == -1)      {return -1;}            // No permissions somewhere in the branch
-                                       }
-                               } else {
-                                       return -1;              // No permissions
+       function checkValue_radio($res,$value,$tcaFieldConf,$PP)        {
+               list($table,$id,$curValue,$status,$realPid,$recFID) = $PP;
+
+               if (is_array($tcaFieldConf['items']))   {
+                       foreach($tcaFieldConf['items'] as $set) {
+                               if (!strcmp($set[1],$value))    {
+                                       $res['value'] = $value;
+                                       break;
                                }
                        }
                }
-               return $inList;
-       }
 
-       /**
-        * Returns the value of the $field from page $id
-        * NOTICE; the function caches the result for faster delivery next time. You can use this function repeatedly without performanceloss since it doesn't look up the same record twice!
-        *
-        * @param       integer         Page uid
-        * @param       string          Field name for which to return value
-        * @return      string          Value of the field. Result is cached in $this->pageCache[$id][$field] and returned from there next time!
-        */
-       function pageInfo($id,$field)   {
-               if (!isset($this->pageCache[$id]))      {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid='.intval($id));
-                       if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
-                               $this->pageCache[$id] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
-                       }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
-               }
-               return $this->pageCache[$id][$field];
+               return $res;
        }
 
        /**
-        * Returns the row of a record given by $table and $id and $fieldList (list of fields, may be '*')
-        * NOTICE: No check for deleted or access!
+        * Evaluates 'group' or 'select' type values.
         *
-        * @param       string          Table name
-        * @param       integer         UID of the record from $table
-        * @param       string          Field list for the SELECT query, eg. "*" or "uid,pid,..."
-        * @return      mixed           Returns the selected record on success, otherwise false.
+        * @param       array           The result array. The processed value (if any!) is set in the 'value' key.
+        * @param       string          The value to set.
+        * @param       array           Field configuration from TCA
+        * @param       array           Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
+        * @param       [type]          $uploadedFiles: ...
+        * @param       string          Field name
+        * @return      array           Modified $res array
         */
-       function recordInfo($table,$id,$fieldList)      {
-               global $TCA;
-               if (is_array($TCA[$table]))     {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fieldList, $table, 'uid='.intval($id));
-                       if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
-                               return $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
-                       }
+       function checkValue_group_select($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field)   {
+               list($table,$id,$curValue,$status,$realPid,$recFID) = $PP;
+
+                       // Detecting if value send is an array and if so, implode it around a comma:
+               if (is_array($value))   {
+                       $value = implode(',',$value);
                }
-       }
 
-       /**
-        * Returns an array with record properties, like header and pid
-        *
-        * @param       [type]          $table: ...
-        * @param       [type]          $id: ...
-        * @return      [type]          ...
-        */
-       function getRecordProperties($table,$id)        {
-               $row = ($table=='pages' && !$id) ? array('title'=>'[root-level]', 'uid' => 0, 'pid' => 0) :$this->recordInfo($table,$id,'*');
-               t3lib_BEfunc::fixVersioningPid($table,$row);
-               return $this->getRecordPropertiesFromRow($table,$row);
-       }
+                       // This converts all occurencies of '&#123;' to the byte 123 in the string - this is needed in very rare cases where filenames with special characters (like æøå, umlaud etc) gets sent to the server as HTML entities instead of bytes. The error is done only by MSIE, not Mozilla and Opera.
+                       // Anyways, this should NOT disturb anything else:
+               $value = $this->convNumEntityToByteValue($value);
 
-       /**
-        * Returns an array with record properties, like header and pid, based on the row
-        *
-        * @param       [type]          $table: ...
-        * @param       [type]          $row: ...
-        * @return      [type]          ...
-        */
-       function getRecordPropertiesFromRow($table,$row)        {
-               global $TCA;
-               if ($TCA[$table])       {
-                       $out = array(
-                               'header' => $row[$TCA[$table]['ctrl']['label']],
-                               'pid' => $row['pid'],
-                               'event_pid' => ($table=='pages'?$row['uid']:$row['pid']),
-                               't3ver_state' => $TCA[$table]['ctrl']['versioningWS'] ? $row['t3ver_state'] : '',
-                               '_ORIG_pid' => $row['_ORIG_pid']
-                       );
-                       return $out;
-               }
-       }
+                       // When values are send as group or select they come as comma-separated values which are exploded by this function:
+               $valueArray = $this->checkValue_group_select_explodeSelectGroupValue($value);
 
-       /**
-        * [Describe function...]
-        *
-        * @param       [type]          $fieldArray: ...
-        * @param       [type]          $TSConfig_p: ...
-        * @return      [type]          ...
-        */
-       function setTSconfigPermissions($fieldArray,$TSConfig_p)        {
-               if (strcmp($TSConfig_p['userid'],''))   $fieldArray['perms_userid']=intval($TSConfig_p['userid']);
-               if (strcmp($TSConfig_p['groupid'],''))  $fieldArray['perms_groupid']=intval($TSConfig_p['groupid']);
-               if (strcmp($TSConfig_p['user'],''))                     $fieldArray['perms_user']=t3lib_div::testInt($TSConfig_p['user']) ? $TSConfig_p['user'] : $this->assemblePermissions($TSConfig_p['user']);
-               if (strcmp($TSConfig_p['group'],''))            $fieldArray['perms_group']=t3lib_div::testInt($TSConfig_p['group']) ? $TSConfig_p['group'] : $this->assemblePermissions($TSConfig_p['group']);
-               if (strcmp($TSConfig_p['everybody'],''))        $fieldArray['perms_everybody']=t3lib_div::testInt($TSConfig_p['everybody']) ? $TSConfig_p['everybody'] : $this->assemblePermissions($TSConfig_p['everybody']);
+                       // If not multiple is set, then remove duplicates:
+               if (!$tcaFieldConf['multiple']) {
+                       $valueArray = array_unique($valueArray);
+               }
 
-               return $fieldArray;
-       }
+               // This could be a good spot for parsing the array through a validation-function which checks if the values are allright (except that database references are not in their final form - but that is the point, isn't it?)
+               // NOTE!!! Must check max-items of files before the later check because that check would just leave out filenames if there are too many!!
 
-       /**
-        * Returns a fieldArray with default values.
-        *
-        * @param       [type]          $table: ...
-        * @return      [type]          ...
-        */
-       function newFieldArray($table)  {
-               global $TCA;
-               t3lib_div::loadTCA($table);
-               $fieldArray=Array();
-               if (is_array($TCA[$table]['columns']))  {
-                       reset ($TCA[$table]['columns']);
-                       while (list($field,$content)=each($TCA[$table]['columns']))     {
-                               if (isset($this->defaultValues[$table][$field]))        {
-                                       $fieldArray[$field] = $this->defaultValues[$table][$field];
-                               } elseif (isset($content['config']['default'])) {
-                                       $fieldArray[$field] = $content['config']['default'];
+                       // Checking for select / authMode, removing elements from $valueArray if any of them is not allowed!
+               if ($tcaFieldConf['type']=='select' && $tcaFieldConf['authMode'])       {
+                       $preCount = count($valueArray);
+                       foreach($valueArray as $kk => $vv)      {
+                               if (!$this->BE_USER->checkAuthMode($table,$field,$vv,$tcaFieldConf['authMode']))        {
+                                       unset($valueArray[$kk]);
                                }
                        }
+
+                               // During the check it turns out that the value / all values were removed - we respond by simply returning an empty array so nothing is written to DB for this field.
+                       if ($preCount && !count($valueArray))   {
+                               return array();
+                       }
                }
-               if ($table=='pages')    {               // Set default permissions for a page.
-                       $fieldArray['perms_userid'] = $this->userid;
-                       $fieldArray['perms_groupid'] = intval($this->BE_USER->firstMainGroup);
-                       $fieldArray['perms_user'] = $this->assemblePermissions($this->defaultPermissions['user']);
-                       $fieldArray['perms_group'] = $this->assemblePermissions($this->defaultPermissions['group']);
-                       $fieldArray['perms_everybody'] = $this->assemblePermissions($this->defaultPermissions['everybody']);
+
+                       // For group types:
+               if ($tcaFieldConf['type']=='group')     {
+                       switch($tcaFieldConf['internal_type'])  {
+                               case 'file':
+                                       $valueArray = $this->checkValue_group_select_file(
+                                               $valueArray,
+                                               $tcaFieldConf,
+                                               $curValue,
+                                               $uploadedFiles,
+                                               $status,
+                                               $table,
+                                               $id,
+                                               $recFID
+                                       );
+                               break;
+                               case 'db':
+                                       $valueArray = $this->checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,'group');
+                               break;
+                       }
+               }
+                       // For select types which has a foreign table attached:
+               if ($tcaFieldConf['type']=='select' && $tcaFieldConf['foreign_table'])  {
+                       $valueArray = $this->checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,'select');
                }
-               return $fieldArray;
-       }
 
-       /**
-        * Returns the $data array from $table overridden in the fields defined in ->overrideValues.
-        *
-        * @param       [type]          $table: ...
-        * @param       [type]          $data: ...
-        * @return      [type]          ...
-        */
-       function overrideFieldArray($table,$data)       {
-               if (is_array($this->overrideValues[$table]))    {
-                       $data = array_merge($data,$this->overrideValues[$table]);                       // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
+// BTW, checking for min and max items here does NOT make any sense when MM is used because the above function calls will just return an array with a single item (the count) if MM is used... Why didn't I perform the check before? Probably because we could not evaluate the validity of record uids etc... Hmm...
+
+                       // Checking the number of items, that it is correct.
+                       // If files, there MUST NOT be too many files in the list at this point, so check that prior to this code.
+               $valueArrayC = count($valueArray);
+               $minI = isset($tcaFieldConf['minitems']) ? intval($tcaFieldConf['minitems']):0;
+
+                       // NOTE to the comment: It's not really possible to check for too few items, because you must then determine first, if the field is actual used regarding the CType.
+               $maxI = isset($tcaFieldConf['maxitems']) ? intval($tcaFieldConf['maxitems']):1;
+               if ($valueArrayC > $maxI)       {$valueArrayC=$maxI;}   // Checking for not too many elements
+
+                       // Dumping array to list
+               $newVal=array();
+               foreach($valueArray as $nextVal)        {
+                       if ($valueArrayC==0)    {break;}
+                       $valueArrayC--;
+                       $newVal[]=$nextVal;
                }
-               return $data;
+               $res['value'] = implode(',',$newVal);
+
+               return $res;
        }
 
        /**
-        * Calculates the bitvalue of the permissions given in a string, comma-sep
+        * Handling files for group/select function
         *
-        * @param       [type]          $string: ...
-        * @return      [type]          ...
+        * @param       [type]          $valueArray: ...
+        * @param       [type]          $tcaFieldConf: ...
+        * @param       [type]          $curValue: ...
+        * @param       [type]          $uploadedFileArray: ...
+        * @param       [type]          $status: ...
+        * @param       [type]          $table: ...
+        * @param       [type]          $id: ...
+        * @param       [type]          $recFID: ...
+        * @return      array           Modified value array
+        * @see checkValue_group_select()
         */
-       function assemblePermissions($string)   {
-               $keyArr = t3lib_div::trimExplode(',',$string,1);
-               $value=0;
-               while(list(,$key)=each($keyArr))        {
-                       if ($key && isset($this->pMap[$key]))   {
-                               $value |= $this->pMap[$key];
-                       }
-               }
-               return $value;
-       }
-
+       function checkValue_group_select_file($valueArray,$tcaFieldConf,$curValue,$uploadedFileArray,$status,$table,$id,$recFID)        {
 
+                       // If any files are uploaded:
+               if (is_array($uploadedFileArray) &&
+                       $uploadedFileArray['name'] &&
+                       strcmp($uploadedFileArray['tmp_name'],'none'))  {
+                               $valueArray[]=$uploadedFileArray['tmp_name'];
+                               $this->alternativeFileName[$uploadedFileArray['tmp_name']] = $uploadedFileArray['name'];
+               }
 
+                       // Creating fileFunc object.
+               if (!$this->fileFunc)   {
+                       $this->fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
+                       $this->include_filefunctions=1;
+               }
+                       // Setting permitted extensions.
+               $all_files = Array();
+               $all_files['webspace']['allow'] = $tcaFieldConf['allowed'];
+               $all_files['webspace']['deny'] = $tcaFieldConf['disallowed'] ? $tcaFieldConf['disallowed'] : '*';
+               $all_files['ftpspace'] = $all_files['webspace'];
+               $this->fileFunc->init('', $all_files);
 
+                       // If there is an upload folder defined:
+               if ($tcaFieldConf['uploadfolder'])      {
+                               // For logging..
+                       $propArr = $this->getRecordProperties($table,$id);
 
+                               // Get destrination path:
+                       $dest = $this->destPathFromUploadFolder($tcaFieldConf['uploadfolder']);
 
+                               // If we are updating:
+                       if ($status=='update')  {
 
+                                       // Finding the CURRENT files listed, either from MM or from the current record.
+                               $theFileValues=array();
+                               if ($tcaFieldConf['MM'])        {       // If MM relations for the files also!
+                                       $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
+                                       $dbAnalysis->start('','files',$tcaFieldConf['MM'],$id);
+                                       reset($dbAnalysis->itemArray);
+                                       while (list($somekey,$someval)=each($dbAnalysis->itemArray))    {
+                                               if ($someval['id'])     {
+                                                       $theFileValues[]=$someval['id'];
+                                               }
+                                       }
+                               } else {
+                                       $theFileValues=t3lib_div::trimExplode(',',$curValue,1);
+                               }
 
+                                       // DELETE files: If existing files were found, traverse those and register files for deletion which has been removed:
+                               if (count($theFileValues))      {
+                                               // Traverse the input values and for all input values which match an EXISTING value, remove the existing from $theFileValues array (this will result in an array of all the existing files which should be deleted!)
+                                       foreach($valueArray as $key => $theFile)        {
+                                               if ($theFile && !strstr(t3lib_div::fixWindowsFilePath($theFile),'/'))   {
+                                                       $theFileValues = t3lib_div::removeArrayEntryByValue($theFileValues,$theFile);
+                                               }
+                                       }
 
+                                               // This array contains the filenames in the uploadfolder that should be deleted:
+                                       foreach($theFileValues as $key => $theFile)     {
+                                               $theFile = trim($theFile);
+                                               if (@is_file($dest.'/'.$theFile))       {
+                                                       $this->removeFilesStore[]=$dest.'/'.$theFile;
+                                               } elseif ($theFile) {
+                                                       $this->log($table,$id,5,0,1,"Could not delete file '%s' (does not exist). (%s)",10,array($dest.'/'.$theFile, $recFID),$propArr['event_pid']);
+                                               }
+                                       }
+                               }
+                       }
 
+                               // Traverse the submitted values:
+                       foreach($valueArray as $key => $theFile)        {
+                                       // NEW FILES? If the value contains '/' it indicates, that the file is new and should be added to the uploadsdir (whether its absolute or relative does not matter here)
+                               if (strstr(t3lib_div::fixWindowsFilePath($theFile),'/'))        {
+                                               // Init:
+                                       $maxSize = intval($tcaFieldConf['max_size']);
+                                       $cmd='';
+                                       $theDestFile='';                // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!! (Change: 22/12/2000)
 
+                                               // Check various things before copying file:
+                                       if (@is_dir($dest) && (@is_file($theFile) || @is_uploaded_file($theFile)))      {               // File and destination must exist
 
+                                                       // Finding size. For safe_mode we have to rely on the size in the upload array if the file is uploaded.
+                                               if (is_uploaded_file($theFile) && $theFile==$uploadedFileArray['tmp_name'])     {
+                                                       $fileSize = $uploadedFileArray['size'];
+                                               } else {
+                                                       $fileSize = filesize($theFile);
+                                               }
 
+                                               if (!$maxSize || $fileSize<=($maxSize*1024))    {       // Check file size:
+                                                               // Prepare filename:
+                                                       $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
+                                                       $fI = t3lib_div::split_fileref($theEndFileName);
 
+                                                               // Check for allowed extension:
+                                                       if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
+                                                               $theDestFile = $this->fileFunc->getUniqueName($this->fileFunc->cleanFileName($fI['file']), $dest);
 
+                                                                       // If we have a unique destination filename, then write the file:
+                                                               if ($theDestFile)       {
+                                                                       t3lib_div::upload_copy_move($theFile,$theDestFile);
+                                                                       $this->copiedFileMap[$theFile] = $theDestFile;
+                                                                       clearstatcache();
+                                                                       if (!@is_file($theDestFile))    $this->log($table,$id,5,0,1,"Copying file '%s' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)",16,array($theFile, dirname($theDestFile), $recFID),$propArr['event_pid']);
+                                                               } else $this->log($table,$id,5,0,1,"Copying file '%s' failed!: No destination file (%s) possible!. (%s)",11,array($theFile, $theDestFile, $recFID),$propArr['event_pid']);
+                                                       } else $this->log($table,$id,5,0,1,"Fileextension '%s' not allowed. (%s)",12,array($fI['fileext'], $recFID),$propArr['event_pid']);
+                                               } else $this->log($table,$id,5,0,1,"Filesize (%s) of file '%s' exceeds limit (%s). (%s)",13,array(t3lib_div::formatSize($fileSize),$theFile,t3lib_div::formatSize($maxSize*1024),$recFID),$propArr['event_pid']);
+                                       } else $this->log($table,$id,5,0,1,'The destination (%s) or the source file (%s) does not exist. (%s)',14,array($dest, $theFile, $recFID),$propArr['event_pid']);
 
+                                               // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
+                                       if (@is_file($theDestFile))     {
+                                               $info = t3lib_div::split_fileref($theDestFile);
+                                               $valueArray[$key]=$info['file']; // The value is set to the new filename
+                                       } else {
+                                               unset($valueArray[$key]);       // The value is set to the new filename
+                                       }
+                               }
+                       }
 
+                               // If MM relations for the files, we will set the relations as MM records and change the valuearray to contain a single entry with a count of the number of files!
+                       if ($tcaFieldConf['MM'])        {
+                               $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
+                               $dbAnalysis->tableArray['files']=array();       // dummy
 
+                               reset($valueArray);
+                               while (list($key,$theFile)=each($valueArray))   {
+                                               // explode files
+                                               $dbAnalysis->itemArray[]['id']=$theFile;
+                               }
+                               if ($status=='update')  {
+                                       $dbAnalysis->writeMM($tcaFieldConf['MM'],$id,0);
+                               } else {
+                                       $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, 0);     // This will be traversed later to execute the actions
+                               }
+                               $cc=count($dbAnalysis->itemArray);
+                               $valueArray = array($cc);
+                       }
+               }
 
+               return $valueArray;
+       }
 
-       /*********************************************
+       /**
+        * Evaluates 'flex' type values.
         *
-        * Evaluation of input values
-        *
-        ********************************************/
-
-       /**
-        * Evaluates a value according to $table/$field settings.
-        * This function is for real database fields - NOT FlexForm "pseudo" fields.
-        * NOTICE: Calling this function expects this: 1) That the data is saved! (files are copied and so on) 2) That files registered for deletion IS deleted at the end (with ->removeRegisteredFiles() )
-        *
-        * @param       string          Table name
-        * @param       string          Field name
-        * @param       string          Value to be evaluated. Notice, this is the INPUT value from the form. The original value (from any existing record) must be manually looked up inside the function if needed - or taken from $currentRecord array.
-        * @param       string          The record-uid, mainly - but not exclusively - used for logging
-        * @param       string          'update' or 'new' flag
-        * @param       integer         The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
-        * @param       integer         $tscPID
-        * @return      array           Returns the evaluated $value as key "value" in this array. Can be checked with isset($res['value']) ...
-        */
-       function checkValue($table,$field,$value,$id,$status,$realPid,$tscPID)  {
-               global $TCA, $PAGES_TYPES;
-               t3lib_div::loadTCA($table);
-
-               $res = Array(); // result array
-               $recFID = $table.':'.$id.':'.$field;
-
-                       // Processing special case of field pages.doktype
-               if ($table=='pages' && $field=='doktype')       {
-                               // If the user may not use this specific doktype, we issue a warning
-                       if (! ($this->admin || t3lib_div::inList($this->BE_USER->groupData['pagetypes_select'],$value)))        {
-                               $propArr = $this->getRecordProperties($table,$id);
-                               $this->log($table,$id,5,0,1,"You cannot change the 'doktype' of page '%s' to the desired value.",1,array($propArr['header']),$propArr['event_pid']);
-                               return $res;
-                       };
-                       if ($status=='update')  {
-                                       // This checks 1) if we should check for disallowed tables and 2) if there are records from disallowed tables on the current page
-                               $onlyAllowedTables = isset($PAGES_TYPES[$value]['onlyAllowedTables']) ? $PAGES_TYPES[$value]['onlyAllowedTables'] : $PAGES_TYPES['default']['onlyAllowedTables'];
-                               if ($onlyAllowedTables) {
-                                       $theWrongTables = $this->doesPageHaveUnallowedTables($id,$value);
-                                       if ($theWrongTables)    {
-                                               $propArr = $this->getRecordProperties($table,$id);
-                                               $this->log($table,$id,5,0,1,"'doktype' of page '%s' could not be changed because the page contains records from disallowed tables; %s",2,array($propArr['header'],$theWrongTables),$propArr['event_pid']);
-                                               return $res;
-                                       }
-                               }
-                       }
-               }
-
-                       // Get current value:
-               $curValueRec = $this->recordInfo($table,$id,$field);
-               $curValue = $curValueRec[$field];
-
-                       // Getting config for the field
-               $tcaFieldConf = $TCA[$table]['columns'][$field]['config'];
-
-                       // Preform processing:
-               $res = $this->checkValue_SW($res,$value,$tcaFieldConf,$table,$id,$curValue,$status,$realPid,$recFID,$field,$this->uploadedFileArray[$table][$id][$field],$tscPID);
-
-               return $res;
-       }
-
-       /**
-        * Branches out evaluation of a field value based on its type as configured in TCA
-        * Can be called for FlexForm pseudo fields as well, BUT must not have $field set if so.
-        *
-        * @param       array           The result array. The processed value (if any!) is set in the "value" key.
-        * @param       string          The value to set.
-        * @param       array           Field configuration from TCA
-        * @param       string          Table name
-        * @param       integer         Return UID
-        * @param       [type]          $curValue: ...
-        * @param       [type]          $status: ...
-        * @param       integer         The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
-        * @param       [type]          $recFID: ...
-        * @param       string          Field name. Must NOT be set if the call is for a flexform field (since flexforms are not allowed within flexforms).
-        * @param       [type]          $uploadedFiles: ...
-        * @param       [type]          $tscPID: ...
-        * @return      array           Returns the evaluated $value as key "value" in this array.
-        */
-       function checkValue_SW($res,$value,$tcaFieldConf,$table,$id,$curValue,$status,$realPid,$recFID,$field,$uploadedFiles,$tscPID)   {
-
-               $PP = array($table,$id,$curValue,$status,$realPid,$recFID,$tscPID);
-
-               switch ($tcaFieldConf['type']) {
-                       case 'text':
-                       case 'passthrough':
-                       case 'user':
-                               $res['value'] = $value;
-                       break;
-                       case 'input':
-                               $res = $this->checkValue_input($res,$value,$tcaFieldConf,$PP,$field);
-                       break;
-                       case 'check':
-                               $res = $this->checkValue_check($res,$value,$tcaFieldConf,$PP);
-                       break;
-                       case 'radio':
-                               $res = $this->checkValue_radio($res,$value,$tcaFieldConf,$PP);
-                       break;
-                       case 'group':
-                       case 'select':
-                               $res = $this->checkValue_group_select($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field);
-                       break;
-                       case 'flex':
-                               if ($field)     {       // FlexForms are only allowed for real fields.
-                                       $res = $this->checkValue_flex($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field);
-                               }
-                       break;
-                       default:
-                               #debug(array($tcaFieldConf,$res,$value),'NON existing field type:');
-                       break;
-               }
-
-               return $res;
-       }
-
-       /**
-        * Evaluate "input" type values.
-        *
-        * @param       array           The result array. The processed value (if any!) is set in the "value" key.
+        * @param       array           The result array. The processed value (if any!) is set in the 'value' key.
         * @param       string          The value to set.
         * @param       array           Field configuration from TCA
         * @param       array           Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
+        * @param       array           Uploaded files for the field
+        * @param       array           Current record array.
         * @param       string          Field name
         * @return      array           Modified $res array
         */
-       function checkValue_input($res,$value,$tcaFieldConf,$PP,$field='')      {
+       function checkValue_flex($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field)   {
                list($table,$id,$curValue,$status,$realPid,$recFID) = $PP;
 
-                       // Secures the string-length to be less than max. Will probably make problems with multi-byte strings!
-               if (intval($tcaFieldConf['max'])>0)     {$value = substr($value,0,intval($tcaFieldConf['max']));}
+               if (is_array($value))   {
 
-                       // Checking range of value:
-               if ($tcaFieldConf['range'] && $value!=$tcaFieldConf['checkbox'])        {       // If value is not set to the allowed checkbox-value then it is checked against the ranges
-                       if (isset($tcaFieldConf['range']['upper'])&&$value>$tcaFieldConf['range']['upper'])     {$value=$tcaFieldConf['range']['upper'];}
-                       if (isset($tcaFieldConf['range']['lower'])&&$value<$tcaFieldConf['range']['lower'])     {$value=$tcaFieldConf['range']['lower'];}
-               }
+                               // Get current value array:
+                       $dataStructArray = t3lib_BEfunc::getFlexFormDS($tcaFieldConf,$this->checkValue_currentRecord,$table);
+#debug($this->checkValue_currentRecord);
+                       $currentValueArray = t3lib_div::xml2array($curValue);
+                       if (!is_array($currentValueArray))      $currentValueArray = array();
+                       if (is_array($currentValueArray['meta']['currentLangId']))              unset($currentValueArray['meta']['currentLangId']);     // Remove all old meta for languages...
 
-                       // Process evaluation settings:
-               $evalCodesArray = t3lib_div::trimExplode(',',$tcaFieldConf['eval'],1);
-               $res = $this->checkValue_input_Eval($value,$evalCodesArray,$tcaFieldConf['is_in']);
+                               // Evaluation of input values:
+                       $value['data'] = $this->checkValue_flex_procInData($value['data'],$currentValueArray['data'],$uploadedFiles['data'],$dataStructArray,$PP);
 
-                       // Process UNIQUE settings:
-               if ($field && $realPid>=0)      {       // Field is NOT set for flexForms - which also means that uniqueInPid and unique is NOT available for flexForm fields! Also getUnique should not be done for versioning and if PID is -1 ($realPid<0) then versioning is happening...
-                       if ($res['value'] && in_array('uniqueInPid',$evalCodesArray))   {
-                               $res['value'] = $this->getUnique($table,$field,$res['value'],$id,$realPid);
+                               // Create XML and convert charsets from input value:
+                       $xmlValue = $this->checkValue_flexArray2Xml($value);
+
+                               // If we wanted to set UTF fixed:
+                       // $storeInCharset='utf-8';
+                       // $currentCharset=$GLOBALS['LANG']->charSet;
+                       // $xmlValue = $GLOBALS['LANG']->csConvObj->conv($xmlValue,$currentCharset,$storeInCharset,1);
+                       $storeInCharset=$GLOBALS['LANG']->charSet;
+
+                               // Merge them together IF they are both arrays:
+                               // Here we convert the currently submitted values BACK to an array, then merge the two and then BACK to XML again. This is needed to ensure the charsets are the same (provided that the current value was already stored IN the charset that the new value is converted to).
+                       if (is_array($currentValueArray))       {
+                               $arrValue = t3lib_div::xml2array($xmlValue);
+                               $arrValue = t3lib_div::array_merge_recursive_overrule($currentValueArray,$arrValue);
+                               $xmlValue = $this->checkValue_flexArray2Xml($arrValue);
                        }
-                       if ($res['value'] && in_array('unique',$evalCodesArray))        {
-                               $res['value'] = $this->getUnique($table,$field,$res['value'],$id);
+
+                               // Temporary fix to delete flex form elements:
+                       $deleteCMDs = t3lib_div::_GP('_DELETE_FLEX_FORMdata');
+                       if (is_array($deleteCMDs[$table][$id][$field]['data'])) {
+                               $arrValue = t3lib_div::xml2array($xmlValue);
+                               $this->_DELETE_FLEX_FORMdata($arrValue['data'],$deleteCMDs[$table][$id][$field]['data']);
+                               $xmlValue = $this->checkValue_flexArray2Xml($arrValue);
+                       }
+
+                               // Temporary fix to move flex form elements up:
+                       $moveCMDs = t3lib_div::_GP('_MOVEUP_FLEX_FORMdata');
+                       if (is_array($moveCMDs[$table][$id][$field]['data']))   {
+                               $arrValue = t3lib_div::xml2array($xmlValue);
+                               $this->_MOVE_FLEX_FORMdata($arrValue['data'],$moveCMDs[$table][$id][$field]['data'], 'up');
+                               $xmlValue = $this->checkValue_flexArray2Xml($arrValue);
+                       }
+
+                               // Temporary fix to move flex form elements down:
+                       $moveCMDs = t3lib_div::_GP('_MOVEDOWN_FLEX_FORMdata');
+                       if (is_array($moveCMDs[$table][$id][$field]['data']))   {
+                               $arrValue = t3lib_div::xml2array($xmlValue);
+                               $this->_MOVE_FLEX_FORMdata($arrValue['data'],$moveCMDs[$table][$id][$field]['data'], 'down');
+                               $xmlValue = $this->checkValue_flexArray2Xml($arrValue);
                        }
+
+                               // Create the value XML:
+                       $res['value']='';
+                       $res['value'].='<?xml version="1.0" encoding="'.$storeInCharset.'" standalone="yes" ?>'.chr(10);
+                       $res['value'].=$xmlValue;
+               } else {        // Passthrough...:
+                       $res['value']=$value;
                }
 
                return $res;
        }
 
        /**
-        * Evaluates 'check' type values.
+        * [Describe function...]
         *
-        * @param       array           The result array. The processed value (if any!) is set in the 'value' key.
-        * @param       string          The value to set.
-        * @param       array           Field configuration from TCA
-        * @param       array           Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @return      array           Modified $res array
+        * @param       [type]          $array: ...
+        * @return      [type]          ...
         */
-       function checkValue_check($res,$value,$tcaFieldConf,$PP)        {
-               list($table,$id,$curValue,$status,$realPid,$recFID) = $PP;
-
-               $itemC = count($tcaFieldConf['items']);
-               if (!$itemC)    {$itemC=1;}
-               $maxV = pow(2,$itemC);
-
-               if ($value<0)   {$value=0;}
-               if ($value>$maxV)       {$value=$maxV;}
-               $res['value'] = $value;
-
-               return $res;
+       function checkValue_flexArray2Xml($array)       {
+               $output = t3lib_div::array2xml($array,'',0,'T3FlexForms',4,array('parentTagMap' => array(
+/*                                                             'data' => 'sheets',
+                                                               'sheets' => 'language',
+                                                               'language' => 'fieldname',
+                                                               'el' => 'fieldname'             */
+                                                       )));
+               return $output;
        }
 
        /**
-        * Evaluates 'radio' type values.
+        * Deletes a flex form element
         *
-        * @param       array           The result array. The processed value (if any!) is set in the 'value' key.
-        * @param       string          The value to set.
-        * @param       array           Field configuration from TCA
-        * @param       array           Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @return      array           Modified $res array
+        * @param       array           &$valueArrayToRemoveFrom: by reference
+        * @param       [type]          $deleteCMDS: ...         *
+        * @return      void
         */
-       function checkValue_radio($res,$value,$tcaFieldConf,$PP)        {
-               list($table,$id,$curValue,$status,$realPid,$recFID) = $PP;
-
-               if (is_array($tcaFieldConf['items']))   {
-                       foreach($tcaFieldConf['items'] as $set) {
-                               if (!strcmp($set[1],$value))    {
-                                       $res['value'] = $value;
-                                       break;
+       function _DELETE_FLEX_FORMdata(&$valueArrayToRemoveFrom,$deleteCMDS)    {
+               if (is_array($valueArrayToRemoveFrom) && is_array($deleteCMDS)) {
+                       foreach($deleteCMDS as $key => $value)  {
+                               if (is_array($deleteCMDS[$key]))        {
+                                       $this->_DELETE_FLEX_FORMdata($valueArrayToRemoveFrom[$key],$deleteCMDS[$key]);
+                               } else {
+                                       unset($valueArrayToRemoveFrom[$key]);
                                }
                        }
                }
-
-               return $res;
        }
 
        /**
-        * Evaluates 'group' or 'select' type values.
+        * Deletes a flex form element
         *
-        * @param       array           The result array. The processed value (if any!) is set in the 'value' key.
-        * @param       string          The value to set.
-        * @param       array           Field configuration from TCA
-        * @param       array           Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @param       [type]          $uploadedFiles: ...
-        * @param       string          Field name
-        * @return      array           Modified $res array
-        */
-       function checkValue_group_select($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field)   {
-               list($table,$id,$curValue,$status,$realPid,$recFID) = $PP;
-
-                       // Detecting if value send is an array and if so, implode it around a comma:
-               if (is_array($value))   {
-                       $value = implode(',',$value);
-               }
-
-                       // This converts all occurencies of '&#123;' to the byte 123 in the string - this is needed in very rare cases where filenames with special characters (like æøå, umlaud etc) gets sent to the server as HTML entities instead of bytes. The error is done only by MSIE, not Mozilla and Opera.
-                       // Anyways, this should NOT disturb anything else:
-               $value = $this->convNumEntityToByteValue($value);
-
-                       // When values are send as group or select they come as comma-separated values which are exploded by this function:
-               $valueArray = $this->checkValue_group_select_explodeSelectGroupValue($value);
-
-                       // If not multiple is set, then remove duplicates:
-               if (!$tcaFieldConf['multiple']) {
-                       $valueArray = array_unique($valueArray);
-               }
-
-               // This could be a good spot for parsing the array through a validation-function which checks if the values are allright (except that database references are not in their final form - but that is the point, isn't it?)
-               // NOTE!!! Must check max-items of files before the later check because that check would just leave out filenames if there are too many!!
-
-                       // Checking for select / authMode, removing elements from $valueArray if any of them is not allowed!
-               if ($tcaFieldConf['type']=='select' && $tcaFieldConf['authMode'])       {
-                       $preCount = count($valueArray);
-                       foreach($valueArray as $kk => $vv)      {
-                               if (!$this->BE_USER->checkAuthMode($table,$field,$vv,$tcaFieldConf['authMode']))        {
-                                       unset($valueArray[$kk]);
-                               }
-                       }
-
-                               // During the check it turns out that the value / all values were removed - we respond by simply returning an empty array so nothing is written to DB for this field.
-                       if ($preCount && !count($valueArray))   {
-                               return array();
-                       }
-               }
-
-                       // For group types:
-               if ($tcaFieldConf['type']=='group')     {
-                       switch($tcaFieldConf['internal_type'])  {
-                               case 'file':
-                                       $valueArray = $this->checkValue_group_select_file(
-                                               $valueArray,
-                                               $tcaFieldConf,
-                                               $curValue,
-                                               $uploadedFiles,
-                                               $status,
-                                               $table,
-                                               $id,
-                                               $recFID
-                                       );
-                               break;
-                               case 'db':
-                                       $valueArray = $this->checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,'group');
-                               break;
-                       }
-               }
-                       // For select types which has a foreign table attached:
-               if ($tcaFieldConf['type']=='select' && $tcaFieldConf['foreign_table'])  {
-                       $valueArray = $this->checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,'select');
-               }
-
-// BTW, checking for min and max items here does NOT make any sense when MM is used because the above function calls will just return an array with a single item (the count) if MM is used... Why didn't I perform the check before? Probably because we could not evaluate the validity of record uids etc... Hmm...
-
-                       // Checking the number of items, that it is correct.
-                       // If files, there MUST NOT be too many files in the list at this point, so check that prior to this code.
-               $valueArrayC = count($valueArray);
-               $minI = isset($tcaFieldConf['minitems']) ? intval($tcaFieldConf['minitems']):0;
-
-                       // NOTE to the comment: It's not really possible to check for too few items, because you must then determine first, if the field is actual used regarding the CType.
-               $maxI = isset($tcaFieldConf['maxitems']) ? intval($tcaFieldConf['maxitems']):1;
-               if ($valueArrayC > $maxI)       {$valueArrayC=$maxI;}   // Checking for not too many elements
-
-                       // Dumping array to list
-               $newVal=array();
-               foreach($valueArray as $nextVal)        {
-                       if ($valueArrayC==0)    {break;}
-                       $valueArrayC--;
-                       $newVal[]=$nextVal;
-               }
-               $res['value'] = implode(',',$newVal);
-
-               return $res;
-       }
-
-       /**
-        * Handling files for group/select function
-        *
-        * @param       [type]          $valueArray: ...
-        * @param       [type]          $tcaFieldConf: ...
-        * @param       [type]          $curValue: ...
-        * @param       [type]          $uploadedFileArray: ...
-        * @param       [type]          $status: ...
-        * @param       [type]          $table: ...
-        * @param       [type]          $id: ...
-        * @param       [type]          $recFID: ...
-        * @return      array           Modified value array
-        * @see checkValue_group_select()
-        */
-       function checkValue_group_select_file($valueArray,$tcaFieldConf,$curValue,$uploadedFileArray,$status,$table,$id,$recFID)        {
-
-                       // If any files are uploaded:
-               if (is_array($uploadedFileArray) &&
-                       $uploadedFileArray['name'] &&
-                       strcmp($uploadedFileArray['tmp_name'],'none'))  {
-                               $valueArray[]=$uploadedFileArray['tmp_name'];
-                               $this->alternativeFileName[$uploadedFileArray['tmp_name']] = $uploadedFileArray['name'];
-               }
-
-                       // Creating fileFunc object.
-               if (!$this->fileFunc)   {
-                       $this->fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
-                       $this->include_filefunctions=1;
-               }
-                       // Setting permitted extensions.
-               $all_files = Array();
-               $all_files['webspace']['allow'] = $tcaFieldConf['allowed'];
-               $all_files['webspace']['deny'] = $tcaFieldConf['disallowed'] ? $tcaFieldConf['disallowed'] : '*';
-               $all_files['ftpspace'] = $all_files['webspace'];
-               $this->fileFunc->init('', $all_files);
-
-                       // If there is an upload folder defined:
-               if ($tcaFieldConf['uploadfolder'])      {
-                               // For logging..
-                       $propArr = $this->getRecordProperties($table,$id);
-
-                               // Get destrination path:
-                       $dest = $this->destPathFromUploadFolder($tcaFieldConf['uploadfolder']);
-
-                               // If we are updating:
-                       if ($status=='update')  {
-
-                                       // Finding the CURRENT files listed, either from MM or from the current record.
-                               $theFileValues=array();
-                               if ($tcaFieldConf['MM'])        {       // If MM relations for the files also!
-                                       $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
-                                       $dbAnalysis->start('','files',$tcaFieldConf['MM'],$id);
-                                       reset($dbAnalysis->itemArray);
-                                       while (list($somekey,$someval)=each($dbAnalysis->itemArray))    {
-                                               if ($someval['id'])     {
-                                                       $theFileValues[]=$someval['id'];
-                                               }
-                                       }
-                               } else {
-                                       $theFileValues=t3lib_div::trimExplode(',',$curValue,1);
-                               }
-
-                                       // DELETE files: If existing files were found, traverse those and register files for deletion which has been removed:
-                               if (count($theFileValues))      {
-                                               // Traverse the input values and for all input values which match an EXISTING value, remove the existing from $theFileValues array (this will result in an array of all the existing files which should be deleted!)
-                                       foreach($valueArray as $key => $theFile)        {
-                                               if ($theFile && !strstr(t3lib_div::fixWindowsFilePath($theFile),'/'))   {
-                                                       $theFileValues = t3lib_div::removeArrayEntryByValue($theFileValues,$theFile);
-                                               }
-                                       }
-
-                                               // This array contains the filenames in the uploadfolder that should be deleted:
-                                       foreach($theFileValues as $key => $theFile)     {
-                                               $theFile = trim($theFile);
-                                               if (@is_file($dest.'/'.$theFile))       {
-                                                       $this->removeFilesStore[]=$dest.'/'.$theFile;
-                                               } elseif ($theFile) {
-                                                       $this->log($table,$id,5,0,1,"Could not delete file '%s' (does not exist). (%s)",10,array($dest.'/'.$theFile, $recFID),$propArr['event_pid']);
-                                               }
-                                       }
-                               }
-                       }
-
-                               // Traverse the submitted values:
-                       foreach($valueArray as $key => $theFile)        {
-                                       // NEW FILES? If the value contains '/' it indicates, that the file is new and should be added to the uploadsdir (whether its absolute or relative does not matter here)
-                               if (strstr(t3lib_div::fixWindowsFilePath($theFile),'/'))        {
-                                               // Init:
-                                       $maxSize = intval($tcaFieldConf['max_size']);
-                                       $cmd='';
-                                       $theDestFile='';                // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!! (Change: 22/12/2000)
-
-                                               // Check various things before copying file:
-                                       if (@is_dir($dest) && (@is_file($theFile) || @is_uploaded_file($theFile)))      {               // File and destination must exist
-
-                                                       // Finding size. For safe_mode we have to rely on the size in the upload array if the file is uploaded.
-                                               if (is_uploaded_file($theFile) && $theFile==$uploadedFileArray['tmp_name'])     {
-                                                       $fileSize = $uploadedFileArray['size'];
-                                               } else {
-                                                       $fileSize = filesize($theFile);
-                                               }
-
-                                               if (!$maxSize || $fileSize<=($maxSize*1024))    {       // Check file size:
-                                                               // Prepare filename:
-                                                       $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
-                                                       $fI = t3lib_div::split_fileref($theEndFileName);
-
-                                                               // Check for allowed extension:
-                                                       if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
-                                                               $theDestFile = $this->fileFunc->getUniqueName($this->fileFunc->cleanFileName($fI['file']), $dest);
-
-                                                                       // If we have a unique destination filename, then write the file:
-                                                               if ($theDestFile)       {
-                                                                       t3lib_div::upload_copy_move($theFile,$theDestFile);
-                                                                       $this->copiedFileMap[$theFile] = $theDestFile;
-                                                                       clearstatcache();
-                                                                       if (!@is_file($theDestFile))    $this->log($table,$id,5,0,1,"Copying file '%s' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)",16,array($theFile, dirname($theDestFile), $recFID),$propArr['event_pid']);
-                                                               } else $this->log($table,$id,5,0,1,"Copying file '%s' failed!: No destination file (%s) possible!. (%s)",11,array($theFile, $theDestFile, $recFID),$propArr['event_pid']);
-                                                       } else $this->log($table,$id,5,0,1,"Fileextension '%s' not allowed. (%s)",12,array($fI['fileext'], $recFID),$propArr['event_pid']);
-                                               } else $this->log($table,$id,5,0,1,"Filesize (%s) of file '%s' exceeds limit (%s). (%s)",13,array(t3lib_div::formatSize($fileSize),$theFile,t3lib_div::formatSize($maxSize*1024),$recFID),$propArr['event_pid']);
-                                       } else $this->log($table,$id,5,0,1,'The destination (%s) or the source file (%s) does not exist. (%s)',14,array($dest, $theFile, $recFID),$propArr['event_pid']);
-
-                                               // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
-                                       if (@is_file($theDestFile))     {
-                                               $info = t3lib_div::split_fileref($theDestFile);
-                                               $valueArray[$key]=$info['file']; // The value is set to the new filename
-                                       } else {
-                                               unset($valueArray[$key]);       // The value is set to the new filename
-                                       }
-                               }
-                       }
-
-                               // If MM relations for the files, we will set the relations as MM records and change the valuearray to contain a single entry with a count of the number of files!
-                       if ($tcaFieldConf['MM'])        {
-                               $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
-                               $dbAnalysis->tableArray['files']=array();       // dummy
-
-                               reset($valueArray);
-                               while (list($key,$theFile)=each($valueArray))   {
-                                               // explode files
-                                               $dbAnalysis->itemArray[]['id']=$theFile;
-                               }
-                               if ($status=='update')  {
-                                       $dbAnalysis->writeMM($tcaFieldConf['MM'],$id,0);
-                               } else {
-                                       $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, 0);     // This will be traversed later to execute the actions
-                               }
-                               $cc=count($dbAnalysis->itemArray);
-                               $valueArray = array($cc);
-                       }
-               }
-
-               return $valueArray;
-       }
-
-       /**
-        * Evaluates 'flex' type values.
-        *
-        * @param       array           The result array. The processed value (if any!) is set in the 'value' key.
-        * @param       string          The value to set.
-        * @param       array           Field configuration from TCA
-        * @param       array           Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @param       array           Uploaded files for the field
-        * @param       array           Current record array.
-        * @param       string          Field name
-        * @return      array           Modified $res array
-        */
-       function checkValue_flex($res,$value,$tcaFieldConf,$PP,$uploadedFiles,$field)   {
-               list($table,$id,$curValue,$status,$realPid,$recFID) = $PP;
-
-               if (is_array($value))   {
-
-                               // Get current value array:
-                       $dataStructArray = t3lib_BEfunc::getFlexFormDS($tcaFieldConf,$this->checkValue_currentRecord,$table);
-#debug($this->checkValue_currentRecord);
-                       $currentValueArray = t3lib_div::xml2array($curValue);
-                       if (!is_array($currentValueArray))      $currentValueArray = array();
-                       if (is_array($currentValueArray['meta']['currentLangId']))              unset($currentValueArray['meta']['currentLangId']);     // Remove all old meta for languages...
-
-                               // Evaluation of input values:
-                       $value['data'] = $this->checkValue_flex_procInData($value['data'],$currentValueArray['data'],$uploadedFiles['data'],$dataStructArray,$PP);
-
-                               // Create XML and convert charsets from input value:
-                       $xmlValue = $this->checkValue_flexArray2Xml($value);
-
-                               // If we wanted to set UTF fixed:
-                       // $storeInCharset='utf-8';
-                       // $currentCharset=$GLOBALS['LANG']->charSet;
-                       // $xmlValue = $GLOBALS['LANG']->csConvObj->conv($xmlValue,$currentCharset,$storeInCharset,1);
-                       $storeInCharset=$GLOBALS['LANG']->charSet;
-
-                               // Merge them together IF they are both arrays:
-                               // Here we convert the currently submitted values BACK to an array, then merge the two and then BACK to XML again. This is needed to ensure the charsets are the same (provided that the current value was already stored IN the charset that the new value is converted to).
-                       if (is_array($currentValueArray))       {
-                               $arrValue = t3lib_div::xml2array($xmlValue);
-                               $arrValue = t3lib_div::array_merge_recursive_overrule($currentValueArray,$arrValue);
-                               $xmlValue = $this->checkValue_flexArray2Xml($arrValue);
-                       }
-
-                               // Temporary fix to delete flex form elements:
-                       $deleteCMDs = t3lib_div::_GP('_DELETE_FLEX_FORMdata');
-                       if (is_array($deleteCMDs[$table][$id][$field]['data'])) {
-                               $arrValue = t3lib_div::xml2array($xmlValue);
-                               $this->_DELETE_FLEX_FORMdata($arrValue['data'],$deleteCMDs[$table][$id][$field]['data']);
-                               $xmlValue = $this->checkValue_flexArray2Xml($arrValue);
-                       }
-
-                               // Temporary fix to move flex form elements up:
-                       $moveCMDs = t3lib_div::_GP('_MOVEUP_FLEX_FORMdata');
-                       if (is_array($moveCMDs[$table][$id][$field]['data']))   {
-                               $arrValue = t3lib_div::xml2array($xmlValue);
-                               $this->_MOVE_FLEX_FORMdata($arrValue['data'],$moveCMDs[$table][$id][$field]['data'], 'up');
-                               $xmlValue = $this->checkValue_flexArray2Xml($arrValue);
-                       }
-
-                               // Temporary fix to move flex form elements down:
-                       $moveCMDs = t3lib_div::_GP('_MOVEDOWN_FLEX_FORMdata');
-                       if (is_array($moveCMDs[$table][$id][$field]['data']))   {
-                               $arrValue = t3lib_div::xml2array($xmlValue);
-                               $this->_MOVE_FLEX_FORMdata($arrValue['data'],$moveCMDs[$table][$id][$field]['data'], 'down');
-                               $xmlValue = $this->checkValue_flexArray2Xml($arrValue);
-                       }
-
-                               // Create the value XML:
-                       $res['value']='';
-                       $res['value'].='<?xml version="1.0" encoding="'.$storeInCharset.'" standalone="yes" ?>'.chr(10);
-                       $res['value'].=$xmlValue;
-               } else {        // Passthrough...:
-                       $res['value']=$value;
-               }
-
-               return $res;
-       }
-
-       /**
-        * [Describe function...]
-        *
-        * @param       [type]          $array: ...
-        * @return      [type]          ...
-        */
-       function checkValue_flexArray2Xml($array)       {
-               $output = t3lib_div::array2xml($array,'',0,'T3FlexForms',4,array('parentTagMap' => array(
-/*                                                             'data' => 'sheets',
-                                                               'sheets' => 'language',
-                                                               'language' => 'fieldname',
-                                                               'el' => 'fieldname'             */
-                                                       )));
-               return $output;
-       }
-
-       /**
-        * Deletes a flex form element
-        *
-        * @param       array           &$valueArrayToRemoveFrom: by reference
-        * @param       [type]          $deleteCMDS: ...         *
-        * @return      void
-        */
-       function _DELETE_FLEX_FORMdata(&$valueArrayToRemoveFrom,$deleteCMDS)    {
-               if (is_array($valueArrayToRemoveFrom) && is_array($deleteCMDS)) {
-                       foreach($deleteCMDS as $key => $value)  {
-                               if (is_array($deleteCMDS[$key]))        {
-                                       $this->_DELETE_FLEX_FORMdata($valueArrayToRemoveFrom[$key],$deleteCMDS[$key]);
-                               } else {
-                                       unset($valueArrayToRemoveFrom[$key]);
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Deletes a flex form element
-        *
-        * @param       array           &$valueArrayToMoveIn: by reference
-        * @param       [type]          $moveCMDS: ...   *
-        * @param       string          $direction: 'up' or 'down'
-        * @return      void
-        * TODO: Like _DELETE_FLEX_FORMdata, this is only a temporary solution!
-        */
-       function _MOVE_FLEX_FORMdata(&$valueArrayToMoveIn, $moveCMDS, $direction)       {
-               if (is_array($valueArrayToMoveIn) && is_array($moveCMDS))       {
-
-                               // Only execute the first move command:
-                       list ($key, $value) = each ($moveCMDS);
-
-                       if (is_array($moveCMDS[$key]))  {
-                               $this->_MOVE_FLEX_FORMdata($valueArrayToMoveIn[$key],$moveCMDS[$key], $direction);
-                       } else {
-                               switch ($direction) {
-                                       case 'up':
-                                               if ($key > 1) {
-                                                       $tmpArr = $valueArrayToMoveIn[$key];
-                                                       $valueArrayToMoveIn[$key] = $valueArrayToMoveIn[$key-1];
-                                                       $valueArrayToMoveIn[$key-1] = $tmpArr;
-                                               }
-                                       break;
-                                       case 'down':
-                                               if ($key < count($valueArrayToMoveIn)) {
-                                                       $tmpArr = $valueArrayToMoveIn[$key];
-                                                       $valueArrayToMoveIn[$key] = $valueArrayToMoveIn[$key+1];
-                                                       $valueArrayToMoveIn[$key+1] = $tmpArr;
-                                               }
-                                       break;
-                               }
-                       }
-               }
-       }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-       /*********************************************
-        *
-        * Helper functions for evaluation functions.
-        *
-        ********************************************/
-
-
-       /**
-        * Gets a unique value for $table/$id/$field based on $value
-        *
-        * @param       string          Table name
-        * @param       string          Field name for which $value must be unique
-        * @param       string          Value string.
-        * @param       integer         UID to filter out in the lookup (the record itself...)
-        * @param       integer         If set, the value will be unique for this PID
-        * @return      string          Modified value (if not-unique). Will be the value appended with a number (until 100, then the function just breaks).
-        */
-       function getUnique($table,$field,$value,$id,$newPid=0)  {
-               global $TCA;
-
-                       // Initialize:
-               t3lib_div::loadTCA($table);
-               $whereAdd='';
-               $newValue='';
-               if (intval($newPid))    { $whereAdd.=' AND pid='.intval($newPid); } else { $whereAdd.=' AND pid>=0'; }  // "AND pid>=0" for versioning
-               $whereAdd.=$this->deleteClause($table);
-
-                       // If the field is configured in TCA, proceed:
-               if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$field]))        {
-
-                               // Look for a record which might already have the value:
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, $field.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($value, $table).' AND uid!='.intval($id).$whereAdd);
-                       $counter = 0;
-
-                               // For as long as records with the test-value existing, try again (with incremented numbers appended).
-                       while ($GLOBALS['TYPO3_DB']->sql_num_rows($res))        {
-                               $newValue = $value.$counter;
-                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, $field.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($newValue, $table).' AND uid!='.intval($id).$whereAdd);
-                               $counter++;
-                               if ($counter>100)       { break; }      // At "100" it will give up and accept a duplicate - should probably be fixed to a small hash string instead...!
-                       }
-                               // If the new value is there:
-                       $value = strlen($newValue) ? $newValue : $value;
-               }
-               return $value;
-       }
-
-       /**
-        * Evaluation of 'input'-type values based on 'eval' list
-        *
-        * @param       string          Value
-        * @param       array           Array of evaluations to traverse.
-        * @param       string          Is-in string
-        * @return      string          Modified $value
-        */
-       function checkValue_input_Eval($value,$evalArray,$is_in)        {
-               $res = Array();
-               $newValue = $value;
-               $set = true;
-
-               foreach($evalArray as $func)    {
-                       switch($func)   {
-                               case 'int':
-                               case 'year':
-                               case 'date':
-                               case 'datetime':
-                               case 'time':
-                               case 'timesec':
-                                       $value = intval($value);
-                               break;
-                               case 'double2':
-                                       $theDec = 0;
-                                       for ($a=strlen($value); $a>0; $a--)     {
-                                               if (substr($value,$a-1,1)=='.' || substr($value,$a-1,1)==',')   {
-                                                       $theDec = substr($value,$a);
-                                                       $value = substr($value,0,$a-1);
-                                                       break;
-                                               }
-                                       }
-                                       $theDec = ereg_replace('[^0-9]','',$theDec).'00';
-                                       $value = intval(str_replace(' ','',$value)).'.'.substr($theDec,0,2);
-                               break;
-                               case 'md5':
-                                       if (strlen($value)!=32){$set=false;}
-                               break;
-                               case 'trim':
-                                       $value = trim($value);
-                               break;
-                               case 'upper':
-                                       $value = strtoupper($value);
-#                                      $value = strtr($value, 'áéúíâêûôîæøåäöü', 'ÁÉÚÍÂÊÛÔÎÆØÅÄÖÜ');   // WILL make trouble with other charsets than ISO-8859-1, so what do we do here? PHP-function which can handle this for other charsets? Currently the browsers JavaScript will fix it.
-                               break;
-                               case 'lower':
-                                       $value = strtolower($value);
-#                                      $value = strtr($value, 'ÁÉÚÍÂÊÛÔÎÆØÅÄÖÜ', 'áéúíâêûôîæøåäöü');   // WILL make trouble with other charsets than ISO-8859-1, so what do we do here? PHP-function which can handle this for other charsets? Currently the browsers JavaScript will fix it.
-                               break;
-                               case 'required':
-                                       if (!$value)    {$set=0;}
-                               break;
-                               case 'is_in':
-                                       $c=strlen($value);
-                                       if ($c) {
-                                               $newVal = '';
-                                               for ($a=0;$a<$c;$a++)   {
-                                                       $char = substr($value,$a,1);
-                                                       if (strstr($is_in,$char))       {
-                                                               $newVal.=$char;
-                                                       }
-                                               }
-                                               $value = $newVal;
-                                       }
-                               break;
-                               case 'nospace':
-                                       $value = str_replace(' ','',$value);
-                               break;
-                               case 'alpha':
-                                       $value = ereg_replace('[^a-zA-Z]','',$value);
-                               break;
-                               case 'num':
-                                       $value = ereg_replace('[^0-9]','',$value);
-                               break;
-                               case 'alphanum':
-                                       $value = ereg_replace('[^a-zA-Z0-9]','',$value);
-                               break;
-                               case 'alphanum_x':
-                                       $value = ereg_replace('[^a-zA-Z0-9_-]','',$value);
-                               break;
-                       }
-               }
-               if ($set)       {$res['value'] = $value;}
-               return $res;
-       }
-
-       /**
-        * Returns data for group/db and select fields
-        *
-        * @param       array           Current value array
-        * @param       array           TCA field config
-        * @param       integer         Record id, used for look-up of MM relations (local_uid)
-        * @param       string          Status string ('update' or 'new')
-        * @param       string          The type, either 'select' or 'group'
-        * @return      array           Modified value array
-        */
-       function checkValue_group_select_processDBdata($valueArray,$tcaFieldConf,$id,$status,$type)     {
-               $tables = $type=='group'?$tcaFieldConf['allowed']:$tcaFieldConf['foreign_table'].','.$tcaFieldConf['neg_foreign_table'];
-               $prep = $type=='group'?$tcaFieldConf['prepend_tname']:$tcaFieldConf['neg_foreign_table'];
-
-               $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
-               $dbAnalysis->registerNonTableValues=$tcaFieldConf['allowNonIdValues'] ? 1 : 0;
-               $dbAnalysis->start(implode(',',$valueArray),$tables);
-
-               if ($tcaFieldConf['MM'])        {
-                       if ($status=='update')  {
-                               $dbAnalysis->writeMM($tcaFieldConf['MM'],$id,$prep);
-                       } else {
-                               $this->dbAnalysisStore[] = array($dbAnalysis,$tcaFieldConf['MM'],$id,$prep);    // This will be traversed later to execute the actions
-                       }
-                       $cc=count($dbAnalysis->itemArray);
-                       $valueArray = array($cc);
-               } else {
-                       $valueArray = $dbAnalysis->getValueArray($prep);
-                       if ($type=='select' && $prep)   {
-                               $valueArray = $dbAnalysis->convertPosNeg($valueArray,$tcaFieldConf['foreign_table'],$tcaFieldConf['neg_foreign_table']);
-                       }
-               }
-
-                       // Here we should se if 1) the records exist anymore, 2) which are new and check if the BE_USER has read-access to the new ones.
-               return $valueArray;
-       }
-
-       /**
-        * Explodes the $value, which is a list of files/uids (group select)
-        *
-        * @param       string          Input string, comma separated values. For each part it will also be detected if a '|' is found and the first part will then be used if that is the case. Further the value will be rawurldecoded.
-        * @return      array           The value array.
-        */
-       function checkValue_group_select_explodeSelectGroupValue($value)        {
-               $valueArray = t3lib_div::trimExplode(',',$value,1);
-               reset($valueArray);
-               while(list($key,$newVal)=each($valueArray))     {
-                       $temp=explode('|',$newVal,2);
-                       $valueArray[$key] = str_replace(',','',str_replace('|','',rawurldecode($temp[0])));
-               }
-               return $valueArray;
-       }
-
-       /**
-        * Starts the processing the input data for flexforms. This will traverse all sheets / languages and for each it will traverse the sub-structure.
-        * See checkValue_flex_procInData_travDS() for more details.
-        *
-        * @param       array           The 'data' part of the INPUT flexform data
-        * @param       array           The 'data' part of the CURRENT flexform data
-        * @param       array           The uploaded files for the 'data' part of the INPUT flexform data
-        * @param       array           Data structure for the form (might be sheets or not). Only values in the data array which has a configuration in the data structure will be processed.
-        * @param       array           A set of parameters to pass through for the calling of the evaluation functions
-        * @param       string          Optional call back function, see checkValue_flex_procInData_travDS()
-        * @return      array           The modified 'data' part.
-        * @see checkValue_flex_procInData_travDS()
-        */
-       function checkValue_flex_procInData($dataPart,$dataPart_current,$uploadedFiles,$dataStructArray,$pParams,$callBackFunc='')      {
-#debug(array($dataPart,$dataPart_current,$dataStructArray));
-               if (is_array($dataPart))        {
-                       foreach($dataPart as $sKey => $sheetDef)        {
-                               list ($dataStruct,$actualSheet) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sKey);
-#debug(array($dataStruct,$actualSheet,$sheetDef,$actualSheet,$sKey));
-                               if (is_array($dataStruct) && $actualSheet==$sKey && is_array($sheetDef))        {
-                                       foreach($sheetDef as $lKey => $lData)   {
-                                               $this->checkValue_flex_procInData_travDS(
-                                                       $dataPart[$sKey][$lKey],
-                                                       $dataPart_current[$sKey][$lKey],
-                                                       $uploadedFiles[$sKey][$lKey],
-                                                       $dataStruct['ROOT']['el'],
-                                                       $pParams,
-                                                       $callBackFunc,
-                                                       $sKey.'/'.$lKey.'/'
-                                               );
-                                       }
-                               }
-                       }
-               }
-
-               return $dataPart;
-       }
-
-       /**
-        * Processing of the sheet/language data array
-        * When it finds a field with a value the processing is done by ->checkValue_SW() by default but if a call back function name is given that method in this class will be called for the processing instead.
-        *
-        * @param       array           New values (those being processed): Multidimensional Data array for sheet/language, passed by reference!
-        * @param       array           Current values: Multidimensional Data array. May be empty array() if not needed (for callBackFunctions)
-        * @param       array           Uploaded files array for sheet/language. May be empty array() if not needed (for callBackFunctions)
-        * @param       array           Data structure which fits the data array
-        * @param       array           A set of parameters to pass through for the calling of the evaluation functions / call back function
-        * @param       string          Call back function, default is checkValue_SW(). If $this->callBackObj is set to an object, the callback function in that object is called instead.
-        * @param       [type]          $structurePath: ...
-        * @return      void
-        * @see checkValue_flex_procInData()
-        */
-       function checkValue_flex_procInData_travDS(&$dataValues,$dataValues_current,$uploadedFiles,$DSelements,$pParams,$callBackFunc,$structurePath)   {
-               if (is_array($DSelements))      {
-
-                               // For each DS element:
-                       foreach($DSelements as $key => $dsConf) {
-
-                                               // Array/Section:
-                               if ($DSelements[$key]['type']=='array') {
-                                       if (is_array($dataValues[$key]['el']))  {
-                                               if ($DSelements[$key]['section'])       {
-                                                       foreach($dataValues[$key]['el'] as $ik => $el)  {
-                                                               $theKey = key($el);
-                                                               if (is_array($dataValues[$key]['el'][$ik][$theKey]['el']))      {
-                                                                       $this->checkValue_flex_procInData_travDS(
-                                                                                       $dataValues[$key]['el'][$ik][$theKey]['el'],
-                                                                                       $dataValues_current[$key]['el'][$ik][$theKey]['el'],
-                                                                                       $uploadedFiles[$key]['el'][$ik][$theKey]['el'],
-                                                                                       $DSelements[$key]['el'][$theKey]['el'],
-                                                                                       $pParams,
-                                                                                       $callBackFunc,
-                                                                                       $structurePath.$key.'/el/'.$ik.'/'.$theKey.'/el/'
-                                                                               );
-                                                               }
-                                                       }
-                                               } else {
-                                                       if (!isset($dataValues[$key]['el']))    $dataValues[$key]['el']=array();
-                                                       $this->checkValue_flex_procInData_travDS(
-                                                                       $dataValues[$key]['el'],
-                                                                       $dataValues_current[$key]['el'],
-                                                                       $uploadedFiles[$key]['el'],
-                                                                       $DSelements[$key]['el'],
-                                                                       $pParams,
-                                                                       $callBackFunc,
-                                                                       $structurePath.$key.'/el/'
-                                                               );
-                                               }
-                                       }
-                               } else {
-                                       if (is_array($dsConf['TCEforms']['config']) && is_array($dataValues[$key]))     {
-                                               foreach($dataValues[$key] as $vKey => $data)    {
-
-                                                       if ($callBackFunc)      {
-                                                               if (is_object($this->callBackObj))      {
-                                                                       $res = $this->callBackObj->$callBackFunc(
-                                                                                               $pParams,
-                                                                                               $dsConf['TCEforms']['config'],
-                                                                                               $dataValues[$key][$vKey],
-                                                                                               $dataValues_current[$key][$vKey],
-                                                                                               $uploadedFiles[$key][$vKey],
-                                                                                               $structurePath.$key.'/'.$vKey.'/'
-                                                                                       );
-                                                               } else {
-                                                                       $res = $this->$callBackFunc(
-                                                                                               $pParams,
-                                                                                               $dsConf['TCEforms']['config'],
-                                                                                               $dataValues[$key][$vKey],
-                                                                                               $dataValues_current[$key][$vKey],
-                                                                                               $uploadedFiles[$key][$vKey]
-                                                                                       );
-                                                               }
-                                                       } else {        // Default
-                                                               list($CVtable,$CVid,$CVcurValue,$CVstatus,$CVrealPid,$CVrecFID,$CVtscPID) = $pParams;
-
-                                                               $res = $this->checkValue_SW(
-                                                                                       array(),
-                                                                                       $dataValues[$key][$vKey],
-                                                                                       $dsConf['TCEforms']['config'],
-                                                                                       $CVtable,
-                                                                                       $CVid,
-                                                                                       $dataValues_current[$key][$vKey],
-                                                                                       $CVstatus,
-                                                                                       $CVrealPid,
-                                                                                       $CVrecFID,
-                                                                                       '',
-                                                                                       $uploadedFiles[$key][$vKey],
-                                                                                       array(),
-                                                                                       $CVtscPID
-                                                                               );
-
-                                                                       // Look for RTE transformation of field:
-                                                               if ($dataValues[$key]['_TRANSFORM_'.$vKey] == 'RTE' && !$this->dontProcessTransformations)      {
-
-                                                                               // Unsetting trigger field - we absolutely don't want that into the data storage!
-                                                                       unset($dataValues[$key]['_TRANSFORM_'.$vKey]);
-
-                                                                       if (isset($res['value']))       {
-
-                                                                                       // Calculating/Retrieving some values here:
-                                                                               list(,,$recFieldName) = explode(':', $CVrecFID);
-                                                                               $theTypeString = t3lib_BEfunc::getTCAtypeValue($CVtable,$this->checkValue_currentRecord);
-                                                                               $specConf = t3lib_BEfunc::getSpecConfParts('',$dsConf['TCEforms']['defaultExtras']);
-
-                                                                                       // Find, thisConfig:
-                                                                               $RTEsetup = $this->BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($CVtscPID));
-                                                                               $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$CVtable,$recFieldName,$theTypeString);
+        * TODO: Like _DELETE_FLEX_FORMdata, this is only a temporary solution!
+        *
+        * @param       array           &$valueArrayToMoveIn: by reference
+        * @param       [type]          $moveCMDS: ...   *
+        * @param       string          $direction: 'up' or 'down'
+        * @return      void
+        */
+       function _MOVE_FLEX_FORMdata(&$valueArrayToMoveIn, $moveCMDS, $direction)       {
+               if (is_array($valueArrayToMoveIn) && is_array($moveCMDS))       {
 
-                                                                                       // Get RTE object, draw form and set flag:
-                                                                               $RTEobj = &t3lib_BEfunc::RTEgetObj();
-                                                                               if (is_object($RTEobj)) {
-                                                                                       $res['value'] = $RTEobj->transformContent('db',$res['value'],$CVtable,$recFieldName,$this->checkValue_currentRecord,$specConf,$thisConfig,'',$CVrealPid);
-                                                                               } else {
-                                                                                       debug('NO RTE OBJECT FOUND!');
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
+                               // Only execute the first move command:
+                       list ($key, $value) = each ($moveCMDS);
 
-                                                               // Adding the value:
-                                                       if (isset($res['value']))       {
-                                                               $dataValues[$key][$vKey] = $res['value'];
-                                                       }
+                       if (is_array($moveCMDS[$key]))  {
+                               $this->_MOVE_FLEX_FORMdata($valueArrayToMoveIn[$key],$moveCMDS[$key], $direction);
+                       } else {
+                               switch ($direction) {
+                                       case 'up':
+                                               if ($key > 1) {
+                                                       $tmpArr = $valueArrayToMoveIn[$key];
+                                                       $valueArrayToMoveIn[$key] = $valueArrayToMoveIn[$key-1];
+                                                       $valueArrayToMoveIn[$key-1] = $tmpArr;
                                                }
-                                       }
+                                       break;
+                                       case 'down':
+                                               if ($key < count($valueArrayToMoveIn)) {
+                                                       $tmpArr = $valueArrayToMoveIn[$key];
+                                                       $valueArrayToMoveIn[$key] = $valueArrayToMoveIn[$key+1];
+                                                       $valueArrayToMoveIn[$key+1] = $tmpArr;
+                                               }
+                                       break;
                                }
                        }
                }
@@ -2338,375 +1612,358 @@ class t3lib_TCEmain   {
 
 
 
-
-
        /*********************************************
         *
-        * Storing data to Database Layer
+        * Helper functions for evaluation functions.
         *
         ********************************************/
 
-
        /**
-        * Update database record
-        * Does not check permissions but expects them to be verified on beforehand
+        * Gets a unique value for $table/$id/$field based on $value
         *
-        * @param       string          Record table name
-        * @param       integer         Record uid
-        * @param       array           Array of field=>value pairs to insert. FIELDS MUST MATCH the database FIELDS. No check is done.
-        * @return      void
+        * @param       string          Table name
+        * @param       string          Field name for which $value must be unique
+        * @param       string          Value string.
+        * @param       integer         UID to filter out in the lookup (the record itself...)
+        * @param       integer         If set, the value will be unique for this PID
+        * @return      string          Modified value (if not-unique). Will be the value appended with a number (until 100, then the function just breaks).
         */
-       function updateDB($table,$id,$fieldArray)       {
+       function getUnique($table,$field,$value,$id,$newPid=0)  {
                global $TCA;
 
-               if (is_array($fieldArray) && is_array($TCA[$table]) && intval($id))     {
-                       unset($fieldArray['uid']);      // Do NOT update the UID field, ever!
-
-                       if (count($fieldArray)) {
-
-                                       // Execute the UPDATE query:
-                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($id), $fieldArray);
-
-                                       // If succees, do...:
-                               if (!$GLOBALS['TYPO3_DB']->sql_error()) {
-                                       if ($this->checkStoredRecords)  {
-                                               $newRow = $this->checkStoredRecord($table,$id,$fieldArray,2);
-                                       }
-
-                                               // Set log entry:
-                                       $propArr = $this->getRecordPropertiesFromRow($table,$newRow);
-                                       $theLogId = $this->log($table,$id,2,$recpid,0,"Record '%s' (%s) was updated.",10,array($propArr['header'],$table.':'.$id),$propArr['event_pid']);
-
-                                               // Set History data:
-                                       $this->setHistory($table,$id,$theLogId);
-
-                                               // Clear cache for relavant pages:
-                                       $this->clear_cache($table,$id);
-
-                                               // Unset the pageCache for the id if table was page.
-                                       if ($table=='pages')    unset($this->pageCache[$id]);
-                               } else {
-                                       $this->log($table,$id,2,0,2,"SQL error: '%s' (%s)",12,array($GLOBALS['TYPO3_DB']->sql_error(),$table.':'.$id));
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Compares the incoming field array with the current record and unsets all fields which are the same.
-        * If the returned array is empty, then the record should not be updated!
-        * $fieldArray must be an array.
-        *
-        * @param       string          Record table name
-        * @param       integer         Record uid
-        * @param       array           Array of field=>value pairs intended to be inserted into the database. All keys with values matching exactly the current value will be unset!
-        * @return      array           Returns $fieldArray
-        */
-       function compareFieldArrayWithCurrentAndUnset($table,$id,$fieldArray)   {
-
-                       // Fetch the original record:
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.intval($id));
-               $currentRecord = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
-
-                       // If the current record exists (which it should...), begin comparison:
-               if (is_array($currentRecord))   {
+                       // Initialize:
+               t3lib_div::loadTCA($table);
+               $whereAdd='';
+               $newValue='';
+               if (intval($newPid))    { $whereAdd.=' AND pid='.intval($newPid); } else { $whereAdd.=' AND pid>=0'; }  // "AND pid>=0" for versioning
+               $whereAdd.=$this->deleteClause($table);
 
-                               // Read all field types:
-                       $c = 0;
-                       $cRecTypes = array();
-                       foreach($currentRecord as $col => $val) {
-// DBAL
-#                              $cRecTypes[$col] = $GLOBALS['TYPO3_DB']->sql_field_type($table,$col);
-                               $cRecTypes[$col] = $GLOBALS['TYPO3_DB']->sql_field_type($res,$c);
-                               $c++;
-                       }
-#debug($cRecTypes);
+                       // If the field is configured in TCA, proceed:
+               if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$field]))        {
 
-                               // Free result:
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
+                               // Look for a record which might already have the value:
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, $field.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($value, $table).' AND uid!='.intval($id).$whereAdd);
+                       $counter = 0;
 
-                               // Unset the fields which are similar:
-                       foreach($fieldArray as $col => $val)    {
-                               if (
-                                               #!isset($currentRecord[$col]) ||                // Unset fields which were NOT found in the current record! [Uncommented because NULL fields will not return an entry in the array!]
-                                               !strcmp($val,$currentRecord[$col]) ||   // Unset fields which matched exactly.
-                                               ($cRecTypes[$col]=='int' && $currentRecord[$col]==0 && !strcmp($val,''))        // Now, a situation where TYPO3 tries to put an empty string into an integer field, we should not strcmp the integer-zero and '', but rather accept them to be similar.
-                                       )       {
-                                       unset($fieldArray[$col]);
-                               } else {
-                                       $this->historyRecords[$table.':'.$id]['oldRecord'][$col] = $currentRecord[$col];
-                                       $this->historyRecords[$table.':'.$id]['newRecord'][$col] = $fieldArray[$col];
-                               }
+                               // For as long as records with the test-value existing, try again (with incremented numbers appended).
+                       while ($GLOBALS['TYPO3_DB']->sql_num_rows($res))        {
+                               $newValue = $value.$counter;
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, $field.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($newValue, $table).' AND uid!='.intval($id).$whereAdd);
+                               $counter++;
+                               if ($counter>100)       { break; }      // At "100" it will give up and accept a duplicate - should probably be fixed to a small hash string instead...!
                        }
-               } else {        // If the current record does not exist this is an error anyways and we just return an empty array here.
-                       $fieldArray = array();
+                               // If the new value is there:
+                       $value = strlen($newValue) ? $newValue : $value;
                }
-
-               return $fieldArray;
+               return $value;
        }
 
        /**
-        * Insert into database
-        * Does not check permissions but expects them to be verified on beforehand
+        * Evaluation of 'input'-type values based on 'eval' list
         *
-        * @param       string          Record table name
-        * @param       string          "NEW...." uid string
-        * @param       array           Array of field=>value pairs to insert. FIELDS MUST MATCH the database FIELDS. No check is done. "pid" must point to the destination of the record!
-        * @param       boolean         Set to true if new version is created.
-        * @param       integer         Suggested UID value for the inserted record. See the array $this->suggestedInsertUids; Admin-only feature
-        * @return      void
+        * @param       string          Value
+        * @param       array           Array of evaluations to traverse.
+        * @param       string          Is-in string
+        * @return      string          Modified $value
         */
-       function insertDB($table,$id,$fieldArray,$newVersion=FALSE,$suggestedUid=0,$dontSetNewIdIndex=FALSE)    {
-               global $TCA;
-
-               if (is_array($fieldArray) && is_array($TCA[$table]) && isset($fieldArray['pid']))       {
-                       unset($fieldArray['uid']);      // Do NOT insert the UID field, ever!
-
-                       if (count($fieldArray)) {
-
-                                       // Check for "suggestedUid".
-                                       // This feature is used by the import functionality to force a new record to have a certain UID value.
-                                       // This is only recommended for use when the destination server is a passive mirrow of another server.
-                                       // As a security measure this feature is available only for Admin Users (for now)
-                               $suggestedUid = intval($suggestedUid);
-                               if ($this->BE_USER->isAdmin() && $suggestedUid && $this->suggestedInsertUids[$table.':'.$suggestedUid]) {
-                                               // When the value of ->suggestedInsertUids[...] is "DELETE" it will try to remove the previous record
-                                       if ($this->suggestedInsertUids[$table.':'.$suggestedUid]==='DELETE')    {
-                                                       // DELETE:
-                                               $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'uid='.intval($suggestedUid));
-                                       }
-                                       $fieldArray['uid'] = $suggestedUid;
-                               }
-
-                                       // Execute the INSERT query:
-                               $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $fieldArray);
-
-                                       // If succees, do...:
-                               if (!$GLOBALS['TYPO3_DB']->sql_error()) {
-
-                                               // Set mapping for NEW... -> real uid:
-                                       $NEW_id = $id;          // the NEW_id now holds the 'NEW....' -id
-                                       $id = $GLOBALS['TYPO3_DB']->sql_insert_id();
-                                       if (!$dontSetNewIdIndex)        {
-                                               $this->substNEWwithIDs[$NEW_id] = $id;
-                                               $this->substNEWwithIDs_table[$NEW_id] = $table;
-                                       }
+       function checkValue_input_Eval($value,$evalArray,$is_in)        {
+               $res = Array();
+               $newValue = $value;
+               $set = true;
 
-                                               // Checking the record is properly saved and writing to log
-                                       if ($this->checkStoredRecords)  {
-                                               $newRow = $this->checkStoredRecord($table,$id,$fieldArray,1);
+               foreach($evalArray as $func)    {
+                       switch($func)   {
+                               case 'int':
+                               case 'year':
+                               case 'date':
+                               case 'datetime':
+                               case 'time':
+                               case 'timesec':
+                                       $value = intval($value);
+                               break;
+                               case 'double2':
+                                       $theDec = 0;
+                                       for ($a=strlen($value); $a>0; $a--)     {
+                                               if (substr($value,$a-1,1)=='.' || substr($value,$a-1,1)==',')   {
+                                                       $theDec = substr($value,$a);
+                                                       $value = substr($value,0,$a-1);
+                                                       break;
+                                               }
                                        }
-
-                                       if ($newVersion)        {
-                                               $this->log($table,$id,1,0,0,"New version created of table '%s', uid '%s'",10,array($table,$fieldArray['t3ver_oid']),$newRow['pid'],$NEW_id);
-                                       } else {
-                                                       // Set log entry:
-                                               if ($table=='pages')    {
-                                                       $thePositionID = $this->getInterfacePagePositionID($id);
-                                               } else {
-                                                       $thePositionID = 0;
+                                       $theDec = ereg_replace('[^0-9]','',$theDec).'00';
+                                       $value = intval(str_replace(' ','',$value)).'.'.substr($theDec,0,2);
+                               break;
+                               case 'md5':
+                                       if (strlen($value)!=32){$set=false;}
+                               break;
+                               case 'trim':
+                                       $value = trim($value);
+                               break;
+                               case 'upper':
+                                       $value = strtoupper($value);
+#                                      $value = strtr($value, 'áéúíâêûôîæøåäöü', 'ÁÉÚÍÂÊÛÔÎÆØÅÄÖÜ');   // WILL make trouble with other charsets than ISO-8859-1, so what do we do here? PHP-function which can handle this for other charsets? Currently the browsers JavaScript will fix it.
+                               break;
+                               case 'lower':
+                                       $value = strtolower($value);
+#                                      $value = strtr($value, 'ÁÉÚÍÂÊÛÔÎÆØÅÄÖÜ', 'áéúíâêûôîæøåäöü');   // WILL make trouble with other charsets than ISO-8859-1, so what do we do here? PHP-function which can handle this for other charsets? Currently the browsers JavaScript will fix it.
+                               break;
+                               case 'required':
+                                       if (!$value)    {$set=0;}
+                               break;
+                               case 'is_in':
+                                       $c=strlen($value);
+                                       if ($c) {
+                                               $newVal = '';
+                                               for ($a=0;$a<$c;$a++)   {
+          &nb