00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00208
00209
00210
00211 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
00212 require_once (PATH_t3lib.'class.t3lib_parsehtml_proc.php');
00213 require_once (PATH_t3lib.'class.t3lib_stdgraphic.php');
00214 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
00215 require_once (PATH_t3lib.'class.t3lib_refindex.php');
00216 require_once (PATH_t3lib.'class.t3lib_flexformtools.php');
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00242 class t3lib_TCEmain {
00243
00244
00245
00246
00247
00248
00249 var $storeLogMessages = TRUE;
00250 var $enableLogging = TRUE;
00251 var $reverseOrder = FALSE;
00252 var $checkSimilar = TRUE;
00253 var $stripslashes_values = TRUE;
00254 var $checkStoredRecords = TRUE;
00255 var $checkStoredRecords_loose = TRUE;
00256 var $deleteTree = FALSE;
00257 var $neverHideAtCopy = FALSE;
00258 var $dontProcessTransformations = FALSE;
00259 var $bypassWorkspaceRestrictions = FALSE;
00260 var $bypassFileHandling = FALSE;
00261 var $bypassAccessCheckForRecords = FALSE;
00262
00263 var $copyWhichTables = '*';
00264 var $generalComment = '';
00265
00266 var $copyTree = 0;
00267
00268 var $defaultValues = array();
00269 var $overrideValues = array();
00270 var $alternativeFileName = array();
00271 var $data_disableFields=array();
00272 var $suggestedInsertUids=array();
00273
00274 var $callBackObj;
00275
00276
00277
00278
00279
00280
00281
00282 var $autoVersionIdMap = Array();
00283 var $substNEWwithIDs = Array();
00284 var $substNEWwithIDs_table = Array();
00285 var $newRelatedIDs = Array();
00286 var $copyMappingArray_merged = Array();
00287 var $copiedFileMap = Array();
00288 var $errorLog = Array();
00289
00290
00291
00292
00293
00294
00295
00296
00297 var $BE_USER;
00298 var $userid;
00299 var $username;
00300 var $admin;
00301
00302 var $defaultPermissions = array(
00303 'user' => 'show,edit,delete,new,editcontent',
00304 'group' => 'show,edit,new,editcontent',
00305 'everybody' => ''
00306 );
00307
00308 var $exclude_array;
00309 var $datamap = Array();
00310 var $cmdmap = Array();
00311
00312
00313 var $pMap = Array(
00314 'show' => 1,
00315 'edit' => 2,
00316 'delete' => 4,
00317 'new' => 8,
00318 'editcontent' => 16
00319 );
00320 var $sortIntervals = 256;
00321
00322
00323 var $recUpdateAccessCache = Array();
00324 var $recInsertAccessCache = Array();
00325 var $isRecordInWebMount_Cache=array();
00326 var $isInWebMount_Cache=array();
00327 var $cachedTSconfig = array();
00328 var $pageCache = Array();
00329 var $checkWorkspaceCache = Array();
00330
00331
00332 var $dbAnalysisStore=array();
00333 var $removeFilesStore=array();
00334 var $uploadedFileArray = array();
00335 var $registerDBList=array();
00336 var $registerDBPids=array();
00337 var $copyMappingArray = Array();
00338 var $remapStack = array();
00339 var $remapStackRecords = array();
00340 var $updateRefIndexStack = array();
00341 var $callFromImpExp = false;
00342
00343
00344 var $fileFunc;
00345 var $checkValue_currentRecord=array();
00346 var $autoVersioningUpdate = FALSE;
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00369 function start($data,$cmd,$altUserObject='') {
00370
00371
00372 $this->BE_USER = is_object($altUserObject) ? $altUserObject : $GLOBALS['BE_USER'];
00373 $this->userid = $this->BE_USER->user['uid'];
00374 $this->username = $this->BE_USER->user['username'];
00375 $this->admin = $this->BE_USER->user['admin'];
00376
00377 if ($GLOBALS['BE_USER']->uc['recursiveDelete']) {
00378 $this->deleteTree = 1;
00379 }
00380
00381
00382 $defaultPermissions = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPermissions'];
00383 if (isset($defaultPermissions['user'])) {$this->defaultPermissions['user'] = $defaultPermissions['user'];}
00384 if (isset($defaultPermissions['group'])) {$this->defaultPermissions['group'] = $defaultPermissions['group'];}
00385 if (isset($defaultPermissions['everybody'])) {$this->defaultPermissions['everybody'] = $defaultPermissions['everybody'];}
00386
00387
00388 $this->exclude_array = $this->admin ? array() : $this->getExcludeListArray();
00389
00390
00391 if (is_array($data)) {
00392 reset($data);
00393 $this->datamap = $data;
00394 }
00395 if (is_array($cmd)) {
00396 reset($cmd);
00397 $this->cmdmap = $cmd;
00398 }
00399 }
00400
00408 function setMirror($mirror) {
00409 if (is_array($mirror)) {
00410 reset($mirror);
00411 while(list($table,$uid_array)=each($mirror)) {
00412 if (isset($this->datamap[$table])) {
00413 reset($uid_array);
00414 while (list($id,$uidList) = each($uid_array)) {
00415 if (isset($this->datamap[$table][$id])) {
00416 $theIdsInArray = t3lib_div::trimExplode(',',$uidList,1);
00417 while(list(,$copyToUid)=each($theIdsInArray)) {
00418 $this->datamap[$table][$copyToUid] = $this->datamap[$table][$id];
00419 }
00420 }
00421 }
00422 }
00423 }
00424 }
00425 }
00426
00433 function setDefaultsFromUserTS($userTS) {
00434 global $TCA;
00435 if (is_array($userTS)) {
00436 foreach($userTS as $k => $v) {
00437 $k = substr($k,0,-1);
00438 if ($k && is_array($v) && isset($TCA[$k])) {
00439 if (is_array($this->defaultValues[$k])) {
00440 $this->defaultValues[$k] = array_merge($this->defaultValues[$k],$v);
00441 } else {
00442 $this->defaultValues[$k] = $v;
00443 }
00444 }
00445 }
00446 }
00447 }
00448
00456 function process_uploads($postFiles) {
00457
00458 if (is_array($postFiles)) {
00459
00460
00461 if ($this->BE_USER->workspace!==0 && $this->BE_USER->workspaceRec['freeze']) {
00462 $this->newlog('All editing in this workspace has been frozen!',1);
00463 return FALSE;
00464 }
00465
00466 reset($postFiles);
00467 $subA = current($postFiles);
00468 if (is_array($subA)) {
00469 if (is_array($subA['name']) && is_array($subA['type']) && is_array($subA['tmp_name']) && is_array($subA['size'])) {
00470
00471 $this->uploadedFileArray=array();
00472
00473
00474 foreach($subA as $key => $values) {
00475 $this->process_uploads_traverseArray($this->uploadedFileArray,$values,$key);
00476 }
00477 } else {
00478 $this->uploadedFileArray=$subA;
00479 }
00480 }
00481 }
00482 }
00483
00494 function process_uploads_traverseArray(&$outputArr,$inputArr,$keyToSet) {
00495 if (is_array($inputArr)) {
00496 foreach($inputArr as $key => $value) {
00497 $this->process_uploads_traverseArray($outputArr[$key],$inputArr[$key],$keyToSet);
00498 }
00499 } else {
00500 $outputArr[$keyToSet]=$inputArr;
00501 }
00502 }
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00538 function hook_processDatamap_afterDatabaseOperations(&$hookObjectsArr, &$status, &$table, &$id, &$fieldArray) {
00539
00540 if (!isset($this->remapStackRecords[$table][$id])) {
00541 foreach($hookObjectsArr as $hookObj) {
00542 if (method_exists($hookObj, 'processDatamap_afterDatabaseOperations')) {
00543 $hookObj->processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $this);
00544 }
00545 }
00546
00547 } else {
00548 $this->remapStackRecords[$table][$id]['processDatamap_afterDatabaseOperations'] = array(
00549 'status' => $status,
00550 'fieldArray' => $fieldArray,
00551 'hookObjectsArr' => $hookObjectsArr,
00552 );
00553 }
00554 }
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00581 function process_datamap() {
00582 global $TCA, $TYPO3_CONF_VARS;
00583
00584
00585 if ($this->BE_USER->workspace!==0 && $this->BE_USER->workspaceRec['freeze']) {
00586 $this->newlog('All editing in this workspace has been frozen!',1);
00587 return FALSE;
00588 }
00589
00590
00591 $hookObjectsArr = array();
00592 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'])) {
00593 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'] as $classRef) {
00594 $hookObjectsArr[] = &t3lib_div::getUserObj($classRef);
00595 }
00596 }
00597
00598
00599 $orderOfTables = Array();
00600 if (isset($this->datamap['pages'])) {
00601 $orderOfTables[]='pages';
00602 }
00603 reset($this->datamap);
00604 while (list($table,) = each($this->datamap)) {
00605 if ($table!='pages') {
00606 $orderOfTables[]=$table;
00607 }
00608 }
00609
00610
00611 foreach($orderOfTables as $table) {
00612
00613
00614
00615
00616
00617
00618 $modifyAccessList = $this->checkModifyAccessList($table);
00619 if (!$modifyAccessList) {
00620 $id = 0;
00621 $this->log($table,$id,2,0,1,"Attempt to modify table '%s' without permission",1,array($table));
00622 }
00623 if (isset($TCA[$table]) && !$this->tableReadOnly($table) && is_array($this->datamap[$table]) && $modifyAccessList) {
00624 if ($this->reverseOrder) {
00625 $this->datamap[$table] = array_reverse($this->datamap[$table], 1);
00626 }
00627
00628
00629
00630
00631 foreach($this->datamap[$table] as $id => $incomingFieldArray) {
00632 if (is_array($incomingFieldArray)) {
00633
00634
00635 foreach($hookObjectsArr as $hookObj) {
00636 if (method_exists($hookObj, 'processDatamap_preProcessFieldArray')) {
00637 $hookObj->processDatamap_preProcessFieldArray($incomingFieldArray, $table, $id, $this);
00638 }
00639 }
00640
00641
00642
00643
00644 $createNewVersion = FALSE;
00645 $recordAccess = FALSE;
00646 $old_pid_value = '';
00647 $resetRejected = FALSE;
00648 $this->autoVersioningUpdate = FALSE;
00649
00650 if (!t3lib_div::testInt($id)) {
00651 $fieldArray = $this->newFieldArray($table);
00652 if (isset($incomingFieldArray['pid'])) {
00653
00654 $pid_value = $incomingFieldArray['pid'];
00655
00656
00657 $OK = 1;
00658 if (strstr($pid_value,'NEW')) {
00659 if (substr($pid_value,0,1)=='-') {$negFlag=-1;$pid_value=substr($pid_value,1);} else {$negFlag=1;}
00660 if (isset($this->substNEWwithIDs[$pid_value])) {
00661 $old_pid_value = $pid_value;
00662 $pid_value=intval($negFlag*$this->substNEWwithIDs[$pid_value]);
00663 } else {$OK = 0;}
00664 } elseif ($pid_value>=0 && $this->BE_USER->workspace!==0 && $TCA[$table]['ctrl']['versioning_followPages']) {
00665 if ($WSdestPage = t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, 'pages', $pid_value, 'uid,t3ver_swapmode')) {
00666 if ($WSdestPage['t3ver_swapmode']==0) {
00667 $pid_value = $WSdestPage['uid'];
00668 }
00669 }
00670 }
00671 $pid_value = intval($pid_value);
00672
00673
00674 if ($OK) {
00675 $sortRow = $TCA[$table]['ctrl']['sortby'];
00676 if ($pid_value>=0) {
00677 if ($sortRow) {
00678 $fieldArray[$sortRow] = $this->getSortNumber($table,0,$pid_value);
00679 }
00680 $fieldArray['pid'] = $pid_value;
00681 } else {
00682 if ($sortRow) {
00683 $tempArray=$this->getSortNumber($table,0,$pid_value);
00684 $fieldArray['pid'] = $tempArray['pid'];
00685 $fieldArray[$sortRow] = $tempArray['sortNumber'];
00686 } else {
00687 $tempdata = $this->recordInfo($table,abs($pid_value),'pid');
00688 $fieldArray['pid']=$tempdata['pid'];
00689 }
00690 }
00691 }
00692 }
00693 $theRealPid = $fieldArray['pid'];
00694
00695
00696 if ($theRealPid>=0) {
00697 $recordAccess = $this->checkRecordInsertAccess($table,$theRealPid);
00698 if ($recordAccess) {
00699 $this->addDefaultPermittedLanguageIfNotSet($table,$incomingFieldArray);
00700 $recordAccess = $this->BE_USER->recordEditAccessInternals($table,$incomingFieldArray,TRUE);
00701 if (!$recordAccess) {
00702 $this->newlog("recordEditAccessInternals() check failed. [".$this->BE_USER->errorMsg."]",1);
00703 } elseif(!$this->bypassWorkspaceRestrictions) {
00704
00705 if ($res = $this->BE_USER->workspaceAllowLiveRecordsInPID($theRealPid,$table)) {
00706 if ($res<0) {
00707 $recordAccess = FALSE;
00708 $this->newlog('Stage for versioning root point and users access level did not allow for editing',1);
00709 }
00710 } else {
00711 if ($TCA[$table]['ctrl']['versioningWS']) {
00712 $createNewVersion = TRUE;
00713 } else {
00714 $recordAccess = FALSE;
00715 $this->newlog('Record could not be created in this workspace in this branch',1);
00716 }
00717 }
00718 }
00719 }
00720 } else {
00721 debug('Internal ERROR: pid should not be less than zero!');
00722 }
00723 $status = 'new';
00724 } else {
00725 $fieldArray = array();
00726 $recordAccess = $this->checkRecordUpdateAccess($table,$id);
00727 if (!$recordAccess) {
00728 $propArr = $this->getRecordProperties($table,$id);
00729 $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']);
00730 } else {
00731 $recordAccess = $this->BE_USER->recordEditAccessInternals($table,$id);
00732 if (!$recordAccess) {
00733 $propArr = $this->getRecordProperties($table,$id);
00734 $this->newlog("recordEditAccessInternals() check failed. [".$this->BE_USER->errorMsg."]",1);
00735 } else {
00736 $tempdata = $this->recordInfo($table,$id,'pid'.($TCA[$table]['ctrl']['versioningWS']?',t3ver_wsid,t3ver_stage':''));
00737 $theRealPid = $tempdata['pid'];
00738
00739
00740 if ($TCA[$table]['ctrl']['versioningWS'] && $tempdata['t3ver_stage']<0) {
00741 $resetRejected = TRUE;
00742 }
00743
00744
00745 if (!$this->bypassWorkspaceRestrictions && $errorCode = $this->BE_USER->workspaceCannotEditRecord($table,$tempdata)) {
00746 $recordAccess = FALSE;
00747
00748
00749 if ($this->BE_USER->workspaceAllowAutoCreation($table,$id,$theRealPid)) {
00750 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00751 $tce->stripslashes_values = 0;
00752
00753
00754 $cmd = array();
00755 $cmd[$table][$id]['version'] = array(
00756 'action' => 'new',
00757 'treeLevels' => -1,
00758 'label' => 'Auto-created for WS #'.$this->BE_USER->workspace
00759 );
00760 $tce->start(array(),$cmd);
00761 $tce->process_cmdmap();
00762 $this->errorLog = array_merge($this->errorLog,$tce->errorLog);
00763
00764 if ($tce->copyMappingArray[$table][$id]) {
00765 $this->uploadedFileArray[$table][$tce->copyMappingArray[$table][$id]] = $this->uploadedFileArray[$table][$id];
00766 $id = $this->autoVersionIdMap[$table][$id] = $tce->copyMappingArray[$table][$id];
00767 $recordAccess = TRUE;
00768 $this->autoVersioningUpdate = TRUE;
00769 } else $this->newlog("Could not be edited in offline workspace in the branch where found (failure state: '".$errorCode."'). Auto-creation of version failed!",1);
00770 } else $this->newlog("Could not be edited in offline workspace in the branch where found (failure state: '".$errorCode."'). Auto-creation of version not allowed in workspace!",1);
00771 }
00772 }
00773 }
00774 $status = 'update';
00775 }
00776
00777
00778 if ($recordAccess) {
00779
00780 list($tscPID) = t3lib_BEfunc::getTSCpid($table,$id,$old_pid_value ? $old_pid_value : $fieldArray['pid']);
00781 $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
00782 if ($status=='new' && $table=='pages' && is_array($TSConfig['permissions.'])) {
00783 $fieldArray = $this->setTSconfigPermissions($fieldArray,$TSConfig['permissions.']);
00784 }
00785 if ($createNewVersion) {
00786 $newVersion_placeholderFieldArray = $fieldArray;
00787 }
00788
00789
00790 $fieldArray = $this->fillInFieldArray($table,$id,$fieldArray,$incomingFieldArray,$theRealPid,$status,$tscPID);
00791
00792
00793
00794
00795 $fieldArray = $this->overrideFieldArray($table,$fieldArray);
00796 if ($createNewVersion) {
00797 $newVersion_placeholderFieldArray = $this->overrideFieldArray($table,$newVersion_placeholderFieldArray);
00798 }
00799
00800
00801 if ($status=='new') {
00802 if ($TCA[$table]['ctrl']['crdate']) {
00803 $fieldArray[$TCA[$table]['ctrl']['crdate']]=time();
00804 if ($createNewVersion) $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['crdate']]=time();
00805 }
00806 if ($TCA[$table]['ctrl']['cruser_id']) {
00807 $fieldArray[$TCA[$table]['ctrl']['cruser_id']]=$this->userid;
00808 if ($createNewVersion) $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['cruser_id']]=$this->userid;
00809 }
00810 } elseif ($this->checkSimilar) {
00811 $fieldArray = $this->compareFieldArrayWithCurrentAndUnset($table,$id,$fieldArray);
00812 }
00813 if ($TCA[$table]['ctrl']['tstamp'] && count($fieldArray)) {
00814 $fieldArray[$TCA[$table]['ctrl']['tstamp']]=time();
00815 if ($createNewVersion) $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['tstamp']]=time();
00816 }
00817 if ($resetRejected) {
00818 $fieldArray['t3ver_stage'] = 0;
00819 }
00820
00821
00822 foreach($hookObjectsArr as $hookObj) {
00823 if (method_exists($hookObj, 'processDatamap_postProcessFieldArray')) {
00824 $hookObj->processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $this);
00825 }
00826 }
00827
00828
00829
00830 if (is_array($fieldArray)) {
00831 if ($status=='new') {
00832 if ($createNewVersion) {
00833 $versioningType = $table==='pages' ? $this->BE_USER->workspaceVersioningTypeGetClosest(t3lib_div::intInRange($TYPO3_CONF_VARS['BE']['newPagesVersioningType'],-1,1)) : -1;
00834 if ($this->BE_USER->workspaceVersioningTypeAccess($versioningType)) {
00835 $newVersion_placeholderFieldArray['t3ver_label'] = 'INITIAL PLACEHOLDER';
00836 $newVersion_placeholderFieldArray['t3ver_state'] = 1;
00837 $newVersion_placeholderFieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
00838 $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['label']] = '[PLACEHOLDER, WS#'.$this->BE_USER->workspace.']';
00839 $this->insertDB($table,$id,$newVersion_placeholderFieldArray,FALSE);
00840
00841
00842 $fieldArray['pid'] = -1;
00843 $fieldArray['t3ver_oid'] = $this->substNEWwithIDs[$id];
00844 $fieldArray['t3ver_id'] = 1;
00845 $fieldArray['t3ver_state'] = -1;
00846 $fieldArray['t3ver_label'] = 'First draft version';
00847 $fieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
00848 if ($table==='pages') {
00849 $fieldArray['t3ver_swapmode'] = $versioningType;
00850 }
00851 $phShadowId = $this->insertDB($table,$id,$fieldArray,TRUE,0,TRUE);
00852 if ($phShadowId) {
00853 $this->placeholderShadowing($table,$phShadowId);
00854 }
00855 } else $this->newlog('Versioning type "'.$versioningType.'" was not allowed, so could not create new record.',1);
00856 } else {
00857 $this->insertDB($table,$id,$fieldArray,FALSE,$incomingFieldArray['uid']);
00858 }
00859 } else {
00860 $this->updateDB($table,$id,$fieldArray);
00861 $this->placeholderShadowing($table,$id);
00862 }
00863 }
00864
00865
00866
00867
00868
00869
00870
00871 $this->hook_processDatamap_afterDatabaseOperations($hookObjectsArr, $status, $table, $id, $fieldArray);
00872 }
00873 }
00874 }
00875 }
00876 }
00877
00878
00879 $this->processRemapStack();
00880
00881 $this->dbAnalysisStoreExec();
00882 $this->removeRegisteredFiles();
00883 }
00884
00892 function placeholderShadowing($table,$id) {
00893 global $TCA;
00894
00895 t3lib_div::loadTCA($table);
00896 if ($liveRec = t3lib_BEfunc::getLiveVersionOfRecord($table,$id,'*')) {
00897 if ((int)$liveRec['t3ver_state']===1) {
00898 $justStoredRecord = t3lib_BEfunc::getRecord($table,$id);
00899 $newRecord = array();
00900
00901 $shadowCols = $TCA[$table]['ctrl']['shadowColumnsForNewPlaceholders'];
00902 $shadowCols.= ','.$TCA[$table]['ctrl']['languageField'];
00903 $shadowCols.= ','.$TCA[$table]['ctrl']['transOrigPointerField'];
00904 $shadowCols.= ','.$TCA[$table]['ctrl']['type'];
00905 $shadowCols.= ','.$TCA[$table]['ctrl']['label'];
00906
00907 $shadowColumns = array_unique(t3lib_div::trimExplode(',', $shadowCols,1));
00908 foreach($shadowColumns as $fieldName) {
00909 if (strcmp($justStoredRecord[$fieldName],$liveRec[$fieldName]) && isset($TCA[$table]['columns'][$fieldName]) && $fieldName!=='uid' && $fieldName!=='pid') {
00910 $newRecord[$fieldName] = $justStoredRecord[$fieldName];
00911 }
00912 }
00913
00914 if (count($newRecord)) {
00915 $this->newlog('Shadowing done on fields '.implode(',',array_keys($newRecord)).' in Placeholder record '.$table.':'.$liveRec['uid'].' (offline version UID='.$id.')');
00916 $this->updateDB($table,$liveRec['uid'],$newRecord);
00917 }
00918 }
00919 }
00920 }
00921
00935 function fillInFieldArray($table,$id,$fieldArray,$incomingFieldArray,$realPid,$status,$tscPID) {
00936 global $TCA;
00937
00938
00939 t3lib_div::loadTCA($table);
00940 $originalLanguageRecord = NULL;
00941 $originalLanguage_diffStorage = NULL;
00942 $diffStorageFlag = FALSE;
00943
00944
00945 if (strstr($id,'NEW')) {
00946 $currentRecord = $checkValueRecord = $fieldArray;
00947
00948
00949
00950 if (is_array($incomingFieldArray) && is_array($checkValueRecord)) {
00951 $checkValueRecord = t3lib_div::array_merge_recursive_overrule($checkValueRecord, $incomingFieldArray);
00952 }
00953 } else {
00954 $currentRecord = $checkValueRecord = $this->recordInfo($table,$id,'*');
00955
00956 t3lib_BEfunc::fixVersioningPid($table,$currentRecord);
00957
00958
00959 if (is_array($currentRecord)
00960 && $TCA[$table]['ctrl']['transOrigDiffSourceField']
00961 && $TCA[$table]['ctrl']['languageField']
00962 && $currentRecord[$TCA[$table]['ctrl']['languageField']] > 0
00963 && $TCA[$table]['ctrl']['transOrigPointerField']
00964 && intval($currentRecord[$TCA[$table]['ctrl']['transOrigPointerField']]) > 0) {
00965
00966 $lookUpTable = $TCA[$table]['ctrl']['transOrigPointerTable'] ? $TCA[$table]['ctrl']['transOrigPointerTable'] : $table;
00967 $originalLanguageRecord = $this->recordInfo($lookUpTable,$currentRecord[$TCA[$table]['ctrl']['transOrigPointerField']],'*');
00968 t3lib_BEfunc::workspaceOL($lookUpTable,$originalLanguageRecord);
00969 $originalLanguage_diffStorage = unserialize($currentRecord[$TCA[$table]['ctrl']['transOrigDiffSourceField']]);
00970 }
00971 }
00972 $this->checkValue_currentRecord = $checkValueRecord;
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983 foreach($incomingFieldArray as $field => $fieldValue) {
00984 if (!in_array($table.'-'.$field, $this->exclude_array) && !$this->data_disableFields[$table][$id][$field]) {
00985
00986
00987 $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$this->BE_USER->checkLanguageAccess($fieldValue);
00988
00989 if (!$languageDeny) {
00990
00991 if ($this->stripslashes_values) {
00992 if (is_array($fieldValue)) {
00993 t3lib_div::stripSlashesOnArray($fieldValue);
00994 } else $fieldValue = stripslashes($fieldValue);
00995 }
00996
00997 switch ($field) {
00998 case 'uid':
00999 case 'pid':
01000
01001 break;
01002 case 'perms_userid':
01003 case 'perms_groupid':
01004 case 'perms_user':
01005 case 'perms_group':
01006 case 'perms_everybody':
01007
01008 if ($table=='pages' && ($this->admin || $status=='new' || $this->pageInfo($id,'perms_userid')==$this->userid) ) {
01009 $value=intval($fieldValue);
01010 switch($field) {
01011 case 'perms_userid':
01012 $fieldArray[$field]=$value;
01013 break;
01014 case 'perms_groupid':
01015 $fieldArray[$field]=$value;
01016 break;
01017 default:
01018 if ($value>=0 && $value<pow(2,5)) {
01019 $fieldArray[$field]=$value;
01020 }
01021 break;
01022 }
01023 }
01024 break;
01025 case 't3ver_oid':
01026 case 't3ver_id':
01027 case 't3ver_wsid':
01028 case 't3ver_state':
01029 case 't3ver_swapmode':
01030 case 't3ver_count':
01031 case 't3ver_stage':
01032 case 't3ver_tstamp':
01033
01034 break;
01035 default:
01036 if (isset($TCA[$table]['columns'][$field])) {
01037
01038 $res = $this->checkValue($table,$field,$fieldValue,$id,$status,$realPid,$tscPID);
01039 if (isset($res['value'])) {
01040 $fieldArray[$field]=$res['value'];
01041
01042
01043 if ($TCA[$table]['ctrl']['transOrigDiffSourceField']) {
01044 $originalLanguage_diffStorage[$field] = $originalLanguageRecord[$field];
01045 $diffStorageFlag = TRUE;
01046 }
01047 }
01048 } elseif ($TCA[$table]['ctrl']['origUid']===$field) {
01049 $fieldArray[$field] = $fieldValue;
01050 }
01051 break;
01052 }
01053 }
01054 }
01055 }
01056
01057
01058 if ($diffStorageFlag && !isset($fieldArray[$TCA[$table]['ctrl']['transOrigDiffSourceField']])) {
01059 $fieldArray[$TCA[$table]['ctrl']['transOrigDiffSourceField']] = serialize($originalLanguage_diffStorage);
01060 }
01061
01062
01063 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$currentRecord);
01064 $theTypeString = t3lib_BEfunc::getTCAtypeValue($table,$currentRecord);
01065 if (is_array($types_fieldConfig)) {
01066 reset($types_fieldConfig);
01067 while(list(,$vconf) = each($types_fieldConfig)) {
01068
01069 $eFile = t3lib_parsehtml_proc::evalWriteFile($vconf['spec']['static_write'],array_merge($currentRecord,$fieldArray));
01070
01071
01072 if (!$this->dontProcessTransformations) {
01073 if (isset($fieldArray[$vconf['field']])) {
01074
01075 switch((string)$incomingFieldArray['_TRANSFORM_'.$vconf['field']]) {
01076 case 'RTE':
01077 $RTEsetup = $this->BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID));
01078 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$vconf['field'],$theTypeString);
01079
01080
01081 $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
01082
01083
01084 $RTEobj = &t3lib_BEfunc::RTEgetObj();
01085 if (is_object($RTEobj)) {
01086 $fieldArray[$vconf['field']] = $RTEobj->transformContent('db',$fieldArray[$vconf['field']],$table,$vconf['field'],$currentRecord,$vconf['spec'],$thisConfig,$RTErelPath,$currentRecord['pid']);
01087 } else {
01088 debug('NO RTE OBJECT FOUND!');
01089 }
01090 break;
01091 }
01092 }
01093 }
01094
01095
01096 if (is_array($eFile)) {
01097 $mixedRec = array_merge($currentRecord,$fieldArray);
01098 $SW_fileContent = t3lib_div::getUrl($eFile['editFile']);
01099 $parseHTML = t3lib_div::makeInstance('t3lib_parsehtml_proc');
01100 $parseHTML->init('','');
01101
01102 $eFileMarker = $eFile['markerField']&&trim($mixedRec[$eFile['markerField']]) ? trim($mixedRec[$eFile['markerField']]) : '###TYPO3_STATICFILE_EDIT###';
01103 $insertContent = str_replace($eFileMarker,'',$mixedRec[$eFile['contentField']]);
01104
01105 $SW_fileNewContent = $parseHTML->substituteSubpart($SW_fileContent, $eFileMarker, chr(10).$insertContent.chr(10), 1, 1);
01106 t3lib_div::writeFile($eFile['editFile'],$SW_fileNewContent);
01107
01108
01109 if (!strstr($id,'NEW') && $eFile['statusField']) {
01110 $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
01111 $table,
01112 'uid='.intval($id),
01113 array(
01114 $eFile['statusField'] => $eFile['relEditFile'].' updated '.date('d-m-Y H:i:s').', bytes '.strlen($mixedRec[$eFile['contentField']])
01115 )
01116 );
01117 }
01118 } elseif ($eFile && is_string($eFile)) {
01119 $this->log($table,$id,2,0,1,"Write-file error: '%s'",13,array($eFile),$realPid);
01120 }
01121 }
01122 }
01123
01124 return $fieldArray;
01125 }
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01158<