2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Contains the TYPO3 Core Engine
30 * Revised for TYPO3 3.9 October 2005 by Kasper Skårhøj
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 * This is the TYPO3 Core Engine class for manipulation of the database
38 * This class is used by eg. the tce_db.php script which provides an the interface for POST forms to this class.
41 * - $GLOBALS['TCA'] must exist
42 * - $GLOBALS['LANG'] must exist
44 * tce_db.php for further comments and SYNTAX! Also see document 'TYPO3 Core API' for details.
46 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
53 // *********************
54 // Public variables you can configure before using the class:
55 // *********************
57 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.
58 var $enableLogging = TRUE; // Boolean: If TRUE, actions are logged to sys_log.
59 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.
60 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.
61 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!
62 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
63 var $checkStoredRecords_loose = TRUE; // Boolean: If set, values '' and 0 will equal each other when the stored records are checked.
64 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
65 var $neverHideAtCopy = FALSE; // Boolean. If set, then the 'hideAtCopy' flag for tables will be ignored.
66 var $dontProcessTransformations = FALSE; // Boolean: If set, then transformations are NOT performed on the input.
67 var $clear_flexFormData_vDEFbase = FALSE; // Boolean: If set, .vDEFbase values are unset in flexforms.
68 var $updateModeL10NdiffData = TRUE; // Boolean/Mixed: TRUE: (traditional) Updates when record is saved. For flexforms, updates if change is made to the localized value. FALSE: Will not update anything. "FORCE_FFUPD" (string): Like TRUE, but will force update to the FlexForm Field
69 var $updateModeL10NdiffDataClear = FALSE; // Boolean: If TRUE, the translation diff. fields will in fact be reset so that they indicate that all needs to change again! It's meant as the opposite of declaring the record translated.
70 var $bypassWorkspaceRestrictions = FALSE; // Boolean: If TRUE, workspace restrictions are bypassed on edit an create actions (process_datamap()). YOU MUST KNOW what you do if you use this feature!
71 var $bypassFileHandling = FALSE; // Boolean: If TRUE, file handling of attached files (addition, deletion etc) is bypassed - the value is saved straight away. YOU MUST KNOW what you are doing with this feature!
72 var $bypassAccessCheckForRecords = FALSE; // Boolean: If TRUE, access check, check for deleted etc. for records is bypassed. YOU MUST KNOW what you are doing if you use this feature!
74 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)
76 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
78 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)
79 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!
80 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.
81 var $alternativeFilePath = array(); // Array [filename]=alternative_filepath: Same as alternativeFileName but with relative path to the file
82 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.
83 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)
85 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.
88 // *********************
89 // Internal variables (mapping arrays) which can be used (read-only) from outside
90 // *********************
92 var $autoVersionIdMap = array(); // Contains mapping of auto-versionized records.
93 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
94 var $substNEWwithIDs_table = array(); // Like $substNEWwithIDs, but where each old "NEW..." id is mapped to the table it was from.
95 var $newRelatedIDs = array(); // Holds the tables and there the ids of newly created child records from IRRE
96 var $copyMappingArray_merged = array(); // This array is the sum of all copying operations in this class. May be READ from outside, thus partly public.
97 var $copiedFileMap = array(); // A map between input file name and final destination for files being attached to records.
98 var $RTEmagic_copyIndex = array(); // Contains [table][id][field] of fiels where RTEmagic images was copied. Holds old filename as key and new filename as value.
99 var $errorLog = array(); // Errors are collected in this variable.
102 // *********************
103 // Internal Variables, do not touch.
104 // *********************
106 // Variables set in init() function:
108 * The user-object the script uses. If not set from outside, this is set to the current global $BE_USER.
110 * @var t3lib_beUserAuth
113 var $userid; // will be set to uid of be_user executing this script
114 var $username; // will be set to username of be_user executing this script
115 var $admin; // will be set if user is admin
117 var $defaultPermissions = array( // Can be overridden from $GLOBALS['TYPO3_CONF_VARS']
118 'user' => 'show,edit,delete,new,editcontent',
119 'group' => 'show,edit,new,editcontent',
123 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.
124 var $datamap = array(); // Set with incoming data array
125 var $cmdmap = array(); // Set with incoming cmd array
128 var $pMap = array( // Permission mapping
129 'show' => 1, // 1st bit
130 'edit' => 2, // 2nd bit
131 'delete' => 4, // 3rd bit
132 'new' => 8, // 4th bit
133 'editcontent' => 16 // 5th bit
135 var $sortIntervals = 256; // Integer: The interval between sorting numbers used with tables with a 'sorting' field defined. Min 1
137 // Internal caching arrays
138 var $recUpdateAccessCache = array(); // Used by function checkRecordUpdateAccess() to store whether a record is updateable or not.
139 var $recInsertAccessCache = array(); // User by function checkRecordInsertAccess() to store whether a record can be inserted on a page id
140 var $isRecordInWebMount_Cache = array(); // Caching array for check of whether records are in a webmount
141 var $isInWebMount_Cache = array(); // Caching array for page ids in webmounts
142 var $cachedTSconfig = array(); // Caching for collecting TSconfig for page ids
143 var $pageCache = array(); // Used for caching page records in pageInfo()
144 var $checkWorkspaceCache = array(); // Array caching workspace access for BE_USER
147 var $dbAnalysisStore = array(); // For accumulation of MM relations that must be written after new records are created.
148 var $removeFilesStore = array(); // For accumulation of files which must be deleted after processing of all input content
149 var $uploadedFileArray = array(); // Uploaded files, set by process_uploads()
150 var $registerDBList = array(); // Used for tracking references that might need correction after operations
151 var $registerDBPids = array(); // Used for tracking references that might need correction in pid field after operations (e.g. IRRE)
152 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.
153 var $remapStack = array(); // array used for remapping uids and values at the end of process_datamap
154 var $remapStackRecords = array(); // array used for remapping uids and values at the end of process_datamap (e.g. $remapStackRecords[<table>][<uid>] = <index in $remapStack>)
155 protected $remapStackChildIds = array(); // array used for checking whether new children need to be remapped
156 protected $remapStackActions = array(); // array used for executing addition actions after remapping happened (sett processRemapStack())
157 protected $remapStackRefIndex = array(); // array used for executing post-processing on the reference index
158 var $updateRefIndexStack = array(); // array used for additional calls to $this->updateRefIndex
159 var $callFromImpExp = FALSE; // tells, that this TCEmain was called from tx_impext - this variable is set by tx_impexp
160 var $newIndexMap = array(); // Array for new flexform index mapping
164 * basicFileFunctions object
166 * @var t3lib_basicFileFunctions
168 var $fileFunc; // For "singleTon" file-manipulation object
169 var $checkValue_currentRecord = array(); // Set to "currentRecord" during checking of values.
170 var $autoVersioningUpdate = FALSE; // A signal flag used to tell file processing that autoversioning has happend and hence certain action should be applied.
172 protected $disableDeleteClause = FALSE; // Disable delete clause
173 protected $checkModifyAccessListHookObjects;
174 protected $version_remapMMForVersionSwap_reg;
177 * The outer most instance of t3lib_TCEmain
178 * (t3lib_TCEmain instantiates itself on versioning and localization)
181 protected $outerMostInstance = NULL;
185 * For details, see 'TYPO3 Core API' document.
186 * This function does not start the processing of data, but merely initializes the object
188 * @param array Data to be modified or inserted in the database
189 * @param array Commands to copy, move, delete, localize, versionize records.
190 * @param object An alternative userobject you can set instead of the default, which is $GLOBALS['BE_USER']
193 public function start($data, $cmd, $altUserObject = '') {
195 // Initializing BE_USER
196 $this->BE_USER
= is_object($altUserObject) ?
$altUserObject : $GLOBALS['BE_USER'];
197 $this->userid
= $this->BE_USER
->user
['uid'];
198 $this->username
= $this->BE_USER
->user
['username'];
199 $this->admin
= $this->BE_USER
->user
['admin'];
201 if ($this->BE_USER
->uc
['recursiveDelete']) {
202 $this->deleteTree
= 1;
205 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['explicitConfirmationOfTranslation'] && $this->updateModeL10NdiffData
=== TRUE) {
206 $this->updateModeL10NdiffData
= FALSE;
209 // Initializing default permissions for pages
210 $defaultPermissions = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPermissions'];
211 if (isset($defaultPermissions['user'])) {
212 $this->defaultPermissions
['user'] = $defaultPermissions['user'];
214 if (isset($defaultPermissions['group'])) {
215 $this->defaultPermissions
['group'] = $defaultPermissions['group'];
217 if (isset($defaultPermissions['everybody'])) {
218 $this->defaultPermissions
['everybody'] = $defaultPermissions['everybody'];
221 // generates the excludelist, based on TCA/exclude-flag and non_exclude_fields for the user:
222 $this->exclude_array
= $this->admin ?
array() : $this->getExcludeListArray();
224 // Setting the data and cmd arrays
225 if (is_array($data)) {
227 $this->datamap
= $data;
229 if (is_array($cmd)) {
231 $this->cmdmap
= $cmd;
236 * Function that can mirror input values in datamap-array to other uid numbers.
237 * 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]
239 * @param array This array has the syntax $mirror[table_name][uid] = [list of uids to copy data-value TO!]
242 function setMirror($mirror) {
243 if (is_array($mirror)) {
244 foreach ($mirror as $table => $uid_array) {
245 if (isset($this->datamap
[$table])) {
246 foreach ($uid_array as $id => $uidList) {
247 if (isset($this->datamap
[$table][$id])) {
248 $theIdsInArray = t3lib_div
::trimExplode(',', $uidList, 1);
249 foreach ($theIdsInArray as $copyToUid) {
250 $this->datamap
[$table][$copyToUid] = $this->datamap
[$table][$id];
260 * Initializes default values coming from User TSconfig
262 * @param array User TSconfig array
265 function setDefaultsFromUserTS($userTS) {
266 if (is_array($userTS)) {
267 foreach ($userTS as $k => $v) {
268 $k = substr($k, 0, -1);
269 if ($k && is_array($v) && isset($GLOBALS['TCA'][$k])) {
270 if (is_array($this->defaultValues
[$k])) {
271 $this->defaultValues
[$k] = array_merge($this->defaultValues
[$k], $v);
273 $this->defaultValues
[$k] = $v;
281 * Processing of uploaded files.
282 * It turns out that some versions of PHP arranges submitted data for files different if sent in an array. This function will unify this so the internal array $this->uploadedFileArray will always contain files arranged in the same structure.
284 * @param array $_FILES array
287 function process_uploads($postFiles) {
289 if (is_array($postFiles)) {
292 if ($this->BE_USER
->workspace
!== 0 && $this->BE_USER
->workspaceRec
['freeze']) {
293 $this->newlog('All editing in this workspace has been frozen!', 1);
297 $subA = reset($postFiles);
298 if (is_array($subA)) {
299 if (is_array($subA['name']) && is_array($subA['type']) && is_array($subA['tmp_name']) && is_array($subA['size'])) {
300 // Initialize the uploadedFilesArray:
301 $this->uploadedFileArray
= array();
304 foreach ($subA as $key => $values) {
305 $this->process_uploads_traverseArray($this->uploadedFileArray
, $values, $key);
308 $this->uploadedFileArray
= $subA;
315 * Traverse the upload array if needed to rearrange values.
317 * @param array $this->uploadedFileArray passed by reference
318 * @param array Input array ($_FILES parts)
319 * @param string The current $_FILES array key to set on the outermost level.
322 * @see process_uploads()
324 function process_uploads_traverseArray(&$outputArr, $inputArr, $keyToSet) {
325 if (is_array($inputArr)) {
326 foreach ($inputArr as $key => $value) {
327 $this->process_uploads_traverseArray($outputArr[$key], $inputArr[$key], $keyToSet);
330 $outputArr[$keyToSet] = $inputArr;
335 /*********************************************
339 *********************************************/
342 * Hook: processDatamap_afterDatabaseOperations
343 * (calls $hookObj->processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $this);)
345 * Note: When using the hook after INSERT operations, you will only get the temporary NEW... id passed to your hook as $id,
346 * but you can easily translate it to the real uid of the inserted record using the $this->substNEWwithIDs array.
348 * @param object $hookObjectsArr: (reference) Array with hook objects
349 * @param string $status: (reference) Status of the current operation, 'new' or 'update
350 * @param string $table: (refrence) The table currently processing data for
351 * @param string $id: (reference) The record uid currently processing data for, [integer] or [string] (like 'NEW...')
352 * @param array $fieldArray: (reference) The field array of a record
355 function hook_processDatamap_afterDatabaseOperations(&$hookObjectsArr, &$status, &$table, &$id, &$fieldArray) {
356 // Process hook directly:
357 if (!isset($this->remapStackRecords
[$table][$id])) {
358 foreach ($hookObjectsArr as $hookObj) {
359 if (method_exists($hookObj, 'processDatamap_afterDatabaseOperations')) {
360 $hookObj->processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $this);
363 // If this record is in remapStack (e.g. when using IRRE), values will be updated/remapped later on. So the hook will also be called later:
365 $this->remapStackRecords
[$table][$id]['processDatamap_afterDatabaseOperations'] = array(
367 'fieldArray' => $fieldArray,
368 'hookObjectsArr' => $hookObjectsArr,
374 * Gets the 'checkModifyAccessList' hook objects.
375 * The first call initializes the accordant objects.
377 * @return array The 'checkModifyAccessList' hook objects (if any)
379 protected function getCheckModifyAccessListHookObjects() {
380 if (!isset($this->checkModifyAccessListHookObjects
)) {
381 $this->checkModifyAccessListHookObjects
= array();
383 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'])) {
384 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'] as $classData) {
385 $hookObject = t3lib_div
::getUserObj($classData);
387 if (!($hookObject instanceof t3lib_TCEmain_checkModifyAccessListHook
)) {
388 throw new UnexpectedValueException('$hookObject must implement interface t3lib_TCEmain_checkModifyAccessListHook', 1251892472);
391 $this->checkModifyAccessListHookObjects
[] = $hookObject;
396 return $this->checkModifyAccessListHookObjects
;
400 /*********************************************
404 *********************************************/
407 * Processing the data-array
408 * Call this function to process the data-array set by start()
412 public function process_datamap() {
413 // Keep versionized(!) relations here locally:
414 $registerDBList = array();
416 $this->registerElementsToBeDeleted();
417 $this->datamap
= $this->unsetElementsToBeDeleted($this->datamap
);
420 if ($this->BE_USER
->workspace
!== 0 && $this->BE_USER
->workspaceRec
['freeze']) {
421 $this->newlog('All editing in this workspace has been frozen!', 1);
425 // First prepare user defined objects (if any) for hooks which extend this function:
426 $hookObjectsArr = array();
427 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'])) {
428 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'] as $classRef) {
429 $hookObjectsArr[] = t3lib_div
::getUserObj($classRef);
433 // 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.
434 $orderOfTables = array();
435 if (isset($this->datamap
['pages'])) { // Set pages first.
436 $orderOfTables[] = 'pages';
438 $orderOfTables = array_unique(array_merge($orderOfTables, array_keys($this->datamap
)));
440 // Process the tables...
441 foreach ($orderOfTables as $table) {
443 - table is set in $GLOBALS['TCA'],
444 - table is NOT readOnly
445 - the table is set with content in the data-array (if not, there's nothing to process...)
446 - permissions for tableaccess OK
448 $modifyAccessList = $this->checkModifyAccessList($table);
449 if (!$modifyAccessList) {
451 $this->log($table, $id, 2, 0, 1, "Attempt to modify table '%s' without permission", 1, array($table));
453 if (isset($GLOBALS['TCA'][$table]) && !$this->tableReadOnly($table) && is_array($this->datamap
[$table]) && $modifyAccessList) {
454 if ($this->reverseOrder
) {
455 $this->datamap
[$table] = array_reverse($this->datamap
[$table], 1);
458 // For each record from the table, do:
459 // $id is the record uid, may be a string if new records...
460 // $incomingFieldArray is the array of fields
461 foreach ($this->datamap
[$table] as $id => $incomingFieldArray) {
462 if (is_array($incomingFieldArray)) {
464 // Hook: processDatamap_preProcessFieldArray
465 foreach ($hookObjectsArr as $hookObj) {
466 if (method_exists($hookObj, 'processDatamap_preProcessFieldArray')) {
467 $hookObj->processDatamap_preProcessFieldArray($incomingFieldArray, $table, $id, $this);
471 // ******************************
472 // Checking access to the record
473 // ******************************
474 $createNewVersion = FALSE;
475 $recordAccess = FALSE;
477 $this->autoVersioningUpdate
= FALSE;
479 if (!t3lib_utility_Math
::canBeInterpretedAsInteger($id)) { // Is it a new record? (Then Id is a string)
480 $fieldArray = $this->newFieldArray($table); // Get a fieldArray with default values
481 if (isset($incomingFieldArray['pid'])) { // A pid must be set for new records.
483 $pid_value = $incomingFieldArray['pid'];
485 // Checking and finding numerical pid, it may be a string-reference to another value
487 if (strstr($pid_value, 'NEW')) { // If a NEW... id
488 if (substr($pid_value, 0, 1) == '-') {
490 $pid_value = substr($pid_value, 1);
494 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.
495 if ($negFlag === 1) {
496 $old_pid_value = $this->substNEWwithIDs
[$pid_value];
498 $pid_value = intval($negFlag * $this->substNEWwithIDs
[$pid_value]);
501 } // If not found in the substArray we must stop the process...
502 } elseif ($pid_value >= 0 && $this->BE_USER
->workspace
!== 0
503 && $GLOBALS['TCA'][$table]['ctrl']['versioning_followPages']) {
504 // PID points to page, the workspace is an offline space and the table follows
505 // page during versioning: This means we must check if the PID page has a version
506 // in the workspace with swapmode set to 0 (zero = page+content) and if so, change
507 // the pid to the uid of that version.
508 if ($WSdestPage = t3lib_BEfunc
::getWorkspaceVersionOfRecord($this->BE_USER
->workspace
, 'pages', $pid_value, 'uid,t3ver_swapmode')) { // Looks for workspace version of page.
509 if ($WSdestPage['t3ver_swapmode'] == 0) { // if swapmode is zero, then change pid value.
510 $pid_value = $WSdestPage['uid'];
514 $pid_value = intval($pid_value);
516 // The $pid_value is now the numerical pid at this point
518 $sortRow = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
519 if ($pid_value >= 0) { // Points to a page on which to insert the element, possibly in the top of the page
520 if ($sortRow) { // If this table is sorted we better find the top sorting number
521 $fieldArray[$sortRow] = $this->getSortNumber($table, 0, $pid_value);
523 $fieldArray['pid'] = $pid_value; // The numerical pid is inserted in the data array
524 } else { // points to another record before ifself
525 if ($sortRow) { // If this table is sorted we better find the top sorting number
526 $tempArray = $this->getSortNumber($table, 0, $pid_value); // Because $pid_value is < 0, getSortNumber returns an array
527 $fieldArray['pid'] = $tempArray['pid'];
528 $fieldArray[$sortRow] = $tempArray['sortNumber'];
529 } else { // Here we fetch the PID of the record that we point to...
530 $tempdata = $this->recordInfo($table, abs($pid_value), 'pid');
531 $fieldArray['pid'] = $tempdata['pid'];
536 $theRealPid = $fieldArray['pid'];
538 // Now, check if we may insert records on this pid.
539 if ($theRealPid >= 0) {
540 $recordAccess = $this->checkRecordInsertAccess($table, $theRealPid); // Checks if records can be inserted on this $pid.
542 $this->addDefaultPermittedLanguageIfNotSet($table, $incomingFieldArray);
543 $recordAccess = $this->BE_USER
->recordEditAccessInternals($table, $incomingFieldArray, TRUE);
544 if (!$recordAccess) {
545 $this->newlog("recordEditAccessInternals() check failed. [" . $this->BE_USER
->errorMsg
. "]", 1);
546 } elseif (!$this->bypassWorkspaceRestrictions
) {
547 // Workspace related processing:
548 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
550 $recordAccess = FALSE;
551 $this->newlog('Stage for versioning root point and users access level did not allow for editing', 1);
553 } else { // So, if no live records were allowed, we have to create a new version of this record:
554 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
555 $createNewVersion = TRUE;
557 $recordAccess = FALSE;
558 $this->newlog('Record could not be created in this workspace in this branch', 1);
564 debug('Internal ERROR: pid should not be less than zero!');
566 $status = 'new'; // Yes new record, change $record_status to 'insert'
567 } else { // Nope... $id is a number
568 $fieldArray = array();
569 $recordAccess = $this->checkRecordUpdateAccess($table, $id, $incomingFieldArray, $hookObjectsArr);
570 if (!$recordAccess) {
571 $propArr = $this->getRecordProperties($table, $id);
572 $this->log($table, $id, 2, 0, 1, "Attempt to modify record '%s' (%s) without permission. Or non-existing page.", 2, array($propArr['header'], $table . ':' . $id), $propArr['event_pid']);
573 } else { // Next check of the record permissions (internals)
574 $recordAccess = $this->BE_USER
->recordEditAccessInternals($table, $id);
575 if (!$recordAccess) {
576 $propArr = $this->getRecordProperties($table, $id);
577 $this->newlog("recordEditAccessInternals() check failed. [" . $this->BE_USER
->errorMsg
. "]", 1);
578 } else { // Here we fetch the PID of the record that we point to...
579 $tempdata = $this->recordInfo($table, $id, 'pid' .
580 ($GLOBALS['TCA'][$table]['ctrl']['versioningWS'] ?
',t3ver_wsid,t3ver_stage' : '')
582 $theRealPid = $tempdata['pid'];
584 // Use the new id of the versionized record we're trying to write to:
585 // (This record is a child record of a parent and has already been versionized.)
586 if ($this->autoVersionIdMap
[$table][$id]) {
587 // For the reason that creating a new version of this record, automatically
588 // created related child records (e.g. "IRRE"), update the accordant field:
589 $this->getVersionizedIncomingFieldArray($table, $id, $incomingFieldArray, $registerDBList);
591 // Use the new id of the copied/versionized record:
592 $id = $this->autoVersionIdMap
[$table][$id];
593 $recordAccess = TRUE;
594 $this->autoVersioningUpdate
= TRUE;
596 // Checking access in case of offline workspace:
597 } elseif (!$this->bypassWorkspaceRestrictions
&& $errorCode = $this->BE_USER
->workspaceCannotEditRecord($table, $tempdata)) {
598 $recordAccess = FALSE; // Versioning is required and it must be offline version!
600 // 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.
601 if ($this->BE_USER
->workspaceAllowAutoCreation($table, $id, $theRealPid)) {
602 /** @var $tce t3lib_TCEmain */
603 $tce = t3lib_div
::makeInstance('t3lib_TCEmain');
604 /* @var $tce t3lib_TCEmain */
605 $tce->stripslashes_values
= 0;
607 // Setting up command for creating a new version of the record:
609 $cmd[$table][$id]['version'] = array(
611 'treeLevels' => -1, // Default is to create a version of the individual records... element versioning that is.
612 'label' => 'Auto-created for WS #' . $this->BE_USER
->workspace
614 $tce->start(array(), $cmd);
615 $tce->process_cmdmap();
616 $this->errorLog
= array_merge($this->errorLog
, $tce->errorLog
);
618 // If copying was successful, share the new uids (also of related children):
619 if ($tce->copyMappingArray
[$table][$id]) {
620 foreach ($tce->copyMappingArray
as $origTable => $origIdArray) {
621 foreach ($origIdArray as $origId => $newId) {
622 $this->uploadedFileArray
[$origTable][$newId] = $this->uploadedFileArray
[$origTable][$origId];
623 $this->autoVersionIdMap
[$origTable][$origId] = $newId;
626 $this->RTEmagic_copyIndex
= t3lib_div
::array_merge_recursive_overrule($this->RTEmagic_copyIndex
, $tce->RTEmagic_copyIndex
); // See where RTEmagic_copyIndex is used inside fillInFieldArray() for more information...
628 // Update registerDBList, that holds the copied relations to child records:
629 $registerDBList = array_merge($registerDBList, $tce->registerDBList
);
630 // For the reason that creating a new version of this record, automatically
631 // created related child records (e.g. "IRRE"), update the accordant field:
632 $this->getVersionizedIncomingFieldArray($table, $id, $incomingFieldArray, $registerDBList);
634 // Use the new id of the copied/versionized record:
635 $id = $this->autoVersionIdMap
[$table][$id];
636 $recordAccess = TRUE;
637 $this->autoVersioningUpdate
= TRUE;
639 $this->newlog("Could not be edited in offline workspace in the branch where found (failure state: '" . $errorCode . "'). Auto-creation of version failed!", 1);
642 $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);
647 $status = 'update'; // the default is 'update'
650 // If access was granted above, proceed to create or update record:
653 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.
654 $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
655 if ($status == 'new' && $table == 'pages' && is_array($TSConfig['permissions.'])) {
656 $fieldArray = $this->setTSconfigPermissions($fieldArray, $TSConfig['permissions.']);
658 if ($createNewVersion) {
659 $newVersion_placeholderFieldArray = $fieldArray;
662 // Processing of all fields in incomingFieldArray and setting them in $fieldArray
663 $fieldArray = $this->fillInFieldArray($table, $id, $fieldArray, $incomingFieldArray, $theRealPid, $status, $tscPID);
665 // NOTICE! All manipulation beyond this point bypasses both "excludeFields" AND possible "MM" relations / file uploads to field!
667 // Forcing some values unto field array:
668 $fieldArray = $this->overrideFieldArray($table, $fieldArray); // NOTICE: This overriding is potentially dangerous; permissions per field is not checked!!!
669 if ($createNewVersion) {
670 $newVersion_placeholderFieldArray = $this->overrideFieldArray($table, $newVersion_placeholderFieldArray);
673 // Setting system fields
674 if ($status == 'new') {
675 if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) {
676 $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME'];
677 if ($createNewVersion) {
678 $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME'];
681 if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) {
682 $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']] = $this->userid
;
683 if ($createNewVersion) {
684 $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']] = $this->userid
;
687 } elseif ($this->checkSimilar
) { // Removing fields which are equal to the current value:
688 $fieldArray = $this->compareFieldArrayWithCurrentAndUnset($table, $id, $fieldArray);
690 if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'] && count($fieldArray)) {
691 $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
692 if ($createNewVersion) {
693 $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
696 // Set stage to "Editing" to make sure we restart the workflow
697 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
698 $fieldArray['t3ver_stage'] = 0;
701 // Hook: processDatamap_postProcessFieldArray
702 foreach ($hookObjectsArr as $hookObj) {
703 if (method_exists($hookObj, 'processDatamap_postProcessFieldArray')) {
704 $hookObj->processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $this);
708 // Performing insert/update. If fieldArray has been unset by some userfunction (see hook above), don't do anything
709 // Kasper: Unsetting the fieldArray is dangerous; MM relations might be saved already and files could have been uploaded that are now "lost"
710 if (is_array($fieldArray)) {
711 if ($status == 'new') {
712 if ($createNewVersion) { // This creates a new version of the record with online placeholder and offline version
713 $versioningType = ($table === 'pages'
714 ?
$this->BE_USER
->workspaceVersioningTypeGetClosest(-1)
716 if ($this->BE_USER
->workspaceVersioningTypeAccess($versioningType)) {
717 $newVersion_placeholderFieldArray['t3ver_label'] = 'INITIAL PLACEHOLDER';
718 $newVersion_placeholderFieldArray['t3ver_state'] = 1; // Setting placeholder state value for temporary record
719 $newVersion_placeholderFieldArray['t3ver_wsid'] = $this->BE_USER
->workspace
; // Setting workspace - only so display of place holders can filter out those from other workspaces.
720 $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['label']] = '[PLACEHOLDER, WS#' . $this->BE_USER
->workspace
. ']';
721 $this->insertDB($table, $id, $newVersion_placeholderFieldArray, FALSE); // Saving placeholder as 'original'
723 // For the actual new offline version, set versioning values to point to placeholder:
724 $fieldArray['pid'] = -1;
725 $fieldArray['t3ver_oid'] = $this->substNEWwithIDs
[$id];
726 $fieldArray['t3ver_id'] = 1;
727 $fieldArray['t3ver_state'] = -1; // Setting placeholder state value for version (so it can know it is currently a new version...)
728 $fieldArray['t3ver_label'] = 'First draft version';
729 $fieldArray['t3ver_wsid'] = $this->BE_USER
->workspace
;
730 if ($table === 'pages') { // Swap mode set to "branch" so we can build branches for pages.
731 $fieldArray['t3ver_swapmode'] = $versioningType;
733 $phShadowId = $this->insertDB($table, $id, $fieldArray, TRUE, 0, TRUE); // When inserted, $this->substNEWwithIDs[$id] will be changed to the uid of THIS version and so the interface will pick it up just nice!
735 // Processes fields of the placeholder record:
736 $this->triggerRemapAction(
739 array($this, 'placeholderShadowing'),
740 array($table, $phShadowId)
742 // Hold auto-versionized ids of placeholders:
743 $this->autoVersionIdMap
[$table][$this->substNEWwithIDs
[$id]] = $phShadowId;
746 $this->newlog('Versioning type "' . $versioningType . '" was not allowed, so could not create new record.', 1);
749 $this->insertDB($table, $id, $fieldArray, FALSE, $incomingFieldArray['uid']);
752 $this->updateDB($table, $id, $fieldArray);
753 $this->placeholderShadowing($table, $id);
758 * Hook: processDatamap_afterDatabaseOperations
760 * Note: When using the hook after INSERT operations, you will only get the temporary NEW... id passed to your hook as $id,
761 * but you can easily translate it to the real uid of the inserted record using the $this->substNEWwithIDs array.
763 $this->hook_processDatamap_afterDatabaseOperations($hookObjectsArr, $status, $table, $id, $fieldArray);
764 } // if ($recordAccess) {
765 } // if (is_array($incomingFieldArray)) {
770 // Process the stack of relations to remap/correct
771 $this->processRemapStack();
772 $this->dbAnalysisStoreExec();
773 $this->removeRegisteredFiles();
776 * Hook: processDatamap_afterAllOperations
778 * Note: When this hook gets called, all operations on the submitted data have been finished.
780 foreach ($hookObjectsArr as $hookObj) {
781 if (method_exists($hookObj, 'processDatamap_afterAllOperations')) {
782 $hookObj->processDatamap_afterAllOperations($this);
786 if ($this->isOuterMostInstance()) {
787 $this->resetElementsToBeDeleted();
792 * Fix shadowing of data in case we are editing a offline version of a live "New" placeholder record:
794 * @param string Table name
795 * @param integer Record uid
798 function placeholderShadowing($table, $id) {
799 t3lib_div
::loadTCA($table);
800 if ($liveRec = t3lib_BEfunc
::getLiveVersionOfRecord($table, $id, '*')) {
801 if ((int) $liveRec['t3ver_state'] > 0) {
802 $justStoredRecord = t3lib_BEfunc
::getRecord($table, $id);
803 $newRecord = array();
805 $shadowCols = $GLOBALS['TCA'][$table]['ctrl']['shadowColumnsForNewPlaceholders'];
806 $shadowCols .= ',' . $GLOBALS['TCA'][$table]['ctrl']['languageField'];
807 $shadowCols .= ',' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
808 $shadowCols .= ',' . $GLOBALS['TCA'][$table]['ctrl']['type'];
809 $shadowCols .= ',' . $GLOBALS['TCA'][$table]['ctrl']['label'];
811 $shadowColumns = array_unique(t3lib_div
::trimExplode(',', $shadowCols, 1));
812 foreach ($shadowColumns as $fieldName) {
813 if (strcmp($justStoredRecord[$fieldName], $liveRec[$fieldName])
814 && isset($GLOBALS['TCA'][$table]['columns'][$fieldName])
815 && $fieldName !== 'uid' && $fieldName !== 'pid') {
816 $newRecord[$fieldName] = $justStoredRecord[$fieldName];
820 if (count($newRecord)) {
821 $this->newlog2('Shadowing done on fields <i>' . implode(',', array_keys($newRecord)) . '</i> in placeholder record ' . $table . ':' . $liveRec['uid'] . ' (offline version UID=' . $id . ')', $table, $liveRec['uid'], $liveRec['pid']);
822 $this->updateDB($table, $liveRec['uid'], $newRecord);
829 * Filling in the field array
830 * $this->exclude_array is used to filter fields if needed.
832 * @param string Table name
833 * @param integer Record ID
834 * @param array Default values, Preset $fieldArray with 'pid' maybe (pid and uid will be not be overridden anyway)
835 * @param array $incomingFieldArray is which fields/values you want to set. There are processed and put into $fieldArray if OK
836 * @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.
837 * @param string $status = 'new' or 'update'
838 * @param integer $tscPID: TSconfig PID
839 * @return array Field Array
841 function fillInFieldArray($table, $id, $fieldArray, $incomingFieldArray, $realPid, $status, $tscPID) {
844 t3lib_div
::loadTCA($table);
845 $originalLanguageRecord = NULL;
846 $originalLanguage_diffStorage = NULL;
847 $diffStorageFlag = FALSE;
849 // Setting 'currentRecord' and 'checkValueRecord':
850 if (strstr($id, 'NEW')) {
851 $currentRecord = $checkValueRecord = $fieldArray; // must have the 'current' array - not the values after processing below...
853 // IF $incomingFieldArray is an array, overlay it.
854 // The point is that when new records are created as copies with flex type fields there might be a field containing information about which DataStructure to use and without that information the flexforms cannot be correctly processed.... This should be OK since the $checkValueRecord is used by the flexform evaluation only anyways...
855 if (is_array($incomingFieldArray) && is_array($checkValueRecord)) {
856 $checkValueRecord = t3lib_div
::array_merge_recursive_overrule($checkValueRecord, $incomingFieldArray);
859 $currentRecord = $checkValueRecord = $this->recordInfo($table, $id, '*'); // We must use the current values as basis for this!
861 t3lib_BEfunc
::fixVersioningPid($table, $currentRecord); // This is done to make the pid positive for offline versions; Necessary to have diff-view for pages_language_overlay in workspaces.
863 // Get original language record if available:
864 if (is_array($currentRecord)
865 && $GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']
866 && $GLOBALS['TCA'][$table]['ctrl']['languageField']
867 && $currentRecord[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0
868 && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
869 && intval($currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]) > 0) {
871 $lookUpTable = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'] ?
$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'] : $table;
872 $originalLanguageRecord = $this->recordInfo($lookUpTable, $currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']], '*');
873 t3lib_BEfunc
::workspaceOL($lookUpTable, $originalLanguageRecord);
874 $originalLanguage_diffStorage = unserialize($currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']]);
877 $this->checkValue_currentRecord
= $checkValueRecord;
880 In the following all incoming value-fields are tested:
881 - Are the user allowed to change the field?
882 - Is the field uid/pid (which are already set)
883 - perms-fields for pages-table, then do special things...
884 - If the field is nothing of the above and the field is configured in TCA, the fieldvalues are evaluated by ->checkValue
886 If everything is OK, the field is entered into $fieldArray[]
888 foreach ($incomingFieldArray as $field => $fieldValue) {
889 if (!in_array($table . '-' . $field, $this->exclude_array
) && !$this->data_disableFields
[$table][$id][$field]) { // The field must be editable.
891 // Checking if a value for language can be changed:
892 $languageDeny = $GLOBALS['TCA'][$table]['ctrl']['languageField']
893 && !strcmp($GLOBALS['TCA'][$table]['ctrl']['languageField'], $field)
894 && !$this->BE_USER
->checkLanguageAccess($fieldValue);
896 if (!$languageDeny) {
897 // Stripping slashes - will probably be removed the day $this->stripslashes_values is removed as an option...
898 if ($this->stripslashes_values
) {
899 if (is_array($fieldValue)) {
900 t3lib_div
::stripSlashesOnArray($fieldValue);
902 $fieldValue = stripslashes($fieldValue);
909 // Nothing happens, already set
912 case 'perms_groupid':
915 case 'perms_everybody':
916 // Permissions can be edited by the owner or the administrator
917 if ($table == 'pages' && ($this->admin ||
$status == 'new' ||
$this->pageInfo($id, 'perms_userid') == $this->userid
)) {
918 $value = intval($fieldValue);
921 $fieldArray[$field] = $value;
923 case 'perms_groupid':
924 $fieldArray[$field] = $value;
927 if ($value >= 0 && $value < pow(2, 5)) {
928 $fieldArray[$field] = $value;
938 case 't3ver_swapmode':
942 // t3ver_label is not here because it CAN be edited as a regular field!
945 if (isset($GLOBALS['TCA'][$table]['columns'][$field])) {
946 // Evaluating the value
947 $res = $this->checkValue($table, $field, $fieldValue, $id, $status, $realPid, $tscPID);
948 if (isset($res['value'])) {
949 $fieldArray[$field] = $res['value'];
952 // Add the value of the original record to the diff-storage content:
953 if ($this->updateModeL10NdiffData
&& $GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']) {
954 $originalLanguage_diffStorage[$field] = $this->updateModeL10NdiffDataClear ?
'' : $originalLanguageRecord[$field];
955 $diffStorageFlag = TRUE;
958 // If autoversioning is happening we need to perform a nasty hack. The case is parallel to a similar hack inside checkValue_group_select_file().
959 // When a copy or version is made of a record, a search is made for any RTEmagic* images in fields having the "images" soft reference parser applied. That should be TRUE for RTE fields. If any are found they are duplicated to new names and the file reference in the bodytext is updated accordingly.
960 // However, with auto-versioning the submitted content of the field will just overwrite the corrected values. This leaves a) lost RTEmagic files and b) creates a double reference to the old files.
961 // The only solution I can come up with is detecting when auto versioning happens, then see if any RTEmagic images was copied and if so make a stupid string-replace of the content !
962 if ($this->autoVersioningUpdate
=== TRUE) {
963 if (is_array($this->RTEmagic_copyIndex
[$table][$id][$field])) {
964 foreach ($this->RTEmagic_copyIndex
[$table][$id][$field] as $oldRTEmagicName => $newRTEmagicName) {
965 $fieldArray[$field] = str_replace(' src="' . $oldRTEmagicName . '"', ' src="' . $newRTEmagicName . '"', $fieldArray[$field]);
970 } elseif ($GLOBALS['TCA'][$table]['ctrl']['origUid'] === $field) {
971 // Allow value for original UID to pass by...
972 $fieldArray[$field] = $fieldValue;
976 } // Checking language.
977 } // Check exclude fields / disabled fields...
979 // Add diff-storage information:
980 if ($diffStorageFlag && !isset($fieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']])) {
981 // If the field is set it would probably be because of an undo-operation - in which case we should not update the field of course...
982 $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']] = serialize($originalLanguage_diffStorage);
985 // Checking for RTE-transformations of fields:
986 $types_fieldConfig = t3lib_BEfunc
::getTCAtypes($table, $currentRecord);
987 $theTypeString = t3lib_BEfunc
::getTCAtypeValue($table, $currentRecord);
988 if (is_array($types_fieldConfig)) {
989 foreach ($types_fieldConfig as $vconf) {
990 // Write file configuration:
991 $eFile = t3lib_parsehtml_proc
::evalWriteFile($vconf['spec']['static_write'], array_merge($currentRecord, $fieldArray)); // inserted array_merge($currentRecord,$fieldArray) 170502
993 // RTE transformations:
994 if (!$this->dontProcessTransformations
) {
995 if (isset($fieldArray[$vconf['field']])) {
996 // Look for transformation flag:
997 switch ((string) $incomingFieldArray['_TRANSFORM_' . $vconf['field']]) {
999 $RTEsetup = $this->BE_USER
->getTSConfig('RTE', t3lib_BEfunc
::getPagesTSconfig($tscPID));
1000 $thisConfig = t3lib_BEfunc
::RTEsetup($RTEsetup['properties'], $table, $vconf['field'], $theTypeString);
1002 // Set alternative relative path for RTE images/links:
1003 $RTErelPath = is_array($eFile) ?
dirname($eFile['relEditFile']) : '';
1005 // Get RTE object, draw form and set flag:
1006 $RTEobj = t3lib_BEfunc
::RTEgetObj();
1007 if (is_object($RTEobj)) {
1008 $fieldArray[$vconf['field']] = $RTEobj->transformContent('db', $fieldArray[$vconf['field']], $table, $vconf['field'], $currentRecord, $vconf['spec'], $thisConfig, $RTErelPath, $currentRecord['pid']);
1010 debug('NO RTE OBJECT FOUND!');
1017 // Write file configuration:
1018 if (is_array($eFile)) {
1019 $mixedRec = array_merge($currentRecord, $fieldArray);
1020 $SW_fileContent = t3lib_div
::getUrl($eFile['editFile']);
1021 $parseHTML = t3lib_div
::makeInstance('t3lib_parsehtml_proc');
1022 /* @var $parseHTML t3lib_parsehtml_proc */
1023 $parseHTML->init('', '');
1025 $eFileMarker = $eFile['markerField'] && trim($mixedRec[$eFile['markerField']]) ?
trim($mixedRec[$eFile['markerField']]) : '###TYPO3_STATICFILE_EDIT###';
1026 $insertContent = str_replace($eFileMarker, '', $mixedRec[$eFile['contentField']]); // must replace the marker if present in content!
1028 $SW_fileNewContent = $parseHTML->substituteSubpart($SW_fileContent, $eFileMarker, LF
. $insertContent . LF
, 1, 1);
1029 t3lib_div
::writeFile($eFile['editFile'], $SW_fileNewContent);
1032 if (!strstr($id, 'NEW') && $eFile['statusField']) {
1033 $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
1035 'uid=' . intval($id),
1037 $eFile['statusField'] => $eFile['relEditFile'] . ' updated ' . date('d-m-Y H:i:s') . ', bytes ' . strlen($mixedRec[$eFile['contentField']])
1041 } elseif ($eFile && is_string($eFile)) {
1042 $this->log($table, $id, 2, 0, 1, "Write-file error: '%s'", 13, array($eFile), $realPid);
1046 // Return fieldArray
1051 /*********************************************
1053 * Evaluation of input values
1055 ********************************************/
1058 * Evaluates a value according to $table/$field settings.
1059 * This function is for real database fields - NOT FlexForm "pseudo" fields.
1060 * 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() )
1062 * @param string Table name
1063 * @param string Field name
1064 * @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.
1065 * @param string The record-uid, mainly - but not exclusively - used for logging
1066 * @param string 'update' or 'new' flag
1067 * @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.
1068 * @param integer $tscPID
1069 * @return array Returns the evaluated $value as key "value" in this array. Can be checked with isset($res['value']) ...
1071 function checkValue($table, $field, $value, $id, $status, $realPid, $tscPID) {
1072 t3lib_div
::loadTCA($table);
1074 $res = array(); // result array
1075 $recFID = $table . ':' . $id . ':' . $field;
1077 // Processing special case of field pages.doktype
1078 if (($table === 'pages' ||
$table === 'pages_language_overlay') && $field === 'doktype') {
1079 // If the user may not use this specific doktype, we issue a warning
1080 if (!($this->admin || t3lib_div
::inList($this->BE_USER
->groupData
['pagetypes_select'], $value))) {
1081 $propArr = $this->getRecordProperties($table, $id);
1082 $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']);
1086 if ($status == 'update') {
1087 // This checks 1) if we should check for disallowed tables and 2) if there are records from disallowed tables on the current page
1088 $onlyAllowedTables = (isset($GLOBALS['PAGES_TYPES'][$value]['onlyAllowedTables'])
1089 ?
$GLOBALS['PAGES_TYPES'][$value]['onlyAllowedTables']
1090 : $GLOBALS['PAGES_TYPES']['default']['onlyAllowedTables']);
1091 if ($onlyAllowedTables) {
1092 $theWrongTables = $this->doesPageHaveUnallowedTables($id, $value);
1093 if ($theWrongTables) {
1094 $propArr = $this->getRecordProperties($table, $id);
1095 $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']);
1102 // Get current value:
1103 $curValueRec = $this->recordInfo($table, $id, $field);
1104 $curValue = $curValueRec[$field];
1106 // Getting config for the field
1107 $tcaFieldConf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
1109 // Preform processing:
1110 $res = $this->checkValue_SW($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $field, $this->uploadedFileArray
[$table][$id][$field], $tscPID);
1116 * Branches out evaluation of a field value based on its type as configured in $GLOBALS['TCA']
1117 * Can be called for FlexForm pseudo fields as well, BUT must not have $field set if so.
1119 * @param array The result array. The processed value (if any!) is set in the "value" key.
1120 * @param string The value to set.
1121 * @param array Field configuration from $GLOBALS['TCA']
1122 * @param string Table name
1123 * @param integer Return UID
1124 * @param [type] $curValue: ...
1125 * @param [type] $status: ...
1126 * @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.
1127 * @param [type] $recFID: ...
1128 * @param string Field name. Must NOT be set if the call is for a flexform field (since flexforms are not allowed within flexforms).
1129 * @param [type] $uploadedFiles: ...
1130 * @param [type] $tscPID: ...
1131 * @return array Returns the evaluated $value as key "value" in this array.
1133 function checkValue_SW($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $field, $uploadedFiles, $tscPID) {
1135 $PP = array($table, $id, $curValue, $status, $realPid, $recFID, $tscPID);
1137 switch ($tcaFieldConf['type']) {
1139 $res = $this->checkValue_text($res, $value, $tcaFieldConf, $PP, $field);
1143 $res['value'] = $value;
1146 $res = $this->checkValue_input($res, $value, $tcaFieldConf, $PP, $field);
1149 $res = $this->checkValue_check($res, $value, $tcaFieldConf, $PP);
1152 $res = $this->checkValue_radio($res, $value, $tcaFieldConf, $PP);
1156 $res = $this->checkValue_group_select($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field);
1159 $res = $this->checkValue_inline($res, $value, $tcaFieldConf, $PP, $field);
1162 if ($field) { // FlexForms are only allowed for real fields.
1163 $res = $this->checkValue_flex($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field);
1167 #debug(array($tcaFieldConf,$res,$value),'NON existing field type:');
1176 * Evaluate "text" type values.
1178 * @param array The result array. The processed value (if any!) is set in the "value" key.
1179 * @param string The value to set.
1180 * @param array Field configuration from TCA
1181 * @param array Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
1182 * @param string Field name
1183 * @return array Modified $res array
1185 function checkValue_text($res, $value, $tcaFieldConf, $PP, $field = '') {
1186 $evalCodesArray = t3lib_div
::trimExplode(',', $tcaFieldConf['eval'], 1);
1187 $res = $this->checkValue_text_Eval($value, $evalCodesArray, $tcaFieldConf['is_in']);
1192 * Evaluate "input" type values.
1194 * @param array The result array. The processed value (if any!) is set in the "value" key.
1195 * @param string The value to set.
1196 * @param array Field configuration from TCA
1197 * @param array Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
1198 * @param string Field name
1199 * @return array Modified $res array
1201 function checkValue_input($res, $value, $tcaFieldConf, $PP, $field = '') {
1202 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
1204 // Secures the string-length to be less than max.
1205 if (intval($tcaFieldConf['max']) > 0) {
1206 $value = $GLOBALS['LANG']->csConvObj
->substr($GLOBALS['LANG']->charSet
, $value, 0, intval($tcaFieldConf['max']));
1209 // Checking range of value:
1210 if ($tcaFieldConf['range'] && $value != $tcaFieldConf['checkbox'] && $value != $tcaFieldConf['default']) {
1211 if (isset($tcaFieldConf['range']['upper']) && $value > $tcaFieldConf['range']['upper']) {
1212 $value = $tcaFieldConf['range']['upper'];
1214 if (isset($tcaFieldConf['range']['lower']) && $value < $tcaFieldConf['range']['lower']) {
1215 $value = $tcaFieldConf['range']['lower'];
1219 // Process evaluation settings:
1220 $evalCodesArray = t3lib_div
::trimExplode(',', $tcaFieldConf['eval'], 1);
1221 $res = $this->checkValue_input_Eval($value, $evalCodesArray, $tcaFieldConf['is_in']);
1223 // Process UNIQUE settings:
1224 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...
1225 if ($res['value'] && in_array('uniqueInPid', $evalCodesArray)) {
1226 $res['value'] = $this->getUnique($table, $field, $res['value'], $id, $realPid);
1228 if ($res['value'] && in_array('unique', $evalCodesArray)) {
1229 $res['value'] = $this->getUnique($table, $field, $res['value'], $id);
1237 * Evaluates 'check' type values.
1239 * @param array The result array. The processed value (if any!) is set in the 'value' key.
1240 * @param string The value to set.
1241 * @param array Field configuration from TCA
1242 * @param array Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
1243 * @return array Modified $res array
1245 function checkValue_check($res, $value, $tcaFieldConf, $PP) {
1246 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
1248 $itemC = count($tcaFieldConf['items']);
1252 $maxV = pow(2, $itemC);
1257 if ($value > $maxV) {
1260 $res['value'] = $value;
1266 * Evaluates 'radio' type values.
1268 * @param array The result array. The processed value (if any!) is set in the 'value' key.
1269 * @param string The value to set.
1270 * @param array Field configuration from TCA
1271 * @param array Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
1272 * @return array Modified $res array
1274 function checkValue_radio($res, $value, $tcaFieldConf, $PP) {
1275 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
1277 if (is_array($tcaFieldConf['items'])) {
1278 foreach ($tcaFieldConf['items'] as $set) {
1279 if (!strcmp($set[1], $value)) {
1280 $res['value'] = $value;
1290 * Evaluates 'group' or 'select' type values.
1292 * @param array The result array. The processed value (if any!) is set in the 'value' key.
1293 * @param string The value to set.
1294 * @param array Field configuration from TCA
1295 * @param array Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
1296 * @param [type] $uploadedFiles: ...
1297 * @param string Field name
1298 * @return array Modified $res array
1300 function checkValue_group_select($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field) {
1302 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
1304 // Detecting if value sent is an array and if so, implode it around a comma:
1305 if (is_array($value)) {
1306 $value = implode(',', $value);
1309 // This converts all occurencies of '{' 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.
1310 // Anyways, this should NOT disturb anything else:
1311 $value = $this->convNumEntityToByteValue($value);
1313 // When values are sent as group or select they come as comma-separated values which are exploded by this function:
1314 $valueArray = $this->checkValue_group_select_explodeSelectGroupValue($value);
1316 // If not multiple is set, then remove duplicates:
1317 if (!$tcaFieldConf['multiple']) {
1318 $valueArray = array_unique($valueArray);
1321 // If an exclusive key is found, discard all others:
1322 if ($tcaFieldConf['type'] == 'select' && $tcaFieldConf['exclusiveKeys']) {
1323 $exclusiveKeys = t3lib_div
::trimExplode(',', $tcaFieldConf['exclusiveKeys']);
1324 foreach ($valueArray as $kk => $vv) {
1325 if (in_array($vv, $exclusiveKeys)) { // $vv is the item key!
1326 $valueArray = array($kk => $vv);
1332 // This could be a good spot for parsing the array through a validation-function which checks if the values are alright (except that database references are not in their final form - but that is the point, isn't it?)
1333 // NOTE!!! Must check max-items of files before the later check because that check would just leave out filenames if there are too many!!
1335 // Checking for select / authMode, removing elements from $valueArray if any of them is not allowed!
1336 if ($tcaFieldConf['type'] == 'select' && $tcaFieldConf['authMode']) {
1337 $preCount = count($valueArray);
1338 foreach ($valueArray as $kk => $vv) {
1339 if (!$this->BE_USER
->checkAuthMode($table, $field, $vv, $tcaFieldConf['authMode'])) {
1340 unset($valueArray[$kk]);
1344 // 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.
1345 if ($preCount && !count($valueArray)) {
1351 if ($tcaFieldConf['type'] == 'group') {
1352 switch ($tcaFieldConf['internal_type']) {
1353 case 'file_reference':
1355 $valueArray = $this->checkValue_group_select_file(
1367 $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, 'group', $table, $field);
1371 // For select types which has a foreign table attached:
1372 if ($tcaFieldConf['type'] == 'select' && $tcaFieldConf['foreign_table']) {
1373 // check, if there is a NEW... id in the value, that should be substituded later
1374 if (strpos($value, 'NEW') !== FALSE) {
1375 $this->remapStackRecords
[$table][$id] = array('remapStackIndex' => count($this->remapStack
));
1376 $this->addNewValuesToRemapStackChildIds($valueArray);
1377 $this->remapStack
[] = array(
1378 'func' => 'checkValue_group_select_processDBdata',
1379 'args' => array($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field),
1380 'pos' => array('valueArray' => 0, 'tcaFieldConf' => 1, 'id' => 2, 'table' => 5),
1383 $unsetResult = TRUE;
1385 $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field);
1389 if (!$unsetResult) {
1390 $newVal = $this->checkValue_checkMax($tcaFieldConf, $valueArray);
1391 $res['value'] = implode(',', $newVal);
1393 unset($res['value']);
1400 * Handling files for group/select function
1402 * @param array Array of incoming file references. Keys are numeric, values are files (basically, this is the exploded list of incoming files)
1403 * @param array Configuration array from TCA of the field
1404 * @param string Current value of the field
1405 * @param array Array of uploaded files, if any
1406 * @param string Status ("update" or ?)
1407 * @param string tablename of record
1408 * @param integer UID of record
1409 * @param string Field identifier ([table:uid:field:....more for flexforms?]
1410 * @return array Modified value array
1411 * @see checkValue_group_select()
1413 function checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue, $uploadedFileArray, $status, $table, $id, $recFID) {
1415 if (!$this->bypassFileHandling
) { // If filehandling should NOT be bypassed, do processing:
1417 // If any files are uploaded, add them to value array
1418 if (is_array($uploadedFileArray) &&
1419 $uploadedFileArray['name'] &&
1420 strcmp($uploadedFileArray['tmp_name'], 'none')) {
1421 $valueArray[] = $uploadedFileArray['tmp_name'];
1422 $this->alternativeFileName
[$uploadedFileArray['tmp_name']] = $uploadedFileArray['name'];
1425 // Creating fileFunc object.
1426 if (!$this->fileFunc
) {
1427 $this->fileFunc
= t3lib_div
::makeInstance('t3lib_basicFileFunctions');
1428 $this->include_filefunctions
= 1;
1430 // Setting permitted extensions.
1431 $all_files = array();
1432 $all_files['webspace']['allow'] = $tcaFieldConf['allowed'];
1433 $all_files['webspace']['deny'] = $tcaFieldConf['disallowed'] ?
$tcaFieldConf['disallowed'] : '*';
1434 $all_files['ftpspace'] = $all_files['webspace'];
1435 $this->fileFunc
->init('', $all_files);
1438 // If there is an upload folder defined:
1439 if ($tcaFieldConf['uploadfolder'] && $tcaFieldConf['internal_type'] == 'file') {
1440 if (!$this->bypassFileHandling
) { // If filehandling should NOT be bypassed, do processing:
1442 $propArr = $this->getRecordProperties($table, $id);
1444 // Get destrination path:
1445 $dest = $this->destPathFromUploadFolder($tcaFieldConf['uploadfolder']);
1447 // If we are updating:
1448 if ($status == 'update') {
1450 // Traverse the input values and convert to absolute filenames in case the update happens to an autoVersionized record.
1451 // Background: This is a horrible workaround! The problem is that when a record is auto-versionized the files of the record get copied and therefore get new names which is overridden with the names from the original record in the incoming data meaning both lost files and double-references!
1452 // The only solution I could come up with (except removing support for managing files when autoversioning) was to convert all relative files to absolute names so they are copied again (and existing files deleted). This should keep references intact but means that some files are copied, then deleted after being copied _again_.
1453 // Actually, the same problem applies to database references in case auto-versioning would include sub-records since in such a case references are remapped - and they would be overridden due to the same principle then.
1454 // Illustration of the problem comes here:
1455 // We have a record 123 with a file logo.gif. We open and edit the files header in a workspace. So a new version is automatically made.
1456 // The versions uid is 456 and the file is copied to "logo_01.gif". But the form data that we sent was based on uid 123 and hence contains the filename "logo.gif" from the original.
1457 // The file management code below will do two things: First it will blindly accept "logo.gif" as a file attached to the record (thus creating a double reference) and secondly it will find that "logo_01.gif" was not in the incoming filelist and therefore should be deleted.
1458 // If we prefix the incoming file "logo.gif" with its absolute path it will be seen as a new file added. Thus it will be copied to "logo_02.gif". "logo_01.gif" will still be deleted but since the files are the same the difference is zero - only more processing and file copying for no reason. But it will work.
1459 if ($this->autoVersioningUpdate
=== TRUE) {
1460 foreach ($valueArray as $key => $theFile) {
1461 if ($theFile === basename($theFile)) { // If it is an already attached file...
1462 $valueArray[$key] = PATH_site
. $tcaFieldConf['uploadfolder'] . '/' . $theFile;
1467 // Finding the CURRENT files listed, either from MM or from the current record.
1468 $theFileValues = array();
1469 if ($tcaFieldConf['MM']) { // If MM relations for the files also!
1470 $dbAnalysis = t3lib_div
::makeInstance('t3lib_loadDBGroup');
1471 /* @var $dbAnalysis t3lib_loadDBGroup */
1472 $dbAnalysis->start('', 'files', $tcaFieldConf['MM'], $id);
1473 foreach ($dbAnalysis->itemArray
as $item) {
1475 $theFileValues[] = $item['id'];
1479 $theFileValues = t3lib_div
::trimExplode(',', $curValue, 1);
1481 $currentFilesForHistory = implode(',', $theFileValues);
1483 // DELETE files: If existing files were found, traverse those and register files for deletion which has been removed:
1484 if (count($theFileValues)) {
1485 // 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!)
1486 foreach ($valueArray as $key => $theFile) {
1487 if ($theFile && !strstr(t3lib_div
::fixWindowsFilePath($theFile), '/')) {
1488 $theFileValues = t3lib_div
::removeArrayEntryByValue($theFileValues, $theFile);
1492 // This array contains the filenames in the uploadfolder that should be deleted:
1493 foreach ($theFileValues as $key => $theFile) {
1494 $theFile = trim($theFile);
1495 if (@is_file
($dest . '/' . $theFile)) {
1496 $this->removeFilesStore
[] = $dest . '/' . $theFile;
1497 } elseif ($theFile) {
1498 $this->log($table, $id, 5, 0, 1, "Could not delete file '%s' (does not exist). (%s)", 10, array($dest . '/' . $theFile, $recFID), $propArr['event_pid']);
1504 // Traverse the submitted values:
1505 foreach ($valueArray as $key => $theFile) {
1506 // 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)
1507 if (strstr(t3lib_div
::fixWindowsFilePath($theFile), '/')) {
1509 $maxSize = intval($tcaFieldConf['max_size']);
1511 $theDestFile = ''; // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
1513 // Check various things before copying file:
1514 if (@is_dir
($dest) && (@is_file
($theFile) || @is_uploaded_file
($theFile))) { // File and destination must exist
1517 if (is_uploaded_file($theFile) && $theFile == $uploadedFileArray['tmp_name']) {
1518 $fileSize = $uploadedFileArray['size'];
1520 $fileSize = filesize($theFile);
1523 if (!$maxSize ||
$fileSize <= ($maxSize * 1024)) { // Check file size:
1524 // Prepare filename:
1525 $theEndFileName = isset($this->alternativeFileName
[$theFile]) ?
$this->alternativeFileName
[$theFile] : $theFile;
1526 $fI = t3lib_div
::split_fileref($theEndFileName);
1528 // Check for allowed extension:
1529 if ($this->fileFunc
->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
1530 $theDestFile = $this->fileFunc
->getUniqueName($this->fileFunc
->cleanFileName($fI['file']), $dest);
1532 // If we have a unique destination filename, then write the file:
1534 t3lib_div
::upload_copy_move($theFile, $theDestFile);
1536 // Hook for post-processing the upload action
1537 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'])) {
1538 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'] as $classRef) {
1539 $hookObject = t3lib_div
::getUserObj($classRef);
1541 if (!($hookObject instanceof t3lib_TCEmain_processUploadHook
)) {
1542 throw new UnexpectedValueException('$hookObject must implement interface t3lib_TCEmain_processUploadHook', 1279962349);
1545 $hookObject->processUpload_postProcessAction($theDestFile, $this);
1549 $this->copiedFileMap
[$theFile] = $theDestFile;
1551 if (!@is_file
($theDestFile)) {
1552 $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']);
1555 $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']);
1558 $this->log($table, $id, 5, 0, 1, "File extension '%s' not allowed. (%s)", 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
1561 $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']);
1564 $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']);
1567 // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
1568 if (@is_file
($theDestFile)) {
1569 $info = t3lib_div
::split_fileref($theDestFile);
1570 $valueArray[$key] = $info['file']; // The value is set to the new filename
1572 unset($valueArray[$key]); // The value is set to the new filename
1578 // 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!
1579 if ($tcaFieldConf['MM']) {
1580 $dbAnalysis = t3lib_div
::makeInstance('t3lib_loadDBGroup');
1581 /* @var $dbAnalysis t3lib_loadDBGroup */
1582 $dbAnalysis->tableArray
['files'] = array(); // dummy
1584 foreach ($valueArray as $key => $theFile) {
1586 $dbAnalysis->itemArray
[]['id'] = $theFile;
1588 if ($status == 'update') {
1589 $dbAnalysis->writeMM($tcaFieldConf['MM'], $id, 0);
1590 $newFiles = implode(',', $dbAnalysis->getValueArray());
1591 list(, , $recFieldName) = explode(':', $recFID);
1592 if ($currentFilesForHistory != $newFiles) {
1593 $this->mmHistoryRecords
[$table . ':' . $id]['oldRecord'][$recFieldName] = $currentFilesForHistory;
1594 $this->mmHistoryRecords
[$table . ':' . $id]['newRecord'][$recFieldName] = $newFiles;
1596 $this->mmHistoryRecords
[$table . ':' . $id]['oldRecord'][$recFieldName] = '';
1597 $this->mmHistoryRecords
[$table . ':' . $id]['newRecord'][$recFieldName] = '';
1600 $this->dbAnalysisStore
[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, 0); // This will be traversed later to execute the actions
1602 $valueArray = $dbAnalysis->countItems();
1604 //store path relative to site root (if uploadfolder is not set or internal_type is file_reference)
1606 if (count($valueArray)) {
1607 if (!$this->bypassFileHandling
) { // If filehandling should NOT be bypassed, do processing:
1608 $propArr = $this->getRecordProperties($table, $id); // For logging..
1609 foreach ($valueArray as &$theFile) {
1611 // if alernative File Path is set for the file, then it was an import
1612 if ($this->alternativeFilePath
[$theFile]) {
1614 // don't import the file if it already exists
1615 if (@is_file
(PATH_site
. $this->alternativeFilePath
[$theFile])) {
1616 $theFile = PATH_site
. $this->alternativeFilePath
[$theFile];
1619 } elseif (@is_file
($theFile)) {
1620 $dest = dirname(PATH_site
. $this->alternativeFilePath
[$theFile]);
1621 if (!@is_dir
($dest)) {
1622 t3lib_div
::mkdir_deep(PATH_site
, dirname($this->alternativeFilePath
[$theFile]) . '/');
1626 $maxSize = intval($tcaFieldConf['max_size']);
1628 $theDestFile = ''; // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
1629 $fileSize = filesize($theFile);
1631 if (!$maxSize ||
$fileSize <= ($maxSize * 1024)) { // Check file size:
1632 // Prepare filename:
1633 $theEndFileName = isset($this->alternativeFileName
[$theFile]) ?
$this->alternativeFileName
[$theFile] : $theFile;
1634 $fI = t3lib_div
::split_fileref($theEndFileName);
1636 // Check for allowed extension:
1637 if ($this->fileFunc
->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
1638 $theDestFile = PATH_site
. $this->alternativeFilePath
[$theFile];
1642 t3lib_div
::upload_copy_move($theFile, $theDestFile);
1643 $this->copiedFileMap
[$theFile] = $theDestFile;
1645 if (!@is_file
($theDestFile)) {
1646 $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']);
1649 $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']);
1652 $this->log($table, $id, 5, 0, 1, "File extension '%s' not allowed. (%s)", 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
1655 $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']);
1658 // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
1659 if (@is_file
($theDestFile)) {
1660 $theFile = $theDestFile; // The value is set to the new filename
1662 unset($theFile); // The value is set to the new filename
1666 $theFile = t3lib_div
::fixWindowsFilePath($theFile);
1667 if (t3lib_div
::isFirstPartOfStr($theFile, PATH_site
)) {
1668 $theFile = substr($theFile, strlen(PATH_site
));
1680 * Evaluates 'flex' type values.
1682 * @param array The result array. The processed value (if any!) is set in the 'value' key.
1683 * @param string The value to set.
1684 * @param array Field configuration from TCA
1685 * @param array Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
1686 * @param array Uploaded files for the field
1687 * @param array Current record array.
1688 * @param string Field name
1689 * @return array Modified $res array
1691 function checkValue_flex($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field) {
1692 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
1694 if (is_array($value)) {
1696 // This value is necessary for flex form processing to happen on flexform fields in page records when they are copied.
1697 // The problem is, that when copying a page, flexfrom XML comes along in the array for the new record - but since $this->checkValue_currentRecord does not have a uid or pid for that sake, the t3lib_BEfunc::getFlexFormDS() function returns no good DS. For new records we do know the expected PID so therefore we send that with this special parameter. Only active when larger than zero.
1698 $newRecordPidValue = $status == 'new' ?
$realPid : 0;
1700 // Get current value array:
1701 $dataStructArray = t3lib_BEfunc
::getFlexFormDS($tcaFieldConf, $this->checkValue_currentRecord
, $table, '', TRUE, $newRecordPidValue);
1703 $currentValueArray = t3lib_div
::xml2array($curValue);
1704 if (!is_array($currentValueArray)) {
1705 $currentValueArray = array();
1707 if (is_array($currentValueArray['meta']['currentLangId'])) {
1708 unset($currentValueArray['meta']['currentLangId']);
1709 } // Remove all old meta for languages...
1711 // Evaluation of input values:
1712 $value['data'] = $this->checkValue_flex_procInData($value['data'], $currentValueArray['data'], $uploadedFiles['data'], $dataStructArray, $PP);
1714 // Create XML and convert charsets from input value:
1715 $xmlValue = $this->checkValue_flexArray2Xml($value, TRUE);
1717 // If we wanted to set UTF fixed:
1718 // $storeInCharset='utf-8';
1719 // $currentCharset=$GLOBALS['LANG']->charSet;
1720 // $xmlValue = $GLOBALS['LANG']->csConvObj->conv($xmlValue,$currentCharset,$storeInCharset,1);
1721 $storeInCharset = $GLOBALS['LANG']->charSet
;
1723 // Merge them together IF they are both arrays:
1724 // 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).
1725 if (is_array($currentValueArray)) {
1726 $arrValue = t3lib_div
::xml2array($xmlValue);
1727 $arrValue = t3lib_div
::array_merge_recursive_overrule($currentValueArray, $arrValue);
1728 $xmlValue = $this->checkValue_flexArray2Xml($arrValue, TRUE);
1731 // Action commands (sorting order and removals of elements)
1732 $actionCMDs = t3lib_div
::_GP('_ACTION_FLEX_FORMdata');
1733 if (is_array($actionCMDs[$table][$id][$field]['data'])) {
1734 $arrValue = t3lib_div
::xml2array($xmlValue);
1735 $this->_ACTION_FLEX_FORMdata($arrValue['data'], $actionCMDs[$table][$id][$field]['data']);
1736 $xmlValue = $this->checkValue_flexArray2Xml($arrValue, TRUE);
1739 // Create the value XML:
1741 $res['value'] .= $xmlValue;
1742 } else { // Passthrough...:
1743 $res['value'] = $value;
1750 * Converts an array to FlexForm XML
1752 * @param array Array with FlexForm data
1753 * @param boolean If set, the XML prologue is returned as well.
1754 * @return string Input array converted to XML
1756 function checkValue_flexArray2Xml($array, $addPrologue = FALSE) {
1757 $flexObj = t3lib_div
::makeInstance('t3lib_flexformtools');
1758 /* @var $flexObj t3lib_flexformtools */
1759 return $flexObj->flexArray2Xml($array, $addPrologue);
1763 * Actions for flex form element (move, delete)
1765 * @param array &$valueArrayToRemoveFrom: by reference
1766 * @param array $deleteCMDS: ... *
1769 function _ACTION_FLEX_FORMdata(&$valueArray, $actionCMDs) {
1770 if (is_array($valueArray) && is_array($actionCMDs)) {
1771 foreach ($actionCMDs as $key => $value) {
1772 if ($key == '_ACTION') {
1773 // First, check if there are "commands":
1774 if (current($actionCMDs[$key]) !== "") {
1775 asort($actionCMDs[$key]);
1776 $newValueArray = array();
1777 foreach ($actionCMDs[$key] as $idx => $order) {
1778 if (substr($idx, 0, 3) == "ID-") {
1779 $idx = $this->newIndexMap
[$idx];
1781 if ($order != "DELETE") { // Just one reflection here: It is clear that when removing elements from a flexform, then we will get lost files unless we act on this delete operation by traversing and deleting files that were referred to.
1782 $newValueArray[$idx] = $valueArray[$idx];
1784 unset($valueArray[$idx]);
1786 $valueArray = t3lib_div
::array_merge($newValueArray, $valueArray);
1788 } elseif (is_array($actionCMDs[$key]) && isset($valueArray[$key])) {
1789 $this->_ACTION_FLEX_FORMdata($valueArray[$key], $actionCMDs[$key]);
1796 * Evaluates 'inline' type values.
1797 * (partly copied from the select_group function on this issue)
1799 * @param array The result array. The processed value (if any!) is set in the 'value' key.
1800 * @param string The value to set.
1801 * @param array Field configuration from TCA
1802 * @param array Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
1803 * @param string Field name
1804 * @return array Modified $res array
1806 function checkValue_inline($res, $value, $tcaFieldConf, $PP, $field) {
1807 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
1809 if (!$tcaFieldConf['foreign_table']) {
1810 return FALSE; // Fatal error, inline fields should always have a foreign_table defined
1813 // When values are sent they come as comma-separated values which are exploded by this function:
1814 $valueArray = t3lib_div
::trimExplode(',', $value);
1816 // Remove duplicates: (should not be needed)
1817 $valueArray = array_unique($valueArray);
1819 // Example for received data:
1820 // $value = 45,NEW4555fdf59d154,12,123
1821 // We need to decide whether we use the stack or can save the relation directly.
1822 if (strpos($value, 'NEW') !== FALSE ||
!t3lib_utility_Math
::canBeInterpretedAsInteger($id)) {
1823 $this->remapStackRecords
[$table][$id] = array('remapStackIndex' => count($this->remapStack
));
1824 $this->addNewValuesToRemapStackChildIds($valueArray);
1825 $this->remapStack
[] = array(
1826 'func' => 'checkValue_inline_processDBdata',
1827 'args' => array($valueArray, $tcaFieldConf, $id, $status, $table, $field),
1828 'pos' => array('valueArray' => 0, 'tcaFieldConf' => 1, 'id' => 2, 'table' => 4),
1831 unset($res['value']);
1832 } elseif ($value || t3lib_utility_Math
::canBeInterpretedAsInteger($id)) {
1833 $res['value'] = $this->checkValue_inline_processDBdata($valueArray, $tcaFieldConf, $id, $status, $table, $field);
1840 * Checks if a fields has more items than defined via TCA in maxitems.
1841 * If there are more items than allowd, the item list is truncated to the defined number.
1843 * @param array $tcaFieldConf: Field configuration from TCA
1844 * @param array $valueArray: Current value array of items
1845 * @return array The truncated value array of items
1847 function checkValue_checkMax($tcaFieldConf, $valueArray) {
1848 // 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...
1850 $valueArrayC = count($valueArray);
1852 // 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.
1853 $maxI = isset($tcaFieldConf['maxitems']) ?
intval($tcaFieldConf['maxitems']) : 1;
1854 if ($valueArrayC > $maxI) {
1855 $valueArrayC = $maxI;
1856 } // Checking for not too many elements
1858 // Dumping array to list
1860 foreach ($valueArray as $nextVal) {
1861 if ($valueArrayC == 0) {
1865 $newVal[] = $nextVal;
1872 /*********************************************
1874 * Helper functions for evaluation functions.
1876 ********************************************/
1879 * Gets a unique value for $table/$id/$field based on $value
1881 * @param string Table name
1882 * @param string Field name for which $value must be unique
1883 * @param string Value string.
1884 * @param integer UID to filter out in the lookup (the record itself...)
1885 * @param integer If set, the value will be unique for this PID
1886 * @return string Modified value (if not-unique). Will be the value appended with a number (until 100, then the function just breaks).
1888 function getUnique($table, $field, $value, $id, $newPid = 0) {
1891 t3lib_div
::loadTCA($table);
1894 if (intval($newPid)) {
1895 $whereAdd .= ' AND pid=' . intval($newPid);
1897 $whereAdd .= ' AND pid>=0';
1898 } // "AND pid>=0" for versioning
1899 $whereAdd .= $this->deleteClause($table);
1901 // If the field is configured in TCA, proceed:
1902 if (is_array($GLOBALS['TCA'][$table]) && is_array($GLOBALS['TCA'][$table]['columns'][$field])) {
1904 // Look for a record which might already have the value:
1905 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, $field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $table) . ' AND uid!=' . intval($id) . $whereAdd);
1908 // For as long as records with the test-value existing, try again (with incremented numbers appended).
1909 while ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
1910 $newValue = $value . $counter;
1911 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, $field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($newValue, $table) . ' AND uid!=' . intval($id) . $whereAdd);
1913 if ($counter > 100) {
1915 } // At "100" it will give up and accept a duplicate - should probably be fixed to a small hash string instead...!
1917 // If the new value is there:
1918 $value = strlen($newValue) ?
$newValue : $value;
1923 function checkValue_text_Eval($value, $evalArray, $is_in) {
1928 foreach ($evalArray as $func) {
1931 $value = trim($value);
1939 if (t3lib_div
::hasValidClassPrefix($func)) {
1940 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
1941 if (is_object($evalObj) && method_exists($evalObj, 'evaluateFieldValue')) {
1942 $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
1949 $res['value'] = $value;
1955 * Evaluation of 'input'-type values based on 'eval' list
1957 * @param string Value to evaluate
1958 * @param array Array of evaluations to traverse.
1959 * @param string Is-in string for 'is_in' evaluation
1960 * @return array Modified $value in key 'value' or empty array
1962 function checkValue_input_Eval($value, $evalArray, $is_in) {
1967 foreach ($evalArray as $func) {
1973 $value = intval($value);
1977 $value = intval($value);
1978 if ($value > 0 && !$this->dontProcessTransformations
) {
1979 $value -= date('Z', $value);
1983 $value = preg_replace('/[^0-9,\.-]/', '', $value);
1984 $negative = substr($value, 0, 1) == '-';
1985 $value = strtr($value, array(',' => '.', '-' => ''));
1986 if (strpos($value, '.') === FALSE) {
1989 $valueArray = explode('.', $value);
1990 $dec = array_pop($valueArray);
1991 $value = join('', $valueArray) . '.' . $dec;
1995 $value = number_format($value, 2, '.', '');
1998 if (strlen($value) != 32) {
2003 $value = trim($value);
2006 $value = $GLOBALS['LANG']->csConvObj
->conv_case($GLOBALS['LANG']->charSet
, $value, 'toUpper');
2009 $value = $GLOBALS['LANG']->csConvObj
->conv_case($GLOBALS['LANG']->charSet
, $value, 'toLower');
2012 if (!isset($value) ||
$value === '') {
2017 $c = strlen($value);
2020 for ($a = 0; $a < $c; $a++
) {
2021 $char = substr($value, $a, 1);
2022 if (strpos($is_in, $char) !== FALSE) {
2030 $value = str_replace(' ', '', $value);
2033 $value = preg_replace('/[^a-zA-Z]/', '', $value);
2036 $value = preg_replace('/[^0-9]/', '', $value);
2039 $value = preg_replace('/[^a-zA-Z0-9]/', '', $value);
2042 $value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value);
2045 if (!preg_match('/^[a-z0-9\.\-]*$/i', $value)) {
2046 t3lib_div
::requireOnce(PATH_typo3
. 'contrib/idna/idna_convert.class.php');
2047 $idnaConvert = new idna_convert();
2048 $idnaConvert->set_parameter('idn_version', '2008');
2049 $value = $idnaConvert->encode($value);
2050 unset($idnaConvert);
2054 if (t3lib_div
::hasValidClassPrefix($func)) {
2055 $evalObj = t3lib_div
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
2056 if (is_object($evalObj) && method_exists($evalObj, 'evaluateFieldValue')) {
2057 $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
2064 $res['value'] = $value;
2070 * Returns data for group/db and select fields
2072 * @param array Current value array
2073 * @param array TCA field config
2074 * @param integer Record id, used for look-up of MM relations (local_uid)
2075 * @param string Status string ('update' or 'new')
2076 * @param string The type, either 'select', 'group' or 'inline'
2077 * @param string Table name, needs to be passed to t3lib_loadDBGroup
2078 * @param string field name, needs to be set for writing to sys_history
2079 * @return array Modified value array
2081 function checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, $type, $currentTable, $currentField) {
2082 $tables = $type == 'group' ?
$tcaFieldConf['allowed'] : $tcaFieldConf['foreign_table'] . ',' . $tcaFieldConf['neg_foreign_table'];
2083 $prep = $type == 'group' ?
$tcaFieldConf['prepend_tname'] : $tcaFieldConf['neg_foreign_table'];
2084 $newRelations = implode(',', $valueArray);
2086 $dbAnalysis = t3lib_div
::makeInstance('t3lib_loadDBGroup');
2087 /* @var $dbAnalysis t3lib_loadDBGroup */
2088 $dbAnalysis->registerNonTableValues
= $tcaFieldConf['allowNonIdValues'] ?
1 : 0;
2089 $dbAnalysis->start($newRelations, $tables, '', 0, $currentTable, $tcaFieldConf);
2091 if ($tcaFieldConf['MM']) {
2092 if ($status == 'update') {
2093 $oldRelations_dbAnalysis = t3lib_div
::makeInstance('t3lib_loadDBGroup');
2094 /* @var $oldRelations_dbAnalysis t3lib_loadDBGroup */
2095 $oldRelations_dbAnalysis->registerNonTableValues
= $tcaFieldConf['allowNonIdValues'] ?
1 : 0;
2096 // db analysis with $id will initialize with the existing relations
2097 $oldRelations_dbAnalysis->start('', $tables, $tcaFieldConf['MM'], $id, $currentTable, $tcaFieldConf);
2098 $oldRelations = implode(',', $oldRelations_dbAnalysis->getValueArray());
2099 $dbAnalysis->writeMM($tcaFieldConf['MM'], $id, $prep);
2100 if ($oldRelations != $newRelations) {
2101 $this->mmHistoryRecords
[$currentTable . ':' . $id]['oldRecord'][$currentField] = $oldRelations;
2102 $this->mmHistoryRecords
[$currentTable . ':' . $id]['newRecord'][$currentField] = $newRelations;
2104 $this->mmHistoryRecords
[$currentTable . ':' . $id]['oldRecord'][$currentField] = '';
2105 $this->mmHistoryRecords
[$currentTable . ':' . $id]['newRecord'][$currentField] = '';
2108 $this->dbAnalysisStore
[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, $prep, $currentTable); // This will be traversed later to execute the actions
2110 $valueArray = $dbAnalysis->countItems();
2112 $valueArray = $dbAnalysis->getValueArray($prep);
2113 if ($type == 'select' && $prep) {
2114 $valueArray = $dbAnalysis->convertPosNeg($valueArray, $tcaFieldConf['foreign_table'], $tcaFieldConf['neg_foreign_table']);
2118 // Here we should see if 1) the records exist anymore, 2) which are new and check if the BE_USER has read-access to the new ones.
2123 * Explodes the $value, which is a list of files/uids (group select)
2125 * @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.
2126 * @return array The value array.
2128 function checkValue_group_select_explodeSelectGroupValue($value) {
2129 $valueArray = t3lib_div
::trimExplode(',', $value, 1);
2130 foreach ($valueArray as &$newVal) {
2131 $temp = explode('|', $newVal, 2);
2132 $newVal = str_replace(
2135 str_replace('|', '', rawurldecode($temp[0]))
2143 * Starts the processing the input data for flexforms. This will traverse all sheets / languages and for each it will traverse the sub-structure.
2144 * See checkValue_flex_procInData_travDS() for more details.
2145 * WARNING: Currently, it traverses based on the actual _data_ array and NOT the _structure_. This means that values for non-valid fields, lKey/vKey/sKeys will be accepted! For traversal of data with a call back function you should rather use class.t3lib_flexformtools.php
2147 * @param array The 'data' part of the INPUT flexform data
2148 * @param array The 'data' part of the CURRENT flexform data
2149 * @param array The uploaded files for the 'data' part of the INPUT flexform data
2150 * @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.
2151 * @param array A set of parameters to pass through for the calling of the evaluation functions
2152 * @param string Optional call back function, see checkValue_flex_procInData_travDS() DEPRICATED, use class.t3lib_flexformtools.php instead for traversal!
2153 * @return array The modified 'data' part.
2154 * @see checkValue_flex_procInData_travDS()
2156 function checkValue_flex_procInData($dataPart, $dataPart_current, $uploadedFiles, $dataStructArray, $pParams, $callBackFunc = '') {
2157 if (is_array($dataPart)) {
2158 foreach ($dataPart as $sKey => $sheetDef) {
2159 list ($dataStruct, $actualSheet) = t3lib_div
::resolveSheetDefInDS($dataStructArray, $sKey);
2160 if (is_array($dataStruct) && $actualSheet == $sKey && is_array($sheetDef)) {
2161 foreach ($sheetDef as $lKey => $lData) {
2162 $this->checkValue_flex_procInData_travDS(
2163 $dataPart[$sKey][$lKey],
2164 $dataPart_current[$sKey][$lKey],
2165 $uploadedFiles[$sKey][$lKey],
2166 $dataStruct['ROOT']['el'],
2169 $sKey . '/' . $lKey . '/'
2180 * Processing of the sheet/language data array
2181 * 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.
2183 * @param array New values (those being processed): Multidimensional Data array for sheet/language, passed by reference!
2184 * @param array Current values: Multidimensional Data array. May be empty array() if not needed (for callBackFunctions)
2185 * @param array Uploaded files array for sheet/language. May be empty array() if not needed (for callBackFunctions)
2186 * @param array Data structure which fits the data array
2187 * @param array A set of parameters to pass through for the calling of the evaluation functions / call back function
2188 * @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.
2189 * @param [type] $structurePath: ...
2191 * @see checkValue_flex_procInData()
2193 function checkValue_flex_procInData_travDS(&$dataValues, $dataValues_current, $uploadedFiles, $DSelements, $pParams, $callBackFunc, $structurePath) {
2194 if (is_array($DSelements)) {
2196 // For each DS element:
2197 foreach ($DSelements as $key => $dsConf) {
2200 if ($DSelements[$key]['type'] == 'array') {
2201 if (is_array($dataValues[$key]['el'])) {
2202 if ($DSelements[$key]['section']) {
2203 $newIndexCounter = 0;
2204 foreach ($dataValues[$key]['el'] as $ik => $el) {
2205 if (is_array($el)) {
2206 if (!is_array($dataValues_current[$key]['el'])) {
2207 $dataValues_current[$key]['el'] = array();
2212 if (is_array($dataValues[$key]['el'][$ik][$theKey]['el'])) {
2213 $this->checkValue_flex_procInData_travDS(
2214 $dataValues[$key]['el'][$ik][$theKey]['el'],
2215 is_array($dataValues_current[$key]['el'][$ik]) ?
$dataValues_current[$key]['el'][$ik][$theKey]['el'] : array(),
2216 $uploadedFiles[$key]['el'][$ik][$theKey]['el'],
2217 $DSelements[$key]['el'][$theKey]['el'],
2220 $structurePath . $key . '/el/' . $ik . '/' . $theKey . '/el/'
2223 // If element is added dynamically in the flexform of TCEforms, we map the ID-string to the next numerical index we can have in that particular section of elements:
2224 // The fact that the order changes is not important since order is controlled by a separately submitted index.
2226 if (substr($ik, 0, 3) == "ID-") {
2228 $this->newIndexMap
[$ik] = (is_array($dataValues_current[$key]['el']) && count($dataValues_current[$key]['el']) ?
max(array_keys($dataValues_current[$key]['el'])) : 0) +
$newIndexCounter; // Set mapping index
2229 $dataValues[$key]['el'][$this->newIndexMap
[$ik]] = $dataValues[$key]['el'][$ik]; // Transfer values
2230 unset($dataValues[$key]['el'][$ik]); // Unset original
2236 if (!isset($dataValues[$key]['el'])) {
2237 $dataValues[$key]['el'] = array();
2239 $this->checkValue_flex_procInData_travDS(
2240 $dataValues[$key]['el'],
2241 $dataValues_current[$key]['el'],
2242 $uploadedFiles[$key]['el'],
2243 $DSelements[$key]['el'],
2246 $structurePath . $key . '/el/'
2251 if (is_array($dsConf['TCEforms']['config']) && is_array($dataValues[$key])) {
2252 foreach ($dataValues[$key] as $vKey => $data) {
2254 if ($callBackFunc) {
2255 if (is_object($this->callBackObj
)) {
2256 $res = $this->callBackObj
->$callBackFunc(
2258 $dsConf['TCEforms']['config'],
2259 $dataValues[$key][$vKey],
2260 $dataValues_current[$key][$vKey],
2261 $uploadedFiles[$key][$vKey],
2262 $structurePath . $key . '/' . $vKey . '/'
2265 $res = $this->$callBackFunc(
2267 $dsConf['TCEforms']['config'],
2268 $dataValues[$key][$vKey],
2269 $dataValues_current[$key][$vKey],
2270 $uploadedFiles[$key][$vKey],
2271 $structurePath . $key . '/' . $vKey . '/'
2275 list($CVtable, $CVid, $CVcurValue, $CVstatus, $CVrealPid, $CVrecFID, $CVtscPID) = $pParams;
2277 $res = $this->checkValue_SW(
2279 $dataValues[$key][$vKey],
2280 $dsConf['TCEforms']['config'],
2283 $dataValues_current[$key][$vKey],
2288 $uploadedFiles[$key][$vKey],
2293 // Look for RTE transformation of field:
2294 if ($dataValues[$key]['_TRANSFORM_' . $vKey] == 'RTE' && !$this->dontProcessTransformations
) {
2296 // Unsetting trigger field - we absolutely don't want that into the data storage!
2297 unset($dataValues[$key]['_TRANSFORM_' . $vKey]);
2299 if (isset($res['value'])) {
2301 // Calculating/Retrieving some values here:
2302 list(, , $recFieldName) = explode(':', $CVrecFID);
2303 $theTypeString = t3lib_BEfunc
::getTCAtypeValue($CVtable, $this->checkValue_currentRecord
);
2304 $specConf = t3lib_BEfunc
::getSpecConfParts('', $dsConf['TCEforms']['defaultExtras']);
2306 // Find, thisConfig:
2307 $RTEsetup = $this->BE_USER
->getTSConfig('RTE', t3lib_BEfunc
::getPagesTSconfig($CVtscPID));
2308 $thisConfig = t3lib_BEfunc
::RTEsetup($RTEsetup['properties'], $CVtable, $recFieldName, $theTypeString);
2310 // Get RTE object, draw form and set flag:
2311 $RTEobj = t3lib_BEfunc
::RTEgetObj();
2312 if (is_object($RTEobj)) {
2313 $res['value'] = $RTEobj->transformContent('db', $res['value'], $CVtable, $recFieldName, $this->checkValue_currentRecord
, $specConf, $thisConfig, '', $CVrealPid);
2315 debug('NO RTE OBJECT FOUND!');
2321 // Adding the value:
2322 if (isset($res['value'])) {
2323 $dataValues[$key][$vKey] = $res['value'];
2326 // Finally, check if new and old values are different (or no .vDEFbase value is found) and if so, we record the vDEF value for diff'ing.
2327 // We do this after $dataValues has been updated since I expect that $dataValues_current holds evaluated values from database (so this must be the right value to compare with).
2328 if (substr($vKey, -9) != '.vDEFbase') {
2329 if ($this->clear_flexFormData_vDEFbase
) {
2330 $dataValues[$key][$vKey . '.vDEFbase'] = '';
2331 } elseif ($this->updateModeL10NdiffData
&& $GLOBALS['TYPO3_CONF_VARS']['BE']['flexFormXMLincludeDiffBase'] && $vKey !== 'vDEF' && (strcmp($dataValues[$key][$vKey], $dataValues_current[$key][$vKey]) ||
!isset($dataValues_current[$key][$vKey . '.vDEFbase']) ||
$this->updateModeL10NdiffData
=== 'FORCE_FFUPD')) {
2332 // Now, check if a vDEF value is submitted in the input data, if so we expect this has been processed prior to this operation (normally the case since those fields are higher in the form) and we can use that:
2333 if (isset($dataValues[$key]['vDEF'])) {
2334 $diffValue = $dataValues[$key]['vDEF'];
2335 } else { // If not found (for translators with no access to the default language) we use the one from the current-value data set:
2336 $diffValue = $dataValues_current[$key]['vDEF'];
2338 // Setting the reference value for vDEF for this translation. This will be used for translation tools to make a diff between the vDEF and vDEFbase to see if an update would be fitting.
2339 $dataValues[$key][$vKey . '.vDEFbase'] = $this->updateModeL10NdiffDataClear ?
'' : $diffValue;
2350 * Returns data for inline fields.
2352 * @param array Current value array
2353 * @param array TCA field config
2354 * @param integer Record id
2355 * @param string Status string ('update' or 'new')
2356 * @param string Table name, needs to be passed to t3lib_loadDBGroup
2357 * @param string The current field the values are modified for
2358 * @return string Modified values
2360 protected function checkValue_inline_processDBdata($valueArray, $tcaFieldConf, $id, $status, $table, $field) {
2362 $foreignTable = $tcaFieldConf['foreign_table'];
2365 * Fetch the related child records by using t3lib_loadDBGroup:
2366 * @var $dbAnalysis t3lib_loadDBGroup
2368 $dbAnalysis = t3lib_div
::makeInstance('t3lib_loadDBGroup');
2369 $dbAnalysis->start(implode(',', $valueArray), $foreignTable, '', 0, $table, $tcaFieldConf);
2370 // If the localizationMode is set to 'keep', the children for the localized parent are kept as in the original untranslated record:
2371 $localizationMode = t3lib_BEfunc
::getInlineLocalizationMode($table, $tcaFieldConf);
2372 if ($localizationMode == 'keep' && $status == 'update') {
2373 // Fetch the current record and determine the original record:
2374 $row = t3lib_BEfunc
::getRecordWSOL($table, $id);
2375 if (is_array($row)) {
2376 $language = intval($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
2377 $transOrigPointer = intval($row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]);
2378 // If language is set (e.g. 1) and also transOrigPointer (e.g. 123), use transOrigPointer as uid:
2379 if ($language > 0 && $transOrigPointer) {
2380 $id = $transOrigPointer;
2381 // If we're in active localizationMode 'keep', prevent from writing data to the field of the parent record:
2382 // (on removing the localized parent, the original (untranslated) children would then also be removed)
2383 $keepTranslation = TRUE;
2387 // IRRE with a pointer field (database normalization):
2388 if ($tcaFieldConf['foreign_field']) {
2389 // if the record was imported, sorting was also imported, so skip this
2390 $skipSorting = ($this->callFromImpExp ?
TRUE : FALSE);
2391 // update record in intermediate table (sorting & pointer uid to parent record)
2392 $dbAnalysis->writeForeignField($tcaFieldConf, $id, 0, $skipSorting);
2393 $newValue = ($keepTranslation ?
0 : $dbAnalysis->countItems(FALSE));
2394 // IRRE with MM relation:
2396 if ($this->getInlineFieldType($tcaFieldConf) == 'mm') {
2397 // in order to fully support all the MM stuff, directly call checkValue_group_select_processDBdata instead of repeating the needed code here
2398 $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field);
2399 $newValue = ($keepTranslation ?
0 : $valueArray[0]);
2400 // IRRE with comma separated values:
2402 $valueArray = $dbAnalysis->getValueArray();
2403 // Checking that the number of items is correct:
2404 $valueArray = $this->checkValue_checkMax($tcaFieldConf, $valueArray);
2405 // If a valid translation of the 'keep' mode is active, update relations in the original(!) record:
2406 if ($keepTranslation) {
2407 $this->updateDB($table, $transOrigPointer, array($field => implode(',', $valueArray)));
2409 $newValue = implode(',', $valueArray);
2418 /*********************************************
2420 * PROCESSING COMMANDS
2422 ********************************************/
2425 * Processing the cmd-array
2426 * See "TYPO3 Core API" for a description of the options.
2430 public function process_cmdmap() {
2433 if ($this->BE_USER
->workspace
!== 0 && $this->BE_USER
->workspaceRec
['freeze']) {
2434 $this->newlog('All editing in this workspace has been frozen!', 1);
2438 // Hook initialization:
2439 $hookObjectsArr = array();
2440 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'])) {
2441 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'] as $classRef) {
2442 $hookObj = t3lib_div
::getUserObj($classRef);
2443 if (method_exists($hookObj, 'processCmdmap_beforeStart')) {
2444 $hookObj->processCmdmap_beforeStart($this);
2446 $hookObjectsArr[] = $hookObj;
2450 // Traverse command map:
2451 foreach (array_keys($this->cmdmap
) as $table) {
2453 // Check if the table may be modified!
2454 $modifyAccessList = $this->checkModifyAccessList($table);
2455 if (!$modifyAccessList) {
2457 $this->log($table, $id, 2, 0, 1, "Attempt to modify table '%s' without permission", 1, array($table));
2458 } // FIXME: $id not set here (Comment added by Sebastian Kurfürst)
2460 // Check basic permissions and circumstances:
2461 if (isset($GLOBALS['TCA'][$table]) && !$this->tableReadOnly($table) && is_array($this->cmdmap
[$table]) && $modifyAccessList) {
2463 // Traverse the command map:
2464 foreach ($this->cmdmap
[$table] as $id => $incomingCmdArray) {
2465 if (is_array($incomingCmdArray)) { // have found a command.
2467 // Get command and value (notice, only one command is observed at a time!):
2468 reset($incomingCmdArray);
2469 $command = key($incomingCmdArray);
2470 $value = current($incomingCmdArray);
2472 foreach ($hookObjectsArr as $hookObj) {
2473 if (method_exists($hookObj, 'processCmdmap_preProcess')) {
2474 $hookObj->processCmdmap_preProcess($command, $table, $id, $value, $this);
2478 // Init copyMapping array:
2479 // Must clear this array before call from here to those functions:
2480 // Contains mapping information between new and old id numbers.
2481 $this->copyMappingArray
= array();
2483 // process the command
2484 $commandIsProcessed = FALSE;
2485 foreach ($hookObjectsArr as $hookObj) {
2486 if (method_exists($hookObj, 'processCmdmap')) {
2487 $hookObj->processCmdmap($command, $table, $id, $value, $commandIsProcessed, $this);
2491 // only execute default commands if a hook hasn't been processed the command already
2492 if (!$commandIsProcessed) {
2493 // Branch, based on command
2496 $this->moveRecord($table, $id, $value);
2499 if ($table === 'pages') {
2500 $this->copyPages($id, $value);
2502 $this->copyRecord($table, $id, $value, 1);
2506 $this->localize($table, $id, $value);
2508 case 'inlineLocalizeSynchronize':
2509 $this->inlineLocalizeSynchronize($table, $id, $value);
2512 $this->deleteAction($table, $id);
2515 $this->undeleteRecord($table, $id);
2520 foreach ($hookObjectsArr as $hookObj) {
2521 if (method_exists($hookObj, 'processCmdmap_postProcess')) {
2522 $hookObj->processCmdmap_postProcess($command, $table, $id, $value, $this);
2526 // Merging the copy-array info together for remapping purposes.
2527 $this->copyMappingArray_merged
= t3lib_div
::array_merge_recursive_overrule($this->copyMappingArray_merged
, $this->copyMappingArray
);
2533 // Finally, before exit, check if there are ID references to remap.
2534 // This might be the case if versioning or copying has taken place!
2535 $this->remapListedDBRecords();
2536 $this->processRemapStack();
2538 foreach ($hookObjectsArr as $hookObj) {
2539 if (method_exists($hookObj, 'processCmdmap_afterFinish')) {
2540 $hookObj->processCmdmap_afterFinish($this);
2544 if ($this->isOuterMostInstance()) {
2545 $this->resetNestedElementCalls();
2550 /*********************************************
2554 ********************************************/
2557 * Copying a single record
2559 * @param string Element table
2560 * @param integer Element UID
2561 * @param integer $destPid: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
2562 * @param boolean $first is a flag set, if the record copied is NOT a 'slave' to another record copied. That is, if this record was asked to be copied in the cmd-array
2563 * @param array Associative array with field/value pairs to override directly. Notice; Fields must exist in the table record and NOT be among excluded fields!
2564 * @param string Commalist of fields to exclude from the copy process (might get default values)
2565 * @param integer Language ID (from sys_language table)
2566 * @return integer ID of new record, if any
2568 function copyRecord($table, $uid, $destPid, $first = 0, $overrideValues = array(), $excludeFields = '', $language = 0) {
2569 $uid = $origUid = intval($uid);
2570 // Only copy if the table is defined in $GLOBALS['TCA'], a uid is given and the record wasn't copied before:
2571 if ($GLOBALS['TCA'][$table] && $uid && !$this->isRecordCopied($table, $uid)) {
2572 t3lib_div
::loadTCA($table);
2574 // In case the record to be moved turns out to be an offline version, we have to find the live version and work on that one (this case happens for pages with "branch" versioning type)
2575 if ($lookForLiveVersion = t3lib_BEfunc::getLiveVersionOfRecord($table,$uid,'uid')) {
2576 $uid = $lookForLiveVersion['uid'];
2578 // Get workspace version of the source record, if any: Then we will copy workspace version instead:
2579 if ($WSversion = t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, $table, $uid, 'uid,t3ver_oid')) {
2580 $uid = $WSversion['uid'];
2582 // Now, the $uid is the actual record we will copy while $origUid is the record we asked to get copied - but that could be a live version.
2584 if ($this->doesRecordExist($table, $uid, 'show')) { // This checks if the record can be selected which is all that a copy action requires.
2585 $fullLanguageCheckNeeded = ($table != 'pages');
2586 if (($language > 0 && $this->BE_USER
->checkLanguageAccess($language)) ||
2587 $this->BE_USER
->recordEditAccessInternals(
2588 $table, $uid, FALSE, FALSE, $fullLanguageCheckNeeded
2590 ) { //Used to check language and general editing rights
2593 $nonFields = array_unique(t3lib_div
::trimExplode(',', 'uid,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,t3ver_oid,t3ver_wsid,t3ver_id,t3ver_label,t3ver_state,t3ver_swapmode,t3ver_count,t3ver_stage,t3ver_tstamp,' . $excludeFields, 1));
2595 // $row = $this->recordInfo($table,$uid,'*');
2596 $row = t3lib_BEfunc
::getRecordWSOL($table, $uid); // So it copies (and localized) content from workspace...
2597 if (is_array($row)) {
2600 $theNewID = uniqid('NEW');
2601 $enableField = isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']) ?
$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] : '';
2602 $headerField = $GLOBALS['TCA'][$table]['ctrl']['label'];
2604 // Getting default data:
2605 $defaultData = $this->newFieldArray($table);
2607 // Getting "copy-after" fields if applicable:
2608 $copyAfterFields = $destPid < 0 ?
$this->fixCopyAfterDuplFields($table, $uid, abs($destPid), 0) : array();
2610 // Page TSconfig related:
2611 $tscPID = t3lib_BEfunc
::getTSconfig_pidValue($table, $uid, $destPid); // NOT using t3lib_BEfunc::getTSCpid() because we need the real pid - not the ID of a page, if the input is a page...
2612 $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
2613 $tE = $this->getTableEntries($table, $TSConfig);
2615 // Traverse ALL fields of the selected record:
2616 foreach ($row as $field => $value) {
2617 if (!in_array($field, $nonFields)) {
2619 // Get TCA configuration for the field:
2620 $conf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
2622 // Preparation/Processing of the value:
2623 if ($field == 'pid') { // "pid" is hardcoded of course:
2625 } elseif (isset($overrideValues[$field])) { // Override value...
2626 $value = $overrideValues[$field];
2627 } elseif (isset($copyAfterFields[$field])) { // Copy-after value if available:
2628 $value = $copyAfterFields[$field];
2629 } elseif ($GLOBALS['TCA'][$table]['ctrl']['setToDefaultOnCopy'] && t3lib_div
::inList($GLOBALS['TCA'][$table]['ctrl']['setToDefaultOnCopy'], $field)) { // Revert to default for some fields:
2630 $value = $defaultData[$field];
2632 // Hide at copy may override:
2633 if ($first && $field == $enableField && $GLOBALS['TCA'][$table]['ctrl']['hideAtCopy'] && !$this->neverHideAtCopy
&& !$tE['disableHideAtCopy']) {
2636 // Prepend label on copy:
2637 if ($first && $field == $headerField && $GLOBALS['TCA'][$table]['ctrl']['prependAtCopy'] && !$tE['disablePrependAtCopy']) {
2638 $value = $this->getCopyHeader($table, $this->resolvePid($table, $destPid), $field, $this->clearPrefixFromValue($table, $value), 0);
2640 // Processing based on the TCA config field type (files, references, flexforms...)
2641 $value = $this->copyRecord_procBasedOnFieldType($table, $uid, $field, $value, $row, $conf, $tscPID, $language);
2644 // Add value to array.
2645 $data[$table][$theNewID][$field] = $value;
2648 // Overriding values:
2649 if ($GLOBALS['TCA'][$table]['ctrl']['editlock']) {
2650 $data[$table][$theNewID][$GLOBALS['TCA'][$table]['ctrl']['editlock']] = 0;
2653 // Setting original UID:
2654 if ($GLOBALS['TCA'][$table]['ctrl']['origUid']) {
2655 $data[$table][$theNewID][$GLOBALS['TCA'][$table]['ctrl']['origUid']] = $uid;
2658 // Do the copy by simply submitting the array through TCEmain:
2659 $copyTCE = t3lib_div
::makeInstance('t3lib_TCEmain');
2660 /** @var $copyTCE t3lib_TCEmain */
2661 $copyTCE->stripslashes_values
= 0;
2662 $copyTCE->copyTree
= $this->copyTree
;
2663 $copyTCE->cachedTSconfig
= $this->cachedTSconfig
; // Copy forth the cached TSconfig
2664 $copyTCE->dontProcessTransformations
= 1; // Transformations should NOT be carried out during copy
2666 $copyTCE->start($data, '', $this->BE_USER
);
2667 $copyTCE->process_datamap();
2669 // Getting the new UID:
2670 $theNewSQLID = $copyTCE->substNEWwithIDs
[$theNewID];
2672 $this->copyRecord_fixRTEmagicImages($table, t3lib_BEfunc
::wsMapId($table, $theNewSQLID));
2673 $this->copyMappingArray
[$table][$origUid] = $theNewSQLID;
2674 // Keep automatically versionized record information:
2675 if (isset($copyTCE->autoVersionIdMap
[$table][$theNewSQLID])) {
2676 $this->autoVersionIdMap
[$table][$theNewSQLID] = $copyTCE->autoVersionIdMap
[$table][$theNewSQLID];
2680 // Copy back the cached TSconfig
2681 $this->cachedTSconfig
= $copyTCE->cachedTSconfig
;
2682 $this->errorLog
= array_merge($this->errorLog
, $copyTCE->errorLog
);
2685 if ($language == 0) {
2686 //repointing the new translation records to the parent record we just created
2687 $overrideValues[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] = $theNewSQLID;
2688 $this->copyL10nOverlayRecords($table, $uid, $destPid < 0 ?
$tscPID : $destPid, $first, $overrideValues, $excludeFields);
2691 return $theNewSQLID;
2693 $this->log($table, $uid, 3, 0, 1, 'Attempt to copy record that did not exist!');
2696 $this->log($table, $uid, 3, 0, 1, 'Attempt to copy record without having permissions to do so. [' . $this->BE_USER
->errorMsg
. '].');
2699 $this->log($table, $uid, 3, 0, 1, 'Attempt to copy record without permission');
2706 * Main function for copying pages.
2708 * @param integer Page UID to copy
2709 * @param integer Destination PID: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
2712 function copyPages($uid, $destPid) {
2715 $uid = intval($uid);
2716 $destPid = intval($destPid);
2718 // Finding list of tables to copy.
2719 $copyTablesArray = $this->admin ?
$this->compileAdminTables() : explode(',', $this->BE_USER
->groupData
['tables_modify']); // These are the tables, the user may modify
2720 if (!strstr($this->copyWhichTables
, '*')) { // If not all tables are allowed then make a list of allowed tables: That is the tables that figure in both allowed tables AND the copyTable-list
2721 foreach ($copyTablesArray as $k => $table) {
2722 if (!$table ||
!t3lib_div
::inList($this->copyWhichTables
. ',pages', $table)) { // pages are always going...
2723 unset($copyTablesArray[$k]);
2727 $copyTablesArray = array_unique($copyTablesArray);
2729 // Begin to copy pages if we're allowed to:
2730 if ($this->admin ||
in_array('pages', $copyTablesArray)) {
2732 // Copy this page we're on. And set first-flag (this will trigger that the record is hidden if that is configured)!
2733 $theNewRootID = $this