367 'user' =>
'show,edit,delete,new,editcontent',
368 'group' =>
'show,edit,new,editcontent',
695 $this->databaseConnection =
$GLOBALS[
'TYPO3_DB'];
716 public function start($data, $cmd, $altUserObject =
'') {
718 $this->BE_USER = is_object($altUserObject) ? $altUserObject :
$GLOBALS[
'BE_USER'];
719 $this->userid = $this->BE_USER->user[
'uid'];
720 $this->username = $this->BE_USER->user[
'username'];
721 $this->admin = $this->BE_USER->user[
'admin'];
722 if ($this->BE_USER->uc[
'recursiveDelete']) {
723 $this->deleteTree = 1;
725 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'explicitConfirmationOfTranslation'] && $this->updateModeL10NdiffData === TRUE) {
726 $this->updateModeL10NdiffData = FALSE;
742 if (is_array($data)) {
744 $this->datamap = $data;
746 if (is_array($cmd)) {
748 $this->cmdmap = $cmd;
761 if (is_array($mirror)) {
762 foreach ($mirror as $table => $uid_array) {
763 if (isset($this->datamap[$table])) {
764 foreach ($uid_array as $id => $uidList) {
765 if (isset($this->datamap[$table][$id])) {
767 foreach ($theIdsInArray as $copyToUid) {
768 $this->datamap[$table][$copyToUid] = $this->datamap[$table][$id];
785 if (is_array($userTS)) {
786 foreach ($userTS as $k => $v) {
787 $k = substr($k, 0, -1);
788 if ($k && is_array($v) && isset(
$GLOBALS[
'TCA'][$k])) {
789 if (is_array($this->defaultValues[$k])) {
790 $this->defaultValues[$k] = array_merge($this->defaultValues[$k], $v);
792 $this->defaultValues[$k] = $v;
808 if (is_array($postFiles)) {
810 if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec[
'freeze']) {
811 $this->
newlog(
'All editing in this workspace has been frozen!', 1);
814 $subA = reset($postFiles);
815 if (is_array($subA)) {
816 if (is_array($subA[
'name']) && is_array($subA[
'type']) && is_array($subA[
'tmp_name']) && is_array($subA[
'size'])) {
818 $this->uploadedFileArray = array();
820 foreach ($subA as $key => $values) {
824 $this->uploadedFileArray = $subA;
842 if (is_array($inputArr)) {
843 foreach ($inputArr as $key => $value) {
847 $outputArr[$keyToSet] = $inputArr;
873 if (!isset($this->remapStackRecords[$table][$id])) {
874 foreach ($hookObjectsArr as $hookObj) {
875 if (method_exists($hookObj,
'processDatamap_afterDatabaseOperations')) {
876 $hookObj->processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $this);
880 $this->remapStackRecords[$table][$id][
'processDatamap_afterDatabaseOperations'] = array(
882 'fieldArray' => $fieldArray,
883 'hookObjectsArr' => $hookObjectsArr
895 if (!isset($this->checkModifyAccessListHookObjects)) {
896 $this->checkModifyAccessListHookObjects = array();
897 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkModifyAccessList'])) {
898 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkModifyAccessList'] as $classData) {
901 throw new \UnexpectedValueException(
'$hookObject must implement interface \\TYPO3\\CMS\\Core\\DataHandling\\DataHandlerCheckModifyAccessListHookInterface', 1251892472);
903 $this->checkModifyAccessListHookObjects[] = $hookObject;
921 public function process_datamap() {
929 if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec[
'freeze']) {
930 $this->
newlog(
'All editing in this workspace has been frozen!', 1);
934 $hookObjectsArr = array();
935 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processDatamapClass'])) {
936 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processDatamapClass'] as $classRef) {
938 if (method_exists($hookObject,
'processDatamap_beforeStart')) {
939 $hookObject->processDatamap_beforeStart($this);
941 $hookObjectsArr[] = $hookObject;
945 $orderOfTables = array();
947 if (isset($this->datamap[
'pages'])) {
948 $orderOfTables[] =
'pages';
950 $orderOfTables = array_unique(array_merge($orderOfTables, array_keys($this->datamap)));
952 foreach ($orderOfTables as $table) {
958 $modifyAccessList = $this->checkModifyAccessList($table);
959 if (!$modifyAccessList) {
961 $this->
log($table, $id, 2, 0, 1,
'Attempt to modify table \'%s\' without permission', 1, array($table));
963 if (isset(
$GLOBALS[
'TCA'][$table]) && !$this->
tableReadOnly($table) && is_array($this->datamap[$table]) && $modifyAccessList) {
964 if ($this->reverseOrder) {
965 $this->datamap[$table] = array_reverse($this->datamap[$table], 1);
970 foreach ($this->datamap[$table] as $id => $incomingFieldArray) {
971 if (is_array($incomingFieldArray)) {
973 $dateTimeFormats =
$GLOBALS[
'TYPO3_DB']->getDateTimeFormats($table);
974 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $column => $config) {
975 if (isset($incomingFieldArray[$column])) {
976 if (isset($config[
'config'][
'dbType']) &&
GeneralUtility::inList(
'date,datetime', $config[
'config'][
'dbType'])) {
977 $emptyValue = $dateTimeFormats[$config[
'config'][
'dbType']][
'empty'];
978 $format = $dateTimeFormats[$config[
'config'][
'dbType']][
'format'];
979 $incomingFieldArray[$column] = $incomingFieldArray[$column] && $incomingFieldArray[$column] !== $emptyValue ? gmdate($format, $incomingFieldArray[$column]) : $emptyValue;
984 foreach ($hookObjectsArr as $hookObj) {
985 if (method_exists($hookObj,
'processDatamap_preProcessFieldArray')) {
986 $hookObj->processDatamap_preProcessFieldArray($incomingFieldArray, $table, $id, $this);
992 $createNewVersion = FALSE;
993 $recordAccess = FALSE;
995 $this->autoVersioningUpdate = FALSE;
1001 if (isset($incomingFieldArray[
'pid'])) {
1003 $pid_value = $incomingFieldArray[
'pid'];
1007 if (strstr($pid_value,
'NEW')) {
1008 if ($pid_value[0] ===
'-') {
1010 $pid_value = substr($pid_value, 1);
1015 if (isset($this->substNEWwithIDs[$pid_value])) {
1016 if ($negFlag === 1) {
1017 $old_pid_value = $this->substNEWwithIDs[$pid_value];
1019 $pid_value = (int)($negFlag * $this->substNEWwithIDs[$pid_value]);
1024 $pid_value = (int)$pid_value;
1027 $sortRow =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
1029 if ($pid_value >= 0) {
1032 $fieldArray[$sortRow] = $this->
getSortNumber($table, 0, $pid_value);
1035 $fieldArray[
'pid'] = $pid_value;
1042 $fieldArray[
'pid'] = $tempArray[
'pid'];
1043 $fieldArray[$sortRow] = $tempArray[
'sortNumber'];
1046 $tempdata = $this->recordInfo($table, abs($pid_value),
'pid');
1047 $fieldArray[
'pid'] = $tempdata[
'pid'];
1052 $theRealPid = $fieldArray[
'pid'];
1054 if ($theRealPid >= 0) {
1057 if ($recordAccess) {
1059 $recordAccess = $this->BE_USER->recordEditAccessInternals($table, $incomingFieldArray, TRUE);
1060 if (!$recordAccess) {
1061 $this->
newlog(
'recordEditAccessInternals() check failed. [' . $this->BE_USER->errorMsg .
']', 1);
1062 } elseif (!$this->bypassWorkspaceRestrictions) {
1065 if ($res = $this->BE_USER->workspaceAllowLiveRecordsInPID($theRealPid, $table)) {
1067 $recordAccess = FALSE;
1068 $this->
newlog(
'Stage for versioning root point and users access level did not allow for editing', 1);
1072 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
1073 $createNewVersion = TRUE;
1075 $recordAccess = FALSE;
1076 $this->
newlog(
'Record could not be created in this workspace in this branch', 1);
1082 debug(
'Internal ERROR: pid should not be less than zero!');
1088 $fieldArray = array();
1090 if (!$recordAccess) {
1092 $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']);
1095 $recordAccess = $this->BE_USER->recordEditAccessInternals($table, $id);
1096 if (!$recordAccess) {
1098 $this->
newlog(
'recordEditAccessInternals() check failed. [' . $this->BE_USER->errorMsg .
']', 1);
1101 $tempdata = $this->recordInfo($table, $id,
'pid' . (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] ?
',t3ver_wsid,t3ver_stage' :
''));
1102 $theRealPid = $tempdata[
'pid'];
1105 if ($this->autoVersionIdMap[$table][$id]) {
1110 $id = $this->autoVersionIdMap[$table][$id];
1111 $recordAccess = TRUE;
1112 $this->autoVersioningUpdate = TRUE;
1113 } elseif (!$this->bypassWorkspaceRestrictions && ($errorCode = $this->BE_USER->workspaceCannotEditRecord($table, $tempdata))) {
1114 $recordAccess = FALSE;
1119 $id = $WSversion[
'uid'];
1120 $recordAccess = TRUE;
1121 } elseif ($this->BE_USER->workspaceAllowAutoCreation($table, $id, $theRealPid)) {
1124 $tce->stripslashes_values = 0;
1128 $cmd[$table][$id][
'version'] = array(
1132 'label' =>
'Auto-created for WS #' . $this->BE_USER->workspace
1134 $tce->start(array(), $cmd);
1135 $tce->process_cmdmap();
1136 $this->errorLog = array_merge($this->errorLog, $tce->errorLog);
1138 if ($tce->copyMappingArray[$table][$id]) {
1139 foreach ($tce->copyMappingArray as $origTable => $origIdArray) {
1140 foreach ($origIdArray as $origId => $newId) {
1141 $this->uploadedFileArray[$origTable][$newId] = $this->uploadedFileArray[$origTable][$origId];
1142 $this->autoVersionIdMap[$origTable][$origId] = $newId;
1153 $id = $this->autoVersionIdMap[$table][$id];
1154 $recordAccess = TRUE;
1155 $this->autoVersioningUpdate = TRUE;
1157 $this->
newlog(
'Could not be edited in offline workspace in the branch where found (failure state: \'' . $errorCode .
'\'). Auto-creation of version failed!
', 1); 1160 $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); 1165 // The default is 'update
' 1168 // If access was granted above, proceed to create or update record: 1169 if ($recordAccess) { 1170 // Here the "pid" is set IF NOT the old pid was a string pointing to a place in the subst-id array. 1171 list($tscPID) = BackendUtility::getTSCpid($table, $id, $old_pid_value ? $old_pid_value : $fieldArray['pid
']); 1172 if ($status === 'new' && $table === 'pages
') { 1173 $TSConfig = $this->getTCEMAIN_TSconfig($tscPID); 1174 if (isset($TSConfig['permissions.
']) && is_array($TSConfig['permissions.
'])) { 1175 $fieldArray = $this->setTSconfigPermissions($fieldArray, $TSConfig['permissions.
']); 1178 // Processing of all fields in incomingFieldArray and setting them in $fieldArray 1179 $fieldArray = $this->fillInFieldArray($table, $id, $fieldArray, $incomingFieldArray, $theRealPid, $status, $tscPID); 1180 if ($createNewVersion) { 1181 // create a placeholder array with already processed field content 1182 $newVersion_placeholderFieldArray = $fieldArray; 1184 // NOTICE! All manipulation beyond this point bypasses both "excludeFields" AND possible "MM" relations / file uploads to field! 1185 // Forcing some values unto field array: 1186 // NOTICE: This overriding is potentially dangerous; permissions per field is not checked!!! 1187 $fieldArray = $this->overrideFieldArray($table, $fieldArray); 1188 if ($createNewVersion) { 1189 $newVersion_placeholderFieldArray = $this->overrideFieldArray($table, $newVersion_placeholderFieldArray); 1191 // Setting system fields 1192 if ($status == 'new
') { 1193 if ($GLOBALS['TCA
'][$table]['ctrl
']['crdate
']) { 1194 $fieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['crdate
']] = $GLOBALS['EXEC_TIME
']; 1195 if ($createNewVersion) { 1196 $newVersion_placeholderFieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['crdate
']] = $GLOBALS['EXEC_TIME
']; 1199 if ($GLOBALS['TCA
'][$table]['ctrl
']['cruser_id
']) { 1200 $fieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['cruser_id
']] = $this->userid; 1201 if ($createNewVersion) { 1202 $newVersion_placeholderFieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['cruser_id
']] = $this->userid; 1205 } elseif ($this->checkSimilar) { 1206 // Removing fields which are equal to the current value: 1207 $fieldArray = $this->compareFieldArrayWithCurrentAndUnset($table, $id, $fieldArray); 1209 if ($GLOBALS['TCA
'][$table]['ctrl
']['tstamp
'] && count($fieldArray)) { 1210 $fieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['tstamp
']] = $GLOBALS['EXEC_TIME
']; 1211 if ($createNewVersion) { 1212 $newVersion_placeholderFieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['tstamp
']] = $GLOBALS['EXEC_TIME
']; 1215 // Set stage to "Editing" to make sure we restart the workflow 1216 if ($GLOBALS['TCA
'][$table]['ctrl
']['versioningWS
']) { 1217 $fieldArray['t3ver_stage
'] = 0; 1219 // Hook: processDatamap_postProcessFieldArray 1220 foreach ($hookObjectsArr as $hookObj) { 1221 if (method_exists($hookObj, 'processDatamap_postProcessFieldArray
')) { 1222 $hookObj->processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $this); 1225 // Performing insert/update. If fieldArray has been unset by some userfunction (see hook above), don't
do anything
1227 if (is_array($fieldArray)) {
1228 if ($status ==
'new') {
1230 if ($createNewVersion) {
1231 $newVersion_placeholderFieldArray[
't3ver_label'] =
'INITIAL PLACEHOLDER';
1235 $newVersion_placeholderFieldArray[
't3ver_wsid'] = $this->BE_USER->workspace;
1238 $this->
insertDB($table, $id, $newVersion_placeholderFieldArray, FALSE);
1240 $fieldArray[
'pid'] = -1;
1241 $fieldArray[
't3ver_oid'] = $this->substNEWwithIDs[$id];
1242 $fieldArray[
't3ver_id'] = 1;
1245 $fieldArray[
't3ver_label'] =
'First draft version';
1246 $fieldArray[
't3ver_wsid'] = $this->BE_USER->workspace;
1248 $phShadowId = $this->
insertDB($table, $id, $fieldArray, TRUE, 0, TRUE);
1251 $this->
triggerRemapAction($table, $id, array($this,
'placeholderShadowing'), array($table, $phShadowId));
1253 $this->autoVersionIdMap[$table][$this->substNEWwithIDs[$id]] = $phShadowId;
1256 $this->
insertDB($table, $id, $fieldArray, FALSE, $incomingFieldArray[
'uid']);
1259 $this->
updateDB($table, $id, $fieldArray);
1278 foreach ($hookObjectsArr as $hookObj) {
1279 if (method_exists($hookObj,
'processDatamap_afterAllOperations')) {
1280 $hookObj->processDatamap_afterAllOperations($this);
1284 $this->processClearCacheQueue();
1300 $justStoredRecord = BackendUtility::getRecord($table, $id);
1301 $newRecord = array();
1302 $shadowCols =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'shadowColumnsForNewPlaceholders'];
1303 $shadowCols .=
',' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'];
1304 $shadowCols .=
',' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'];
1305 $shadowCols .=
',' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'type'];
1306 $shadowCols .=
',' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'label'];
1308 foreach ($shadowColumns as $fieldName) {
1309 if ((
string)$justStoredRecord[$fieldName] !== (
string)$liveRec[$fieldName] && isset(
$GLOBALS[
'TCA'][$table][
'columns'][$fieldName]) && $fieldName !==
'uid' && $fieldName !==
'pid') {
1310 $newRecord[$fieldName] = $justStoredRecord[$fieldName];
1313 if (count($newRecord)) {
1314 $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']);
1315 $this->
updateDB($table, $liveRec[
'uid'], $newRecord);
1329 if ($placeholderContent === NULL) {
1330 $placeholderContent =
'PLACEHOLDER';
1333 $labelPlaceholder =
'[' . $placeholderContent .
', WS#' . $this->BE_USER->workspace .
']';
1334 $labelField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'label'];
1335 if (!isset(
$GLOBALS[
'TCA'][$table][
'columns'][$labelField][
'config'][
'eval'])) {
1336 return $labelPlaceholder;
1340 return isset($transformedLabel[
'value']) ? $transformedLabel[
'value'] : $labelPlaceholder;
1357 public function fillInFieldArray($table, $id, $fieldArray, $incomingFieldArray, $realPid, $status, $tscPID) {
1359 $originalLanguageRecord = NULL;
1360 $originalLanguage_diffStorage = NULL;
1361 $diffStorageFlag = FALSE;
1363 if (strstr($id,
'NEW')) {
1365 $currentRecord = ($checkValueRecord = $fieldArray);
1368 if (is_array($incomingFieldArray) && is_array($checkValueRecord)) {
1373 $currentRecord = ($checkValueRecord = $this->recordInfo($table, $id,
'*'));
1377 if (is_array($currentRecord) &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField'] &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] && $currentRecord[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']] > 0 &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'] && (
int)$currentRecord[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']] > 0) {
1378 $lookUpTable =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable'] ?: $table;
1379 $originalLanguageRecord = $this->recordInfo($lookUpTable, $currentRecord[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']],
'*');
1381 $originalLanguage_diffStorage = unserialize($currentRecord[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField']]);
1384 $this->checkValue_currentRecord = $checkValueRecord;
1391 foreach ($incomingFieldArray as $field => $fieldValue) {
1392 if (!in_array(($table .
'-' . $field), $this->exclude_array) && !$this->data_disableFields[$table][$id][$field]) {
1395 $languageDeny =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] && (string)
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] === (
string)$field && !$this->BE_USER->checkLanguageAccess($fieldValue);
1396 if (!$languageDeny) {
1398 if ($this->stripslashes_values) {
1399 if (is_array($fieldValue)) {
1402 $fieldValue = stripslashes($fieldValue);
1411 case 'perms_userid':
1413 case 'perms_groupid':
1419 case 'perms_everybody':
1421 if ($table ==
'pages' && ($this->admin || $status ==
'new' || $this->
pageInfo($id,
'perms_userid') == $this->userid)) {
1422 $value = (int)$fieldValue;
1424 case 'perms_userid':
1425 $fieldArray[$field] = $value;
1427 case 'perms_groupid':
1428 $fieldArray[$field] = $value;
1431 if ($value >= 0 && $value < pow(2, 5)) {
1432 $fieldArray[$field] = $value;
1449 case 't3ver_tstamp':
1453 if (isset(
$GLOBALS[
'TCA'][$table][
'columns'][$field])) {
1455 $res = $this->
checkValue($table, $field, $fieldValue, $id, $status, $realPid, $tscPID);
1456 if (array_key_exists(
'value', $res)) {
1457 $fieldArray[$field] = $res[
'value'];
1460 if ($this->updateModeL10NdiffData &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField']) {
1461 $originalLanguage_diffStorage[$field] = $this->updateModeL10NdiffDataClear ?
'' : $originalLanguageRecord[$field];
1462 $diffStorageFlag = TRUE;
1469 if ($this->autoVersioningUpdate === TRUE) {
1470 if (is_array($this->RTEmagic_copyIndex[$table][$id][$field])) {
1471 foreach ($this->RTEmagic_copyIndex[$table][$id][$field] as $oldRTEmagicName => $newRTEmagicName) {
1472 $fieldArray[$field] = str_replace(
' src="' . $oldRTEmagicName .
'"',
' src="' . $newRTEmagicName .
'"', $fieldArray[$field]);
1476 } elseif (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'origUid'] === $field) {
1478 $fieldArray[$field] = $fieldValue;
1485 if ($diffStorageFlag && !isset($fieldArray[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField']])) {
1487 $fieldArray[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField']] = serialize($originalLanguage_diffStorage);
1491 $theTypeString = NULL;
1492 if (is_array($types_fieldConfig)) {
1493 foreach ($types_fieldConfig as $vconf) {
1495 if (isset($vconf[
'spec'][
'static_write']) && isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'staticFileEditPath'])) {
1499 if (is_string($eFile)) {
1500 $this->
log($table, $id, 2, 0, 1,
'Write-file error: \'%s\'', 13, array($eFile), $realPid);
1506 if (!$this->dontProcessTransformations) {
1507 if (isset($fieldArray[$vconf[
'field']])) {
1509 switch ((
string) $incomingFieldArray[(
'_TRANSFORM_' . $vconf[
'field'])]) {
1511 if ($theTypeString === NULL) {
1517 $RTErelPath = isset($eFile) ? dirname($eFile[
'relEditFile']) :
'';
1520 if (is_object($RTEobj)) {
1521 $fieldArray[$vconf[
'field']] = $RTEobj->transformContent(
'db', $fieldArray[$vconf[
'field']], $table, $vconf[
'field'], $currentRecord, $vconf[
'spec'], $thisConfig, $RTErelPath, $currentRecord[
'pid']);
1523 debug(
'NO RTE OBJECT FOUND!');
1530 if (isset($eFile)) {
1531 $mixedRec = array_merge($currentRecord, $fieldArray);
1535 $parseHTML->init(
'',
'');
1536 $eFileMarker = $eFile[
'markerField'] && trim($mixedRec[$eFile[
'markerField']]) ? trim($mixedRec[$eFile[
'markerField']]) :
'###TYPO3_STATICFILE_EDIT###';
1538 $insertContent = str_replace($eFileMarker,
'', $mixedRec[$eFile[
'contentField']]);
1539 $SW_fileNewContent = $parseHTML->substituteSubpart($SW_fileContent, $eFileMarker, LF . $insertContent . LF, 1, 1);
1542 if (!strstr($id,
'NEW') && $eFile[
'statusField']) {
1543 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$id, array(
1544 $eFile[
'statusField'] => $eFile[
'relEditFile'] .
' updated ' . date(
'd-m-Y H:i:s') .
', bytes ' . strlen($mixedRec[$eFile[
'contentField']])
1574 public function checkValue($table, $field, $value, $id, $status, $realPid, $tscPID) {
1578 if (($table ===
'pages' || $table ===
'pages_language_overlay') && $field ===
'doktype') {
1582 $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']);
1585 if ($status ==
'update') {
1587 $onlyAllowedTables = isset(
$GLOBALS[
'PAGES_TYPES'][$value][
'onlyAllowedTables']) ?
$GLOBALS[
'PAGES_TYPES'][$value][
'onlyAllowedTables'] :
$GLOBALS[
'PAGES_TYPES'][
'default'][
'onlyAllowedTables'];
1588 if ($onlyAllowedTables) {
1590 if ($theWrongTables) {
1592 $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']);
1599 if ((
int)$id !== 0) {
1601 $curValueRec = $this->recordInfo($table, $id, $field);
1602 if (isset($curValueRec[$field])) {
1603 $curValue = $curValueRec[$field];
1607 $tcaFieldConf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
1608 $recFID = $table .
':' . $id .
':' . $field;
1610 $res = $this->
checkValue_SW($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $field, $this->uploadedFileArray[$table][$id][$field], $tscPID);
1634 public function checkValue_SW($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $field, $uploadedFiles, $tscPID, array $additionalData = NULL) {
1636 if ($value === NULL && !empty($tcaFieldConf[
'eval']) &&
GeneralUtility::inList($tcaFieldConf[
'eval'],
'null')) {
1637 $res = array(
'value' => NULL);
1641 $PP = array($table, $id, $curValue, $status, $realPid, $recFID, $tscPID);
1642 switch ($tcaFieldConf[
'type']) {
1644 $res = $this->
checkValue_text($res, $value, $tcaFieldConf, $PP, $field);
1649 $res[
'value'] = $value;
1666 $res = $this->
checkValue_inline($res, $value, $tcaFieldConf, $PP, $field, $additionalData);
1671 $res = $this->
checkValue_flex($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field);
1692 if (!isset($tcaFieldConf[
'eval']) || $tcaFieldConf[
'eval'] ===
'') {
1693 return array(
'value' => $value);
1696 if ($this->runtimeCache->has($cacheId)) {
1697 $evalCodesArray = $this->runtimeCache->get($cacheId);
1700 $this->runtimeCache->set($cacheId, $evalCodesArray);
1717 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
1719 $isDateOrDateTimeField = FALSE;
1720 if (isset($tcaFieldConf[
'dbType']) &&
GeneralUtility::inList(
'date,datetime', $tcaFieldConf[
'dbType'])) {
1721 if (empty($value)) {
1724 $isDateOrDateTimeField = TRUE;
1725 $dateTimeFormats =
$GLOBALS[
'TYPO3_DB']->getDateTimeFormats($table);
1727 $emptyValue = $dateTimeFormats[$tcaFieldConf[
'dbType']][
'empty'];
1728 $format = $dateTimeFormats[$tcaFieldConf[
'dbType']][
'format'];
1730 $timeZone = new \DateTimeZone(
'UTC');
1731 $dateTime = \DateTime::createFromFormat(
'!' . $format, $value, $timeZone);
1732 $value = $value === $emptyValue ? 0 : $dateTime->getTimestamp();
1736 if ((
int)$tcaFieldConf[
'max'] > 0) {
1737 $value =
$GLOBALS[
'LANG']->csConvObj->substr(
$GLOBALS[
'LANG']->charSet, $value, 0, (
int)$tcaFieldConf[
'max']);
1740 if ($tcaFieldConf[
'range'] && $value != $tcaFieldConf[
'checkbox'] && (
int)$value !== (
int)$tcaFieldConf[
'default']) {
1741 if (isset($tcaFieldConf[
'range'][
'upper']) && (
int)$value > (
int)$tcaFieldConf[
'range'][
'upper']) {
1742 $value = $tcaFieldConf[
'range'][
'upper'];
1744 if (isset($tcaFieldConf[
'range'][
'lower']) && (
int)$value < (
int)$tcaFieldConf[
'range'][
'lower']) {
1745 $value = $tcaFieldConf[
'range'][
'lower'];
1749 if (empty($tcaFieldConf[
'eval'])) {
1750 $res = array(
'value' => $value);
1754 if ($this->runtimeCache->has($cacheId)) {
1755 $evalCodesArray = $this->runtimeCache->get($cacheId);
1758 $this->runtimeCache->set($cacheId, $evalCodesArray);
1765 if ($field && $realPid >= 0 && !empty($res[
'value'])) {
1766 if (in_array(
'uniqueInPid', $evalCodesArray, TRUE)) {
1767 $res[
'value'] = $this->
getUnique($table, $field, $res[
'value'], $id, $realPid);
1769 if ($res[
'value'] && in_array(
'unique', $evalCodesArray, TRUE)) {
1770 $res[
'value'] = $this->
getUnique($table, $field, $res[
'value'], $id);
1776 if ($isDateOrDateTimeField) {
1778 $res[
'value'] = $res[
'value'] ? date($format, $res[
'value']) : $emptyValue;
1795 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
1796 $itemC = count($tcaFieldConf[
'items']);
1800 $maxV = pow(2, $itemC) - 1;
1804 if ($value > $maxV) {
1807 if ($field && $realPid >= 0 && $value > 0 && !empty($tcaFieldConf[
'eval'])) {
1809 $otherRecordsWithSameValue = array();
1810 $maxCheckedRecords = 0;
1811 if (in_array(
'maximumRecordsCheckedInPid', $evalCodesArray)) {
1813 $maxCheckedRecords = (int)$tcaFieldConf[
'validation'][
'maximumRecordsCheckedInPid'];
1815 if (in_array(
'maximumRecordsChecked', $evalCodesArray)) {
1817 $maxCheckedRecords = (int)$tcaFieldConf[
'validation'][
'maximumRecordsChecked'];
1822 if ($maxCheckedRecords && count($otherRecordsWithSameValue) >= $maxCheckedRecords) {
1824 $this->
log($table, $id, 5, 0, 1,
'Could not activate checkbox for field "%s". A total of %s record(s) can have this checkbox activated. Uncheck other records first in order to activate the checkbox of this record.', -1, array(
$GLOBALS[
'LANG']->sL(
BackendUtility::getItemLabel($table, $field)), $maxCheckedRecords));
1827 $res[
'value'] = $value;
1842 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
1843 if (is_array($tcaFieldConf[
'items'])) {
1844 foreach ($tcaFieldConf[
'items'] as $set) {
1845 if ((
string)$set[1] === (
string)$value) {
1846 $res[
'value'] = $value;
1867 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
1869 if (is_array($value)) {
1870 $value = implode(
',', $value);
1878 if (!$tcaFieldConf[
'multiple']) {
1879 $valueArray = array_unique($valueArray);
1882 if ($tcaFieldConf[
'type'] ==
'select' && $tcaFieldConf[
'exclusiveKeys']) {
1884 foreach ($valueArray as $kk => $vv) {
1886 if (in_array($vv, $exclusiveKeys)) {
1887 $valueArray = array($kk => $vv);
1896 if ($tcaFieldConf[
'type'] ==
'select' && $tcaFieldConf[
'authMode']) {
1897 $preCount = count($valueArray);
1898 foreach ($valueArray as $kk => $vv) {
1899 if (!$this->BE_USER->checkAuthMode($table, $field, $vv, $tcaFieldConf[
'authMode'])) {
1900 unset($valueArray[$kk]);
1904 if ($preCount && !count($valueArray)) {
1909 if ($tcaFieldConf[
'type'] ==
'group') {
1910 switch ($tcaFieldConf[
'internal_type']) {
1911 case 'file_reference':
1914 $valueArray = $this->checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue, $uploadedFiles, $status, $table, $id, $recFID);
1917 $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status,
'group', $table, $field);
1922 if ($tcaFieldConf[
'type'] ==
'select' && $tcaFieldConf[
'foreign_table']) {
1924 if (strpos($value,
'NEW') !== FALSE) {
1925 $this->remapStackRecords[$table][$id] = array(
'remapStackIndex' => count($this->remapStack));
1927 $this->remapStack[] = array(
1928 'func' =>
'checkValue_group_select_processDBdata',
1929 'args' => array($valueArray, $tcaFieldConf, $id, $status,
'select', $table, $field),
1930 'pos' => array(
'valueArray' => 0,
'tcaFieldConf' => 1,
'id' => 2,
'table' => 5),
1933 $unsetResult = TRUE;
1935 $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status,
'select', $table, $field);
1938 if (!$unsetResult) {
1940 $res[
'value'] = implode(
',', $newVal);
1942 unset($res[
'value']);
1956 if (empty($tcaFieldConfiguration[
'filter']) || !is_array($tcaFieldConfiguration[
'filter'])) {
1959 foreach ($tcaFieldConfiguration[
'filter'] as $filter) {
1960 if (empty($filter[
'userFunc'])) {
1965 $parameters[
'tcaFieldConfig'] = $tcaFieldConfiguration;
1967 if (!is_array($values)) {
1968 throw new \RuntimeException(
'Failed calling filter userFunc.', 1336051942);
1989 public function checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue,
$uploadedFileArray, $status, $table, $id, $recFID) {
1991 if (!$this->bypassFileHandling) {
2001 if (!empty($uploadedFileArray[
'name']) && $uploadedFileArray[
'tmp_name'] !==
'none') {
2002 $valueArray[] = $uploadedFileArray[
'tmp_name'];
2003 $this->alternativeFileName[$uploadedFileArray[
'tmp_name']] = $uploadedFileArray[
'name'];
2007 if (!$this->fileFunc) {
2009 $this->include_filefunctions = 1;
2012 $all_files = array();
2013 $all_files[
'webspace'][
'allow'] = $tcaFieldConf[
'allowed'];
2014 $all_files[
'webspace'][
'deny'] = $tcaFieldConf[
'disallowed'] ?:
'*';
2015 $all_files[
'ftpspace'] = $all_files[
'webspace'];
2016 $this->fileFunc->init(
'', $all_files);
2019 if ($tcaFieldConf[
'uploadfolder'] && $tcaFieldConf[
'internal_type'] ==
'file') {
2021 if (!$this->bypassFileHandling) {
2027 if ($status ==
'update') {
2037 if ($this->autoVersioningUpdate === TRUE) {
2038 foreach ($valueArray as $key => $theFile) {
2040 if ($theFile === basename($theFile)) {
2041 $valueArray[$key] = PATH_site . $tcaFieldConf[
'uploadfolder'] .
'/' . $theFile;
2046 $theFileValues = array();
2048 if ($tcaFieldConf[
'MM']) {
2051 $dbAnalysis->start(
'',
'files', $tcaFieldConf[
'MM'], $id);
2052 foreach ($dbAnalysis->itemArray as $item) {
2054 $theFileValues[] = $item[
'id'];
2060 $currentFilesForHistory = implode(
',', $theFileValues);
2062 if (count($theFileValues)) {
2064 foreach ($valueArray as $key => $theFile) {
2070 foreach ($theFileValues as $key => $theFile) {
2071 $theFile = trim($theFile);
2072 if (@is_file(($dest .
'/' . $theFile))) {
2073 $this->removeFilesStore[] = $dest .
'/' . $theFile;
2074 } elseif ($theFile) {
2075 $this->
log($table, $id, 5, 0, 1,
'Could not delete file \'%s\' (does not exist). (%s)', 10, array($dest .
'/' . $theFile, $recFID), $propArr[
'event_pid']);
2081 foreach ($valueArray as $key => $theFile) {
2083 $maxSize = (int)$tcaFieldConf[
'max_size'];
2090 $theFile = $fileObject->getForLocalProcessing(FALSE);
2097 if (@is_dir($dest) && (@is_file($theFile) || @is_uploaded_file($theFile))) {
2102 $fileSize = filesize($theFile);
2105 if (!$maxSize || $fileSize <= $maxSize * 1024) {
2107 $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
2110 if ($this->fileFunc->checkIfAllowed($fI[
'fileext'], $dest, $theEndFileName)) {
2111 $theDestFile = $this->fileFunc->getUniqueName($this->fileFunc->cleanFileName($fI[
'file']), $dest);
2116 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processUpload'])) {
2117 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processUpload'] as $classRef) {
2120 throw new \UnexpectedValueException(
'$hookObject must implement interface TYPO3\\CMS\\Core\\DataHandling\\DataHandlerProcessUploadHookInterface', 1279962349);
2122 $hookObject->processUpload_postProcessAction($theDestFile, $this);
2125 $this->copiedFileMap[$theFile] = $theDestFile;
2127 if (!@is_file($theDestFile)) {
2128 $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']);
2131 $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']);
2134 $this->
log($table, $id, 5, 0, 1,
'File extension \'%s\' not allowed. (%s)', 12, array($fI[
'fileext'], $recFID), $propArr[
'event_pid']);
2137 $this->
log($table, $id, 5, 0, 1,
'Filesize (%s) of file \'%s\' exceeds limit (%s). (%s)', 13, array(
GeneralUtility::formatSize($fileSize), $theFile,
GeneralUtility::formatSize($maxSize * 1024), $recFID), $propArr[
'event_pid']);
2140 $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']);
2144 if (@is_file($theDestFile)) {
2147 $valueArray[$key] = $info[
'file'];
2150 unset($valueArray[$key]);
2156 if ($tcaFieldConf[
'MM']) {
2160 $dbAnalysis->tableArray[
'files'] = array();
2161 foreach ($valueArray as $key => $theFile) {
2163 $dbAnalysis->itemArray[][
'id'] = $theFile;
2165 if ($status ==
'update') {
2166 $dbAnalysis->writeMM($tcaFieldConf[
'MM'], $id, 0);
2167 $newFiles = implode(
',', $dbAnalysis->getValueArray());
2168 list(, , $recFieldName) = explode(
':', $recFID);
2169 if ($currentFilesForHistory != $newFiles) {
2170 $this->mmHistoryRecords[$table .
':' . $id][
'oldRecord'][$recFieldName] = $currentFilesForHistory;
2171 $this->mmHistoryRecords[$table .
':' . $id][
'newRecord'][$recFieldName] = $newFiles;
2173 $this->mmHistoryRecords[$table .
':' . $id][
'oldRecord'][$recFieldName] =
'';
2174 $this->mmHistoryRecords[$table .
':' . $id][
'newRecord'][$recFieldName] =
'';
2177 $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf[
'MM'], $id, 0);
2179 $valueArray = $dbAnalysis->countItems();
2182 if (count($valueArray)) {
2184 if (!$this->bypassFileHandling) {
2187 foreach ($valueArray as &$theFile) {
2191 $theFile = $fileObject->getForLocalProcessing(FALSE);
2193 if ($this->alternativeFilePath[$theFile]) {
2196 if (@is_file((PATH_site . $this->alternativeFilePath[$theFile]))) {
2197 $theFile = PATH_site . $this->alternativeFilePath[$theFile];
2198 } elseif (@is_file($theFile)) {
2199 $dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]);
2200 if (!@is_dir($dest)) {
2204 $maxSize = (int)$tcaFieldConf[
'max_size'];
2208 $fileSize = filesize($theFile);
2210 if (!$maxSize || $fileSize <= $maxSize * 1024) {
2212 $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
2215 if ($this->fileFunc->checkIfAllowed($fI[
'fileext'], $dest, $theEndFileName)) {
2216 $theDestFile = PATH_site . $this->alternativeFilePath[$theFile];
2220 $this->copiedFileMap[$theFile] = $theDestFile;
2222 if (!@is_file($theDestFile)) {
2223 $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']);
2226 $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']);
2229 $this->
log($table, $id, 5, 0, 1,
'File extension \'%s\' not allowed. (%s)', 12, array($fI[
'fileext'], $recFID), $propArr[
'event_pid']);
2232 $this->
log($table, $id, 5, 0, 1,
'Filesize (%s) of file \'%s\' exceeds limit (%s). (%s)', 13, array(
GeneralUtility::formatSize($fileSize), $theFile,
GeneralUtility::formatSize($maxSize * 1024), $recFID), $propArr[
'event_pid']);
2235 if (@is_file($theDestFile)) {
2237 $theFile = $theDestFile;
2268 public function checkValue_flex($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field) {
2269 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
2271 if (is_array($value)) {
2274 $newRecordPidValue = $status ==
'new' ? $realPid : 0;
2278 if (!is_array($currentValueArray)) {
2279 $currentValueArray = array();
2281 if (isset($currentValueArray[
'meta'][
'currentLangId'])) {
2282 unset($currentValueArray[
'meta'][
'currentLangId']);
2286 $value[
'data'] = $this->
checkValue_flex_procInData($value[
'data'], $currentValueArray[
'data'], $uploadedFiles[
'data'], $dataStructArray, $PP);
2288 $xmlValue = $this->checkValue_flexArray2Xml($value, TRUE);
2293 $storeInCharset =
$GLOBALS[
'LANG']->charSet;
2296 if (is_array($currentValueArray)) {
2299 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkFlexFormValue'])) {
2300 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkFlexFormValue'] as $classRef) {
2302 if (method_exists($hookObject,
'checkFlexFormValue_beforeMerge')) {
2303 $hookObject->checkFlexFormValue_beforeMerge($this, $currentValueArray, $arrValue);
2309 $xmlValue = $this->checkValue_flexArray2Xml($currentValueArray, TRUE);
2313 if (is_array($actionCMDs[$table][$id][$field][
'data'])) {
2316 $xmlValue = $this->checkValue_flexArray2Xml($arrValue, TRUE);
2320 $res[
'value'] .= $xmlValue;
2323 $res[
'value'] = $value;
2337 public function checkValue_flexArray2Xml($array, $addPrologue = FALSE) {
2340 return $flexObj->flexArray2Xml($array, $addPrologue);
2352 if (is_array($valueArray) && is_array($actionCMDs)) {
2353 foreach ($actionCMDs as $key => $value) {
2354 if ($key ==
'_ACTION') {
2356 if (current($actionCMDs[$key]) !==
'') {
2357 asort($actionCMDs[$key]);
2358 $newValueArray = array();
2359 foreach ($actionCMDs[$key] as $idx => $order) {
2360 if (substr($idx, 0, 3) ==
'ID-') {
2361 $idx = $this->newIndexMap[$idx];
2364 if ($order !=
'DELETE') {
2365 $newValueArray[$idx] = $valueArray[$idx];
2367 unset($valueArray[$idx]);
2371 } elseif (is_array($actionCMDs[$key]) && isset($valueArray[$key])) {
2391 public function checkValue_inline($res, $value, $tcaFieldConf, $PP, $field, array $additionalData = NULL) {
2392 list($table, $id, $curValue, $status, $realPid, $recFID) = $PP;
2393 if (!$tcaFieldConf[
'foreign_table']) {
2400 $valueArray = array_unique($valueArray);
2405 $this->remapStackRecords[$table][$id] = array(
'remapStackIndex' => count($this->remapStack));
2407 $this->remapStack[] = array(
2408 'func' =>
'checkValue_inline_processDBdata',
2409 'args' => array($valueArray, $tcaFieldConf, $id, $status, $table, $field, $additionalData),
2410 'pos' => array(
'valueArray' => 0,
'tcaFieldConf' => 1,
'id' => 2,
'table' => 4),
2411 'additionalData' => $additionalData,
2414 unset($res[
'value']);
2416 $res[
'value'] = $this->checkValue_inline_processDBdata($valueArray, $tcaFieldConf, $id, $status, $table, $field, $additionalData);
2432 $valueArrayC = count($valueArray);
2434 $maxI = isset($tcaFieldConf[
'maxitems']) ? (int)$tcaFieldConf[
'maxitems'] : 1;
2435 if ($valueArrayC > $maxI) {
2436 $valueArrayC = $maxI;
2441 foreach ($valueArray as $nextVal) {
2442 if ($valueArrayC == 0) {
2446 $newVal[] = $nextVal;
2467 public function getUnique($table, $field, $value, $id, $newPid = 0) {
2472 $whereAdd .=
' AND pid=' . (int)$newPid;
2474 $whereAdd .=
' AND pid>=0';
2479 if (is_array(
$GLOBALS[
'TCA'][$table]) && is_array(
$GLOBALS[
'TCA'][$table][
'columns'][$field])) {
2481 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid', $table, $field .
'=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($value, $table) .
' AND uid<>' . (
int)$id . $whereAdd);
2484 while (
$GLOBALS[
'TYPO3_DB']->sql_num_rows($res)) {
2485 $newValue = $value . $counter;
2486 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid', $table, $field .
'=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($newValue, $table) .
' AND uid<>' . (
int)$id . $whereAdd);
2488 if ($counter > 100) {
2492 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
2494 $value = strlen($newValue) ? $newValue : $value;
2512 if (!empty(
$GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName])) {
2515 $pageId = (int)$pageId;
2516 $whereStatement =
' AND uid <> ' .
$uid .
' AND ' . ($pageId ?
'pid = ' . $pageId :
'pid >= 0');
2533 foreach ($evalArray as $func) {
2536 $value = trim($value);
2544 if (empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tce'][
'formevals'][$func])) {
2548 if (is_object($evalObj) && method_exists($evalObj,
'evaluateFieldValue')) {
2549 $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
2554 $res[
'value'] = $value;
2572 foreach ($evalArray as $func) {
2581 $value = (int)$value;
2586 $value = (int)$value;
2587 if ($value > 0 && !$this->dontProcessTransformations) {
2588 $value -= date(
'Z', $value);
2592 $value = preg_replace(
'/[^0-9,\\.-]/',
'', $value);
2593 $negative = $value[0] ===
'-';
2594 $value = strtr($value, array(
',' =>
'.',
'-' =>
''));
2595 if (strpos($value,
'.') === FALSE) {
2598 $valueArray = explode(
'.', $value);
2599 $dec = array_pop($valueArray);
2600 $value = join(
'', $valueArray) .
'.' . $dec;
2604 $value = number_format($value, 2,
'.',
'');
2607 if (strlen($value) != 32) {
2612 $value = trim($value);
2615 $value =
$GLOBALS[
'LANG']->csConvObj->conv_case(
$GLOBALS[
'LANG']->charSet, $value,
'toUpper');
2618 $value =
$GLOBALS[
'LANG']->csConvObj->conv_case(
$GLOBALS[
'LANG']->charSet, $value,
'toLower');
2621 if (!isset($value) || $value ===
'') {
2626 $c = strlen($value);
2629 for ($a = 0; $a < $c; $a++) {
2630 $char = substr($value, $a, 1);
2631 if (strpos($is_in, $char) !== FALSE) {
2639 $value = str_replace(
' ',
'', $value);
2642 $value = preg_replace(
'/[^a-zA-Z]/',
'', $value);
2645 $value = preg_replace(
'/[^0-9]/',
'', $value);
2648 $value = preg_replace(
'/[^a-zA-Z0-9]/',
'', $value);
2651 $value = preg_replace(
'/[^a-zA-Z0-9_-]/',
'', $value);
2654 if (!preg_match(
'/^[a-z0-9.\\-]*$/i', $value)) {
2659 if (empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tce'][
'formevals'][$func])) {
2663 if (is_object($evalObj) && method_exists($evalObj,
'evaluateFieldValue')) {
2664 $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
2669 $res[
'value'] = $value;
2687 public function checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, $type, $currentTable, $currentField) {
2688 $tables = $type ==
'group' ? $tcaFieldConf[
'allowed'] : $tcaFieldConf[
'foreign_table'] .
',' . $tcaFieldConf[
'neg_foreign_table'];
2689 $prep = $type ==
'group' ? $tcaFieldConf[
'prepend_tname'] : $tcaFieldConf[
'neg_foreign_table'];
2690 $newRelations = implode(
',', $valueArray);
2693 $dbAnalysis->registerNonTableValues = $tcaFieldConf[
'allowNonIdValues'] ? 1 : 0;
2694 $dbAnalysis->start($newRelations, $tables,
'', 0, $currentTable, $tcaFieldConf);
2695 if ($tcaFieldConf[
'MM']) {
2696 if ($status ==
'update') {
2699 $oldRelations_dbAnalysis->registerNonTableValues = $tcaFieldConf[
'allowNonIdValues'] ? 1 : 0;
2701 $oldRelations_dbAnalysis->start(
'', $tables, $tcaFieldConf[
'MM'], $id, $currentTable, $tcaFieldConf);
2702 $oldRelations = implode(
',', $oldRelations_dbAnalysis->getValueArray());
2703 $dbAnalysis->writeMM($tcaFieldConf[
'MM'], $id, $prep);
2704 if ($oldRelations != $newRelations) {
2705 $this->mmHistoryRecords[$currentTable .
':' . $id][
'oldRecord'][$currentField] = $oldRelations;
2706 $this->mmHistoryRecords[$currentTable .
':' . $id][
'newRecord'][$currentField] = $newRelations;
2708 $this->mmHistoryRecords[$currentTable .
':' . $id][
'oldRecord'][$currentField] =
'';
2709 $this->mmHistoryRecords[$currentTable .
':' . $id][
'newRecord'][$currentField] =
'';
2712 $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf[
'MM'], $id, $prep, $currentTable);
2714 $valueArray = $dbAnalysis->countItems();
2716 $valueArray = $dbAnalysis->getValueArray($prep);
2717 if ($type ==
'select' && $prep) {
2718 $valueArray = $dbAnalysis->convertPosNeg($valueArray, $tcaFieldConf[
'foreign_table'], $tcaFieldConf[
'neg_foreign_table']);
2734 foreach ($valueArray as &$newVal) {
2735 $temp = explode(
'|', $newVal, 2);
2736 $newVal = str_replace(
',',
'', str_replace(
'|',
'', rawurldecode($temp[0])));
2758 public function checkValue_flex_procInData($dataPart, $dataPart_current, $uploadedFiles, $dataStructArray, $pParams, $callBackFunc =
'', $workspaceOptions = array()) {
2759 if (is_array($dataPart)) {
2760 foreach ($dataPart as $sKey => $sheetDef) {
2762 if (is_array($dataStruct) && $actualSheet == $sKey && is_array($sheetDef)) {
2763 foreach ($sheetDef as $lKey => $lData) {
2764 $this->
checkValue_flex_procInData_travDS($dataPart[$sKey][$lKey], $dataPart_current[$sKey][$lKey], $uploadedFiles[$sKey][$lKey], $dataStruct[
'ROOT'][
'el'], $pParams, $callBackFunc, $sKey .
'/' . $lKey .
'/', $workspaceOptions);
2788 public function checkValue_flex_procInData_travDS(&$dataValues, $dataValues_current, $uploadedFiles, $DSelements, $pParams, $callBackFunc, $structurePath, $workspaceOptions = array()) {
2789 if (is_array($DSelements)) {
2791 foreach ($DSelements as $key => $dsConf) {
2793 if ($DSelements[$key][
'type'] ==
'array') {
2794 if (is_array($dataValues[$key][
'el'])) {
2795 if ($DSelements[$key][
'section']) {
2796 $newIndexCounter = 0;
2797 foreach ($dataValues[$key][
'el'] as $ik => $el) {
2798 if (is_array($el)) {
2799 if (!is_array($dataValues_current[$key][
'el'])) {
2800 $dataValues_current[$key][
'el'] = array();
2803 if (is_array($dataValues[$key][
'el'][$ik][$theKey][
'el'])) {
2804 $this->
checkValue_flex_procInData_travDS($dataValues[$key][
'el'][$ik][$theKey][
'el'], is_array($dataValues_current[$key][
'el'][$ik]) ? $dataValues_current[$key][
'el'][$ik][$theKey][
'el'] : array(), $uploadedFiles[$key][
'el'][$ik][$theKey][
'el'], $DSelements[$key][
'el'][$theKey][
'el'], $pParams, $callBackFunc, $structurePath . $key .
'/el/' . $ik .
'/' . $theKey .
'/el/', $workspaceOptions);
2807 if (substr($ik, 0, 3) ==
'ID-') {
2810 $this->newIndexMap[$ik] = (is_array($dataValues_current[$key][
'el']) && count($dataValues_current[$key][
'el']) ? max(array_keys($dataValues_current[$key][
'el'])) : 0) + $newIndexCounter;
2812 $dataValues[$key][
'el'][$this->newIndexMap[$ik]] = $dataValues[$key][
'el'][$ik];
2814 unset($dataValues[$key][
'el'][$ik]);
2820 if (!isset($dataValues[$key][
'el'])) {
2821 $dataValues[$key][
'el'] = array();
2823 $this->
checkValue_flex_procInData_travDS($dataValues[$key][
'el'], $dataValues_current[$key][
'el'], $uploadedFiles[$key][
'el'], $DSelements[$key][
'el'], $pParams, $callBackFunc, $structurePath . $key .
'/el/', $workspaceOptions);
2827 if (is_array($dsConf[
'TCEforms'][
'config']) && is_array($dataValues[$key])) {
2828 foreach ($dataValues[$key] as $vKey => $data) {
2829 if ($callBackFunc) {
2830 if (is_object($this->callBackObj)) {
2831 $res = $this->callBackObj->{$callBackFunc}($pParams, $dsConf[
'TCEforms'][
'config'], $dataValues[$key][$vKey], $dataValues_current[$key][$vKey], $uploadedFiles[$key][$vKey], $structurePath . $key .
'/' . $vKey .
'/', $workspaceOptions);
2833 $res = $this->{$callBackFunc}($pParams, $dsConf[
'TCEforms'][
'config'], $dataValues[$key][$vKey], $dataValues_current[$key][$vKey], $uploadedFiles[$key][$vKey], $structurePath . $key .
'/' . $vKey .
'/', $workspaceOptions);
2837 list($CVtable, $CVid, $CVcurValue, $CVstatus, $CVrealPid, $CVrecFID, $CVtscPID) = $pParams;
2839 $additionalData = array(
2840 'flexFormId' => $CVrecFID,
2841 'flexFormPath' => trim(rtrim($structurePath,
'/') .
'/' . $key .
'/' . $vKey,
'/'),
2844 $res = $this->
checkValue_SW(array(), $dataValues[$key][$vKey], $dsConf[
'TCEforms'][
'config'], $CVtable, $CVid, $dataValues_current[$key][$vKey], $CVstatus, $CVrealPid, $CVrecFID,
'', $uploadedFiles[$key][$vKey], $CVtscPID, $additionalData);
2846 if ($dataValues[$key][
'_TRANSFORM_' . $vKey] ==
'RTE' && !$this->dontProcessTransformations) {
2848 unset($dataValues[$key][
'_TRANSFORM_' . $vKey]);
2849 if (isset($res[
'value'])) {
2851 list(, , $recFieldName) = explode(
':', $CVrecFID);
2859 if (is_object($RTEobj)) {
2860 $res[
'value'] = $RTEobj->transformContent(
'db', $res[
'value'], $CVtable, $recFieldName, $this->checkValue_currentRecord, $specConf, $thisConfig,
'', $CVrealPid);
2862 debug(
'NO RTE OBJECT FOUND!');
2868 if (isset($res[
'value'])) {
2869 $dataValues[$key][$vKey] = $res[
'value'];
2873 if (substr($vKey, -9) !=
'.vDEFbase') {
2874 if ($this->clear_flexFormData_vDEFbase) {
2875 $dataValues[$key][$vKey .
'.vDEFbase'] =
'';
2876 } elseif ($this->updateModeL10NdiffData &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'flexFormXMLincludeDiffBase'] && $vKey !==
'vDEF' && ((
string)$dataValues[$key][$vKey] !== (
string)$dataValues_current[$key][$vKey] || !isset($dataValues_current[$key][($vKey .
'.vDEFbase')]) || $this->updateModeL10NdiffData ===
'FORCE_FFUPD')) {
2878 if (isset($dataValues[$key][
'vDEF'])) {
2879 $diffValue = $dataValues[$key][
'vDEF'];
2882 $diffValue = $dataValues_current[$key][
'vDEF'];
2885 $dataValues[$key][$vKey .
'.vDEFbase'] = $this->updateModeL10NdiffDataClear ?
'' : $diffValue;
2907 protected function checkValue_inline_processDBdata($valueArray, $tcaFieldConf, $id, $status, $table, $field, array $additionalData = NULL) {
2909 $foreignTable = $tcaFieldConf[
'foreign_table'];
2914 $dbAnalysis->start(implode(
',', $valueArray), $foreignTable,
'', 0, $table, $tcaFieldConf);
2917 if ($localizationMode ==
'keep' && $status ==
'update') {
2920 if (is_array($row)) {
2921 $language = (int)$row[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']];
2922 $transOrigPointer = (int)$row[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']];
2924 if ($language > 0 && $transOrigPointer) {
2925 $id = $transOrigPointer;
2928 $keepTranslation = TRUE;
2933 if ($tcaFieldConf[
'foreign_field']) {
2935 $skipSorting = $this->callFromImpExp ? TRUE : FALSE;
2937 $dbAnalysis->writeForeignField($tcaFieldConf, $id, 0, $skipSorting);
2938 $newValue = $keepTranslation ? 0 : $dbAnalysis->countItems(FALSE);
2942 $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status,
'select', $table, $field);
2943 $newValue = $keepTranslation ? 0 : $valueArray[0];
2945 $valueArray = $dbAnalysis->getValueArray();
2949 if ($keepTranslation) {
2950 $this->
updateDB($table, $transOrigPointer, array($field => implode(
',', $valueArray)));
2952 $newValue = implode(
',', $valueArray);
2970 public function process_cmdmap() {
2972 if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec[
'freeze']) {
2973 $this->
newlog(
'All editing in this workspace has been frozen!', 1);
2977 $hookObjectsArr = array();
2978 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processCmdmapClass'])) {
2979 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processCmdmapClass'] as $classRef) {
2981 if (method_exists($hookObj,
'processCmdmap_beforeStart')) {
2982 $hookObj->processCmdmap_beforeStart($this);
2984 $hookObjectsArr[] = $hookObj;
2987 $pasteDatamap = array();
2989 foreach ($this->cmdmap as $table => $_) {
2991 $modifyAccessList = $this->checkModifyAccessList($table);
2992 if (!$modifyAccessList) {
2994 $this->
log($table, $id, 2, 0, 1,
'Attempt to modify table \'%s\' without permission', 1, array($table));
2998 if (isset(
$GLOBALS[
'TCA'][$table]) && !$this->
tableReadOnly($table) && is_array($this->cmdmap[$table]) && $modifyAccessList) {
3000 foreach ($this->cmdmap[$table] as $id => $incomingCmdArray) {
3001 if (!is_array($incomingCmdArray)) {
3004 foreach ($incomingCmdArray as $command => $value) {
3005 $pasteUpdate = FALSE;
3006 if (is_array($value) && isset($value[
'action']) && $value[
'action'] ===
'paste') {
3010 $pasteUpdate = $value[
'update'];
3011 $value = $value[
'target'];
3013 foreach ($hookObjectsArr as $hookObj) {
3014 if (method_exists($hookObj,
'processCmdmap_preProcess')) {
3015 $hookObj->processCmdmap_preProcess($command, $table, $id, $value, $this, $pasteUpdate);
3021 $this->copyMappingArray = array();
3023 $commandIsProcessed = FALSE;
3024 foreach ($hookObjectsArr as $hookObj) {
3025 if (method_exists($hookObj,
'processCmdmap')) {
3026 $hookObj->processCmdmap($command, $table, $id, $value, $commandIsProcessed, $this, $pasteUpdate);
3030 if (!$commandIsProcessed) {
3038 if ($table ===
'pages') {
3041 $this->copyRecord($table, $id, $value, 1);
3043 $procId = $this->copyMappingArray[$table][$id];
3046 $this->localize($table, $id, $value);
3048 case 'inlineLocalizeSynchronize':
3049 $this->inlineLocalizeSynchronize($table, $id, $value);
3058 if (is_array($pasteUpdate)) {
3059 $pasteDatamap[$table][$procId] = $pasteUpdate;
3062 foreach ($hookObjectsArr as $hookObj) {
3063 if (method_exists($hookObj,
'processCmdmap_postProcess')) {
3064 $hookObj->processCmdmap_postProcess($command, $table, $id, $value, $this, $pasteUpdate, $pasteDatamap);
3075 $copyTCE->start($pasteDatamap,
'', $this->BE_USER);
3076 $copyTCE->process_datamap();
3077 $this->errorLog = array_merge($this->errorLog, $copyTCE->errorLog);
3084 foreach ($hookObjectsArr as $hookObj) {
3085 if (method_exists($hookObj,
'processCmdmap_afterFinish')) {
3086 $hookObj->processCmdmap_afterFinish($this);
3090 $this->processClearCacheQueue();
3112 public function copyRecord($table,
$uid, $destPid, $first = 0,
$overrideValues = array(), $excludeFields =
'', $language = 0) {
3123 $fullLanguageCheckNeeded = $table !=
'pages';
3125 if ($language > 0 && $this->BE_USER->checkLanguageAccess($language) || $this->BE_USER->recordEditAccessInternals($table,
$uid, FALSE, FALSE, $fullLanguageCheckNeeded)) {
3127 $nonFields = array_unique(
GeneralUtility::trimExplode(
',',
'uid,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,t3ver_oid,t3ver_wsid,t3ver_id,t3ver_label,t3ver_state,t3ver_count,t3ver_stage,t3ver_tstamp,' . $excludeFields, TRUE));
3130 if (is_array($row)) {
3132 $theNewID = uniqid(
'NEW', TRUE);
3133 $enableField = isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns']) ?
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled'] :
'';
3134 $headerField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'label'];
3145 foreach ($row as $field => $value) {
3146 if (!in_array($field, $nonFields)) {
3148 $conf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
3151 if ($field ==
'pid') {
3156 } elseif (isset($copyAfterFields[$field])) {
3158 $value = $copyAfterFields[$field];
3160 $value = $defaultData[$field];
3163 if ($first && $field == $enableField &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'hideAtCopy'] && !$this->neverHideAtCopy && !$tE[
'disableHideAtCopy']) {
3167 if ($first && $field == $headerField &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'prependAtCopy'] && !$tE[
'disablePrependAtCopy']) {
3171 $value = $this->copyRecord_procBasedOnFieldType($table,
$uid, $field, $value, $row, $conf, $tscPID, $language);
3174 $data[$table][$theNewID][$field] = $value;
3178 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']) {
3179 $data[$table][$theNewID][
$GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']] = 0;
3182 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'origUid']) {
3183 $data[$table][$theNewID][
$GLOBALS[
'TCA'][$table][
'ctrl'][
'origUid']] =
$uid;
3188 $copyTCE->start($data,
'', $this->BE_USER);
3189 $copyTCE->process_datamap();
3191 $theNewSQLID = $copyTCE->substNEWwithIDs[$theNewID];
3194 $this->copyMappingArray[$table][$origUid] = $theNewSQLID;
3196 if (isset($copyTCE->autoVersionIdMap[$table][$theNewSQLID])) {
3197 $this->autoVersionIdMap[$table][$theNewSQLID] = $copyTCE->autoVersionIdMap[$table][$theNewSQLID];
3201 $this->cachedTSconfig = $copyTCE->cachedTSconfig;
3202 $this->errorLog = array_merge($this->errorLog, $copyTCE->errorLog);
3204 if ($language == 0) {
3209 return $theNewSQLID;
3211 $this->
log($table,
$uid, 3, 0, 1,
'Attempt to copy record that did not exist!');
3214 $this->
log($table,
$uid, 3, 0, 1,
'Attempt to copy record without having permissions to do so. [' . $this->BE_USER->errorMsg .
'].');
3217 $this->
log($table,
$uid, 3, 0, 1,
'Attempt to insert record on a page that can\'t store record type.');
3220 $this->
log($table,
$uid, 3, 0, 1,
'Attempt to copy record without permission');
3223 $this->
log($table,
$uid, 5, 0, 1,
'Repeated attemp to copy record "' . $table .
':' .
$uid .
'" with override values');
3239 $destPid = (int)$destPid;
3242 $copyTablesArray = $this->admin ? $this->
compileAdminTables() : explode(
',', $this->BE_USER->groupData[
'tables_modify']);
3244 if (!strstr($this->copyWhichTables,
'*')) {
3245 foreach ($copyTablesArray as $k => $table) {
3248 unset($copyTablesArray[$k]);
3252 $copyTablesArray = array_unique($copyTablesArray);
3254 if ($this->admin || in_array(
'pages', $copyTablesArray)) {
3258 if ($theNewRootID && $this->copyTree) {
3262 foreach ($CPtable as $thePageUid => $thePagePid) {
3263 $newPid = $this->copyMappingArray[
'pages'][$thePagePid];
3264 if (isset($newPid)) {
3267 $this->
log(
'pages',
$uid, 5, 0, 1,
'Something went wrong during copying branch');
3273 $this->
log(
'pages',
$uid, 5, 0, 1,
'Attempt to copy page without permission to this table');
3289 $theNewRootID = $this->copyRecord(
'pages',
$uid, $destPid, $first);
3291 if ($theNewRootID) {
3292 foreach ($copyTablesArray as $table) {
3294 if ($table && is_array(
$GLOBALS[
'TCA'][$table]) && $table !=
'pages') {
3296 $languageField = NULL;
3297 $transOrigPointerField = NULL;
3299 $languageField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'];
3300 $transOrigPointerField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'];
3301 $fields .=
',' . $languageField .
',' . $transOrigPointerField;
3304 $workspaceStatement =
'';
3305 } elseif ((
int)$this->BE_USER->workspace === 0) {
3306 $workspaceStatement =
' AND t3ver_wsid=0';
3308 $workspaceStatement =
' AND t3ver_wsid IN (0,' . (int)$this->BE_USER->workspace .
')';
3310 $rows =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
3315 (!empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']) ?
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'] .
' DESC' :
''),
3321 $rows = array_reverse(
3322 $this->resolveVersionedRecords(
3325 $GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'],
3332 foreach ($rows as $row) {
3335 $transOrigPointer = $row[$transOrigPointerField];
3336 if ($row[$languageField] > 0 && $transOrigPointer > 0 && isset($rows[$transOrigPointer])) {
3340 $this->copyRecord($table, $row[
'uid'], $theNewRootID);
3344 return $theNewRootID;
3364 public function copyRecord_raw($table,
$uid, $pid, $overrideArray = array(), array $workspaceOptions = array()) {
3375 $nonFields = array(
'uid',
'pid',
't3ver_id',
't3ver_oid',
't3ver_wsid',
't3ver_label',
't3ver_state',
't3ver_count',
't3ver_stage',
't3ver_tstamp',
'perms_userid',
'perms_groupid',
'perms_user',
'perms_group',
'perms_everybody');
3377 $row = $this->recordInfo($table,
$uid,
'*');
3378 if (is_array($row)) {
3380 $row = array_merge($row, $overrideArray);
3382 foreach ($row as $field => $value) {
3383 if (!in_array($field, $nonFields)) {
3385 $conf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
3386 if (is_array($conf)) {
3388 $value = $this->copyRecord_procBasedOnFieldType($table,
$uid, $field, $value, $row, $conf, $pid, 0, $workspaceOptions);
3391 $row[$field] = $value;
3397 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'origUid']) {
3398 $row[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'origUid']] =
$uid;
3404 $this->dbAnalysisStore = array();
3406 return $this->copyMappingArray[$table][
$uid] = $theNewSQLID;
3409 $this->
log($table,
$uid, 3, 0, 1,
'Attempt to rawcopy/versionize record that did not exist!');
3412 $this->
log($table,
$uid, 3, 0, 1,
'Attempt to rawcopy/versionize record without copy permission');
3428 $id = uniqid(
'NEW', TRUE);
3431 $this->checkValue_currentRecord = $fieldArray;
3434 $this->dontProcessTransformations = TRUE;
3436 foreach ($fieldArray as $field => $fieldValue) {
3437 if (isset(
$GLOBALS[
'TCA'][$table][
'columns'][$field])) {
3439 $res = $this->
checkValue($table, $field, $fieldValue, $id,
'new', $realPid, 0);
3440 if (isset($res[
'value'])) {
3441 $fieldArray[$field] = $res[
'value'];
3446 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'crdate']) {
3447 $fieldArray[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'crdate']] = $GLOBALS[
'EXEC_TIME'];
3449 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'cruser_id']) {
3452 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']) {
3453 $fieldArray[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']] = $GLOBALS[
'EXEC_TIME'];
3456 $this->
insertDB($table, $id, $fieldArray, TRUE);
3458 $this->dontProcessTransformations = $backupDontProcessTransformations;
3460 return $this->substNEWwithIDs[$id];
3479 public function copyRecord_procBasedOnFieldType($table,
$uid, $field, $value, $row, $conf, $realDestPid, $language = 0, array $workspaceOptions = array()) {
3481 $value = $this->copyRecord_procFilesRefs($conf,
$uid, $value);
3487 $allowedTables = $conf[
'type'] ==
'group' ? $conf[
'allowed'] : $conf[
'foreign_table'] .
',' . $conf[
'neg_foreign_table'];
3488 $prependName = $conf[
'type'] ==
'group' ? $conf[
'prepend_tname'] : $conf[
'neg_foreign_table'];
3489 $mmTable = isset($conf[
'MM']) && $conf[
'MM'] ? $conf[
'MM'] :
'';
3491 $localizeReferences = $localizeForeignTable && isset($conf[
'localizeReferencesAtParentLocalization']) && $conf[
'localizeReferencesAtParentLocalization'];
3492 $localizeChildren = $localizeForeignTable && isset($conf[
'behaviour'][
'localizeChildrenAtParentLocalization']) && $conf[
'behaviour'][
'localizeChildrenAtParentLocalization'];
3495 $dbAnalysis->start($value, $allowedTables, $mmTable,
$uid, $table, $conf);
3497 if ($language > 0 && ($localizeReferences && empty($mmTable) || $localizeChildren && $localizationMode ===
'select' && $inlineSubType ===
'mm')) {
3498 foreach ($dbAnalysis->itemArray as $index => $item) {
3501 if ($recordLocalization) {
3502 $dbAnalysis->itemArray[$index][
'id'] = $recordLocalization[0][
'uid'];
3504 $dbAnalysis->itemArray[$index][
'id'] = $this->localize($item[
'table'], $item[
'id'], $language);
3507 $dbAnalysis->purgeItemArray();
3508 $value = implode(
',', $dbAnalysis->getValueArray($prependName));
3509 } elseif ($language > 0 && $localizeChildren === FALSE && $localizationMode ===
'select' && $inlineSubType ===
'mm') {
3510 foreach ($dbAnalysis->itemArray as $index => $item) {
3513 if ($recordLocalization) {
3514 $dbAnalysis->itemArray[$index][
'id'] = $recordLocalization[0][
'uid'];
3516 unset($dbAnalysis->itemArray[$index]);
3519 $dbAnalysis->purgeItemArray();
3520 $value = implode(
',', $dbAnalysis->getValueArray($prependName));
3521 } elseif ($mmTable) {
3522 $dbAnalysis->purgeItemArray();
3523 $value = implode(
',', $dbAnalysis->getValueArray($prependName));
3527 $this->registerDBList[$table][
$uid][$field] = $value;
3529 } elseif ($inlineSubType !== FALSE) {
3531 if ($language > 0 && $localizationMode ==
'keep') {
3532 $value = $inlineSubType ==
'field' ? 0 :
'';
3537 $dbAnalysis->start($value, $conf[
'foreign_table'],
'',
$uid, $table, $conf);
3539 foreach ($dbAnalysis->itemArray as $k => $v) {
3543 if ($localizationMode != FALSE && isset($conf[
'behaviour'][
'localizeChildrenAtParentLocalization']) && $conf[
'behaviour'][
'localizeChildrenAtParentLocalization']) {
3544 $newId = $this->localize($v[
'table'], $v[
'id'], $language);
3548 $newId = $this->copyRecord($v[
'table'], $v[
'id'], -$v[
'id']);
3553 if (count($workspaceOptions)) {
3558 $v[
'table'], $v[
'id'],
3559 (isset($workspaceOptions[
'label']) ? $workspaceOptions[
'label'] :
'Auto-created for WS #' . $this->BE_USER->workspace),
3560 (isset($workspaceOptions[
'delete']) ? $workspaceOptions[
'delete'] : FALSE)
3566 if (isset($this->copyMappingArray[$v[
'table']][$v[
'id']])) {
3567 $newId = $this->copyMappingArray[$v[
'table']][$v[
'id']];
3569 $newId = $this->copyRecord($v[
'table'], $v[
'id'], $realDestPid);
3575 if (isset($this->copyMappingArray[$v[
'table']][$v[
'id']])) {
3576 $newId = $this->copyMappingArray[$v[
'table']][$v[
'id']];
3578 $newId = $this->
copyRecord_raw($v[
'table'], $v[
'id'], $realDestPid, array(), $workspaceOptions);
3583 if ($table ==
'pages') {
3584 $this->registerDBPids[$v[
'table']][$v[
'id']] =
$uid;
3585 } elseif (isset($this->registerDBPids[$table][
$uid])) {
3586 $this->registerDBPids[$v[
'table']][$v[
'id']] = $this->registerDBPids[$table][
$uid];
3588 $dbAnalysis->itemArray[$k][
'id'] = $newId;
3591 $value = implode(
',', $dbAnalysis->getValueArray());
3592 $this->registerDBList[$table][
$uid][$field] = $value;
3596 if ($conf[
'type'] ==
'flex') {
3601 if (is_array($currentValueArray)) {
3602 $currentValueArray[
'data'] = $this->
checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table,
$uid, $field, $realDestPid),
'copyRecord_flexFormCallBack', $workspaceOptions);
3604 $value = $currentValueArray;
3626 list($table,
$uid, $field, $realDestPid) = $pParams;
3628 $dataValue = $this->copyRecord_procFilesRefs($dsConf,
$uid, $dataValue);
3631 $dataValue = $this->copyRecord_procBasedOnFieldType($table,
$uid, $field, $dataValue, array(), $dsConf, $realDestPid, 0, $workspaceOptions);
3632 $this->registerDBList[$table][
$uid][$field] =
'FlexForm_reference';
3635 return array(
'value' => $dataValue);
3650 public function copyRecord_procFilesRefs($conf,
$uid, $value) {
3652 if ($conf[
'type'] ==
'group' && ($conf[
'internal_type'] ==
'file' || $conf[
'internal_type'] ==
'file_reference')) {
3655 $theFileValues = array();
3658 $dbAnalysis->start(
'',
'files', $conf[
'MM'],
$uid);
3659 foreach ($dbAnalysis->itemArray as $somekey => $someval) {
3660 if ($someval[
'id']) {
3661 $theFileValues[] = $someval[
'id'];
3668 $uploadFolder = $conf[
'internal_type'] ==
'file' ? $conf[
'uploadfolder'] :
'';
3670 $newValue = array();
3671 foreach ($theFileValues as $file) {
3673 $realFile = str_replace(
'//',
'/', $dest .
'/' . trim($file));
3674 if (@is_file($realFile)) {
3675 $newValue[] = $realFile;
3680 $value = implode(
',', $newValue);
3698 if (!$this->fileFunc) {
3700 $this->include_filefunctions = 1;
3703 $recs =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'*',
'sys_refindex',
'ref_table=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr(
'_FILE',
'sys_refindex') .
' AND ref_string LIKE ' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr(
'%/RTEmagic%',
'sys_refindex') .
' AND softref_key=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr(
'images',
'sys_refindex') .
' AND tablename=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($table,
'sys_refindex') .
' AND recuid=' . (
int)$theNewSQLID,
'',
'sorting DESC');
3705 if (is_array($recs)) {
3706 foreach ($recs as $rec) {
3707 $filename = basename($rec[
'ref_string']);
3708 $fileInfo = array();
3710 $fileInfo[
'exists'] = @is_file((PATH_site . $rec[
'ref_string']));
3711 $fileInfo[
'original'] = substr($rec[
'ref_string'], 0, -strlen($filename)) .
'RTEmagicP_' . preg_replace(
'/\\.[[:alnum:]]+$/',
'', substr($filename, 10));
3712 $fileInfo[
'original_exists'] = @is_file((PATH_site . $fileInfo[
'original']));
3714 if ($fileInfo[
'exists'] && $fileInfo[
'original_exists']) {
3716 $dirPrefix = dirname($rec[
'ref_string']) .
'/';
3717 $rteOrigName = basename($fileInfo[
'original']);
3722 $origDestName = $this->fileFunc->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
3724 $pI = pathinfo($rec[
'ref_string']);
3725 $copyDestName = dirname($origDestName) .
'/RTEmagicC_' . substr(basename($origDestName), 10) .
'.' . $pI[
'extension'];
3734 if (@is_file($copyDestName)) {
3736 $error = $sysRefObj->setReferenceValue($rec[
'hash'], \
TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($copyDestName), FALSE, TRUE);
3738 echo $this->
newlog(
'TYPO3\\CMS\\Core\\Database\\ReferenceIndex::setReferenceValue(): ' . $error, 1);
3741 $this->
newlog(
'File "' . $copyDestName .
'" was not created!', 1);
3744 $this->
newlog(
'Could not construct new unique names for file!', 1);
3747 $this->
newlog(
'Maybe directory of file was not within "uploads/"?', 1);
3750 $this->
newlog(
'Trying to copy RTEmagic files (' . $rec[
'ref_string'] .
' / ' . $fileInfo[
'original'] .
') but one or both were missing', 1);
3775 if (isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
3776 $where =
' AND t3ver_oid=0';
3782 if (is_array($l10nRecords)) {
3785 $localizedDestPids = array();
3789 if (is_array($destL10nRecords)) {
3790 foreach ($destL10nRecords as $record) {
3791 $localizedDestPids[$record[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]] = -$record[
'uid'];
3796 foreach ($l10nRecords as $record) {
3797 $localizedDestPid = (int)$localizedDestPids[$record[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]];
3798 if ($localizedDestPid < 0) {
3799 $this->copyRecord($table, $record[
'uid'], $localizedDestPid, $first,
$overrideValues, $excludeFields, $record[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]);
3801 $this->copyRecord($table, $record[
'uid'], $destPid < 0 ? $tscPID : $destPid, $first,
$overrideValues, $excludeFields, $record[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]);
3829 $uid = $lookForLiveVersion[
'uid'];
3832 $destPid = (int)$destPid;
3837 $resolvedPid = $this->
resolvePid($table, $destPid);
3840 if ($table !=
'pages' || $resolvedPid == $moveRec[
'pid']) {
3847 if ($table !=
'pages' || $resolvedPid != $moveRec[
'pid']) {
3854 $fullLanguageCheckNeeded = $table !=
'pages';
3855 $mayEditAccess = $this->BE_USER->recordEditAccessInternals($table,
$uid, FALSE, FALSE, $fullLanguageCheckNeeded);
3857 if ($mayEditAccess) {
3858 if ($mayMoveAccess) {
3859 if ($mayInsertAccess) {
3860 $recordWasMoved = FALSE;
3862 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'moveRecordClass'])) {
3863 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'moveRecordClass'] as $classRef) {
3865 if (method_exists($hookObj,
'moveRecord')) {
3866 $hookObj->moveRecord($table,
$uid, $destPid, $propArr, $moveRec, $resolvedPid, $recordWasMoved, $this);
3871 if (!$recordWasMoved) {
3875 $this->
log($table,
$uid, 4, 0, 1,
'Attempt to move record \'%s\' (%s) without having permissions to insert.', 14, array($propArr[
'header'], $table .
':' .
$uid), $propArr[
'event_pid']);
3878 $this->
log($table,
$uid, 4, 0, 1,
'Attempt to move record \'%s\' (%s) without having permissions to do so.', 14, array($propArr[
'header'], $table .
':' .
$uid), $propArr[
'event_pid']);
3881 $this->
log($table,
$uid, 4, 0, 1,
'Attempt to move record "%s" (%s) without having permissions to do so. [' . $this->BE_USER->errorMsg .
']', 14, array($propArr[
'header'], $table .
':' .
$uid), $propArr[
'event_pid']);
3898 $sortRow =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
3899 $origDestPid = $destPid;
3901 $resolvedPid = $this->
resolvePid($table, $destPid);
3904 if ($destPid < 0 && !$sortRow || $destPid >= 0) {
3905 $destPid = $resolvedPid;
3911 $hookObjectsArr = array();
3912 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'moveRecordClass'])) {
3913 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'moveRecordClass'] as $classRef) {
3918 $updateFields = array();
3919 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']) {
3920 $updateFields[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']] = $GLOBALS[
'EXEC_TIME'];
3923 if ($destPid >= 0) {
3929 $updateFields[
'pid'] = $destPid;
3933 $updateFields[$sortRow] = $sortNumber;
3938 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)
$uid, $updateFields);
3942 foreach ($hookObjectsArr as $hookObj) {
3943 if (method_exists($hookObj,
'moveRecord_firstElementPostProcess')) {
3944 $hookObj->moveRecord_firstElementPostProcess($table, $uid, $destPid, $moveRec, $updateFields, $this);
3951 if ($destPid != $propArr[
'pid']) {
3953 $this->
log($table, $uid, 4, $destPid, 0,
'Moved record \'%s\' (%s) to page \'%s\' (%s)', 2, array($propArr[
'header'], $table .
':' . $uid, $newpagePropArr[
'header'], $newPropArr[
'pid']), $propArr[
'pid']);
3955 $this->
log($table, $uid, 4, $destPid, 0,
'Moved record \'%s\' (%s) from page \'%s\' (%s)', 3, array($propArr[
'header'], $table .
':' . $uid, $oldpagePropArr[
'header'], $propArr[
'pid']), $destPid);
3958 $this->
log($table, $uid, 4, $destPid, 0,
'Moved record \'%s\' (%s) on page \'%s\' (%s)', 4, array($propArr[
'header'], $table .
':' . $uid, $oldpagePropArr[
'header'], $propArr[
'pid']), $destPid);
3964 if ($origDestPid < 0) {
3969 $this->
log($table,
$uid, 4, 0, 1,
'Attempt to move page \'%s\' (%s) to inside of its own rootline (at page \'%s\' (%s))', 10, array($propArr[
'header'],
$uid, $destPropArr[
'header'], $destPid), $propArr[
'pid']);
3976 $originalRecordDestinationPid = $destPid;
3979 $destPid = $sortInfo[
'pid'];
3981 if (is_array($sortInfo)) {
3986 $updateFields[
'pid'] = $destPid;
3987 $updateFields[$sortRow] = $sortInfo[
'sortNumber'];
3991 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)
$uid, $updateFields);
3995 foreach ($hookObjectsArr as $hookObj) {
3996 if (method_exists($hookObj,
'moveRecord_afterAnotherElementPostProcess')) {
3997 $hookObj->moveRecord_afterAnotherElementPostProcess($table, $uid, $destPid, $origDestPid, $moveRec, $updateFields, $this);
4003 if ($destPid != $propArr[
'pid']) {
4006 $this->
log($table, $uid, 4, 0, 0,
'Moved record \'%s\' (%s) to page \'%s\' (%s)', 2, array($propArr[
'header'], $table .
':' . $uid, $newpagePropArr[
'header'], $newPropArr[
'pid']), $propArr[
'pid']);
4008 $this->
log($table, $uid, 4, 0, 0,
'Moved record \'%s\' (%s) from page \'%s\' (%s)', 3, array($propArr[
'header'], $table .
':' . $uid, $oldpagePropArr[
'header'], $propArr[
'pid']), $destPid);
4011 $this->
log($table, $uid, 4, 0, 0,
'Moved record \'%s\' (%s) on page \'%s\' (%s)', 4, array($propArr[
'header'], $table .
':' . $uid, $oldpagePropArr[
'header'], $propArr[
'pid']), $destPid);
4018 if ($origDestPid < 0) {
4023 $this->
log($table,
$uid, 4, 0, 1,
'Attempt to move page \'%s\' (%s) to inside of its own rootline (at page \'%s\' (%s))', 10, array($propArr[
'header'],
$uid, $destPropArr[
'header'], $destPid), $propArr[
'pid']);
4027 $this->
log($table,
$uid, 4, 0, 1,
'Attempt to move record \'%s\' (%s) to after another record, although the table has no sorting row.', 13, array($propArr[
'header'], $table .
':' .
$uid), $propArr[
'event_pid']);
4043 $conf =
$GLOBALS[
'TCA'][$table][
'columns'];
4045 if (is_array($row)) {
4046 foreach ($row as $field => $value) {
4067 if ($conf[
'type'] ==
'inline') {
4068 $foreign_table = $conf[
'foreign_table'];
4069 $moveChildrenWithParent = !isset($conf[
'behaviour'][
'disableMovingChildrenWithParent']) || !$conf[
'behaviour'][
'disableMovingChildrenWithParent'];
4070 if ($foreign_table && $moveChildrenWithParent) {
4072 if ($inlineType ==
'list' || $inlineType ==
'field') {
4073 $moveTable = $foreign_table;
4074 if ($table ==
'pages') {
4080 $dbAnalysis->start($value, $conf[
'foreign_table'],
'',
$uid, $table, $conf);
4085 if (isset($dbAnalysis)) {
4088 foreach (array_reverse($dbAnalysis->itemArray) as $v) {
4089 $this->
moveRecord($v[
'table'], $v[
'id'], $destPid);
4110 if (isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
4111 $where =
' AND t3ver_oid=0';
4114 if (is_array($l10nRecords)) {
4116 if ($originalRecordDestinationPid < 0) {
4117 $localizedDestPids = array();
4121 if (is_array($destL10nRecords)) {
4122 foreach ($destL10nRecords as $record) {
4123 $localizedDestPids[$record[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]] = -$record[
'uid'];
4128 foreach ($l10nRecords as $record) {
4129 $localizedDestPid = (int)$localizedDestPids[$record[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]];
4130 if ($localizedDestPid < 0) {
4131 $this->
moveRecord($table, $record[
'uid'], $localizedDestPid);
4133 $this->
moveRecord($table, $record[
'uid'], $destPid);
4149 public function localize($table,
$uid, $language) {
4154 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'] && !
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable'] || $table ===
'pages') {
4155 if ($langRec = BackendUtility::getRecord(
'sys_language', (
int)$language,
'uid,title')) {
4159 if (is_array($row)) {
4160 if ($row[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']] <= 0 || $table ===
'pages') {
4161 if ($row[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']] == 0 || $table ===
'pages') {
4162 if ($table ===
'pages') {
4163 $pass =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transForeignTable'] ===
'pages_language_overlay' && !
BackendUtility::getRecordsByField(
'pages_language_overlay',
'pid',
$uid, (
' AND ' .
$GLOBALS[
'TCA'][
'pages_language_overlay'][
'ctrl'][
'languageField'] .
'=' . (
int)$langRec[
'uid']));
4164 $Ttable =
'pages_language_overlay';
4172 $excludeFields = array();
4177 if (isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'type']) && isset($GLOBALS[
'TCA'][$Ttable][
'ctrl'][
'type'])) {
4178 $overrideValues[$GLOBALS[
'TCA'][$Ttable][
'ctrl'][
'type']] = $row[$GLOBALS[
'TCA'][$table][
'ctrl'][
'type']];
4181 foreach ($GLOBALS[
'TCA'][$Ttable][
'columns'] as $fN => $fCfg) {
4183 if ($fCfg[
'l10n_mode'] ==
'prefixLangTitle') {
4184 if (($fCfg[
'config'][
'type'] ==
'text' || $fCfg[
'config'][
'type'] ==
'input') && strlen($row[$fN])) {
4187 if (isset($TSConfig[
'translateToMessage']) && !empty($TSConfig[
'translateToMessage'])) {
4188 $translateToMsg = $GLOBALS[
'LANG'] ? $GLOBALS[
'LANG']->sL($TSConfig[
'translateToMessage']) : $TSConfig[
'translateToMessage'];
4189 $translateToMsg = @sprintf($translateToMsg, $langRec[
'title']);
4191 if (!strlen($translateToMsg)) {
4192 $translateToMsg =
'Translate to ' . $langRec[
'title'] .
':';
4196 } elseif (
GeneralUtility::inList(
'exclude,noCopy,mergeIfNotBlank', $fCfg[
'l10n_mode']) && $fN != $GLOBALS[
'TCA'][$Ttable][
'ctrl'][
'languageField'] && $fN != $GLOBALS[
'TCA'][$Ttable][
'ctrl'][
'transOrigPointerField']) {
4199 $excludeFields[] = $fN;
4202 if ($Ttable === $table) {
4206 $newId = $this->copyRecord($table,
$uid, -$previousUid, 1,
$overrideValues, implode(
',', $excludeFields), $language);
4208 if (is_null($autoVersionNewId) === FALSE) {
4209 $this->
triggerRemapAction($table, $newId, array($this,
'placeholderShadowing'), array($table, $autoVersionNewId), TRUE);
4215 $copyTCE->start(array($Ttable => array(
'NEW' =>
$overrideValues)),
'', $this->BE_USER);
4216 $copyTCE->process_datamap();
4218 $theNewSQLID = $copyTCE->substNEWwithIDs[
'NEW'];
4221 $this->copyMappingArray[$Ttable][
$uid] = $theNewSQLID;
4222 $newId = $theNewSQLID;
4226 $this->
newlog(
'Localization failed; There already was a localization for this language of the record!', 1);
4229 $this->
newlog(
'Localization failed; Source record contained a reference to an original default record (which is strange)!', 1);
4232 $this->
newlog(
'Localization failed; Source record had another language than "Default" or "All" defined!', 1);
4235 $this->
newlog(
'Attempt to localize record that did not exist!', 1);
4238 $this->
newlog(
'Attempt to localize record without permission', 1);
4241 $this->
newlog(
'Sys language UID "' . $language .
'" not found valid!', 1);
4244 $this->
newlog(
'Localization failed; "languageField" and "transOrigPointerField" must be defined for the table!', 1);
4258 protected function inlineLocalizeSynchronize($table, $id, $command) {
4264 $config =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
4265 $foreignTable = $config[
'foreign_table'];
4267 if ($localizationMode ==
'select') {
4269 $language = (int)$parentRecord[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']];
4270 $transOrigPointer = (int)$parentRecord[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']];
4272 $childTransOrigPointerField =
$GLOBALS[
'TCA'][$foreignTable][
'ctrl'][
'transOrigPointerField'];
4274 if ($parentRecord && is_array($parentRecord) && $language > 0 && $transOrigPointer) {
4278 if ($inlineSubType !== FALSE) {
4279 $removeArray = array();
4280 $mmTable = $inlineSubType ==
'mm' && isset($config[
'MM']) && $config[
'MM'] ? $config[
'MM'] :
'';
4284 $dbAnalysisOriginal->start($transOrigRecord[$field], $foreignTable, $mmTable, $transOrigRecord[
'uid'], $transOrigTable, $config);
4285 $elementsOriginal = array();
4286 foreach ($dbAnalysisOriginal->itemArray as $item) {
4287 $elementsOriginal[$item[
'id']] = $item;
4289 unset($dbAnalysisOriginal);
4293 $dbAnalysisCurrent->start($parentRecord[$field], $foreignTable, $mmTable, $id, $table, $config);
4295 if ($type ==
'synchronize') {
4296 foreach ($dbAnalysisCurrent->itemArray as $index => $item) {
4298 if (isset($childRecord[$childTransOrigPointerField]) && $childRecord[$childTransOrigPointerField] > 0) {
4299 $childTransOrigPointer = $childRecord[$childTransOrigPointerField];
4301 if (!isset($elementsOriginal[$childTransOrigPointer])) {
4302 unset($dbAnalysisCurrent->itemArray[$index]);
4303 $removeArray[$item[
'table']][$item[
'id']][
'delete'] = 1;
4310 $item = $elementsOriginal[$type];
4311 $item[
'id'] = $this->localize($item[
'table'], $item[
'id'], $language);
4313 $dbAnalysisCurrent->itemArray[] = $item;
4315 foreach ($elementsOriginal as $originalId => $item) {
4316 $item[
'id'] = $this->localize($item[
'table'], $item[
'id'], $language);
4318 $dbAnalysisCurrent->itemArray[] = $item;
4322 $value = implode(
',', $dbAnalysisCurrent->getValueArray());
4323 $this->registerDBList[$table][$id][$field] = $value;
4325 if (is_array($removeArray) && count($removeArray)) {
4327 $tce->stripslashes_values = FALSE;
4329 $tce->start(array(), $removeArray);
4330 $tce->process_cmdmap();
4334 if ($inlineSubType ==
'list') {
4335 $updateFields = array($field => $value);
4336 } elseif ($inlineSubType ==
'field') {
4337 $dbAnalysisCurrent->writeForeignField($config, $id);
4338 $updateFields = array($field => $dbAnalysisCurrent->countItems(FALSE));
4339 } elseif ($inlineSubType ==
'mm') {
4340 $dbAnalysisCurrent->writeMM($config[
'MM'], $id);
4341 $updateFields = array($field => $dbAnalysisCurrent->countItems(FALSE));
4344 if (is_array($updateFields) && count($updateFields)) {
4345 $this->
updateDB($table, $id, $updateFields);
4367 $recordToDelete = BackendUtility::getRecord($table, $id);
4369 if (is_array($recordToDelete)) {
4370 $recordWasDeleted = FALSE;
4371 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processCmdmapClass'])) {
4372 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processCmdmapClass'] as $classRef) {
4374 if (method_exists($hookObj,
'processCmdmap_deleteAction')) {
4375 $hookObj->processCmdmap_deleteAction($table, $id, $recordToDelete, $recordWasDeleted, $this);
4380 if (!$recordWasDeleted) {
4396 public function deleteEl($table,
$uid, $noRecordCheck = FALSE, $forceHardDelete = FALSE) {
4397 if ($table ==
'pages') {
4416 if (is_array($versions)) {
4417 foreach ($versions as $verRec) {
4418 if (!$verRec[
'_CURRENT_VERSION']) {
4419 if ($table ==
'pages') {
4420 $this->
deletePages($verRec[
'uid'], TRUE, $forceHardDelete);
4422 $this->
deleteRecord($table, $verRec[
'uid'], TRUE, $forceHardDelete);
4429 if (!empty($versionMovePlaceholder)) {
4430 $this->
deleteEl($table, $versionMovePlaceholder[
'uid'], TRUE, $forceHardDelete);
4466 public function deleteRecord($table,
$uid, $noRecordCheck = FALSE, $forceHardDelete = FALSE, $undeleteRecord = FALSE) {
4468 $deletedRecord = ($forceHardDelete || $undeleteRecord);
4469 $mayEditAccess = $this->BE_USER->recordEditAccessInternals($table,
$uid, FALSE, $deletedRecord, TRUE);
4472 if ($mayEditAccess) {
4479 $deleteRow =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'delete'];
4480 if ($deleteRow && !$forceHardDelete) {
4481 $value = $undeleteRecord ? 0 : 1;
4482 $updateFields = array(
4483 $deleteRow => $value
4485 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']) {
4486 $updateFields[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']] = $GLOBALS[
'EXEC_TIME'];
4489 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'] && !$undeleteRecord) {
4490 $updateFields[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']] = 1000000000;
4494 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)
$uid, $updateFields);
4496 if (!$undeleteRecord) {
4501 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $fieldName => $cfg) {
4502 $conf = $cfg[
'config'];
4503 switch ($conf[
'type']) {
4512 if (count($fileFieldArr)) {
4513 $mres =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(implode(
',', $fileFieldArr), $table,
'uid=' . (
int)
$uid);
4514 if ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($mres)) {
4515 $fArray = $fileFieldArr;
4517 foreach ($fArray as $theField) {
4522 $this->
log($table, $uid, 3, 0, 100,
'Delete: Zero rows in result when trying to read filenames from record which should be deleted');
4524 $GLOBALS[
'TYPO3_DB']->sql_free_result($mres);
4527 $GLOBALS[
'TYPO3_DB']->exec_DELETEquery($table,
'uid=' . (
int)
$uid);
4531 $state = $undeleteRecord ? 1 : 3;
4532 if (!
$GLOBALS[
'TYPO3_DB']->sql_error()) {
4533 if ($forceHardDelete) {
4534 $message =
'Record \'%s\' (%s) was deleted unrecoverable from page \'%s\' (%s)';
4536 $message = $state == 1 ?
'Record \'%s\' (%s) was restored on page \'%s\' (%s)' :
'Record \'%s\' (%s) was deleted from page \'%s\' (%s)';
4538 $this->
log($table,
$uid, $state, 0, 0, $message, 0, array(
4540 $table .
':' .
$uid,
4541 $pagePropArr[
'header'],
4543 ), $propArr[
'event_pid']);
4545 $this->
log($table,
$uid, $state, 0, 100,
$GLOBALS[
'TYPO3_DB']->sql_error());
4548 $this->updateRefIndex($table,
$uid);
4550 if (is_array($this->updateRefIndexStack[$table]) && is_array($this->updateRefIndexStack[$table][
$uid])) {
4551 while ($args = array_pop($this->updateRefIndexStack[$table][$uid])) {
4553 $this->updateRefIndex($args[0], $args[1]);
4555 unset($this->updateRefIndexStack[$table][$uid]);
4558 $this->
log($table,
$uid, 3, 0, 1,
'Attempt to delete record without delete-permissions');
4561 $this->
log($table,
$uid, 3, 0, 1,
'Attempt to delete record without delete-permissions. [' . $this->BE_USER->errorMsg .
']');
4580 $files = $refIndexObj->getRelations_procFiles($dataValue, $dsArr[
'TCEforms'][
'config'], $PA[
'uid']);
4582 if (is_array($files) && $dsArr[
'TCEforms'][
'config'][
'internal_type'] ===
'file') {
4583 foreach ($files as $dat) {
4584 if (@is_file($dat[
'ID_absFile'])) {
4588 $this->
log(
'', 0, 3, 0, 100,
'Delete: Referenced file \'' . $dat[
'ID_absFile'] .
'\' that was supposed to be deleted together with its record which didn\
't exist');
4606 $this->
newlog2(
'Deleting all pages starting from the root-page is disabled.',
'pages', 0, 0, 2);
4618 if (is_array($res)) {
4619 foreach ($res as $deleteId) {
4640 foreach (
$GLOBALS[
'TCA'] as $table => $_) {
4641 if ($table !=
'pages') {
4643 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($mres)) {
4646 $this->
deleteRecord($table, $row[
'uid'], TRUE, $forceHardDelete);
4648 $GLOBALS[
'TYPO3_DB']->sql_free_result($mres);
4671 if ($this->BE_USER->workspace > 0) {
4672 $originalRecord = BackendUtility::getRecord($table,
$uid);
4676 if (!empty($originalRecord) && !empty($movePlaceholder) && (
int)$originalRecord[
'pid'] !== (
int)$movePlaceholder[
'pid']) {
4683 'copy' =>
'-' . $movePlaceholder[
'uid']
4688 $dataHandler->stripslashes_values = FALSE;
4690 $dataHandler->neverHideAtCopy = TRUE;
4691 $dataHandler->start(array(), $command);
4692 $dataHandler->process_cmdmap();
4693 unset($dataHandler);
4696 $this->
deleteRecord($table, $movePlaceholder[
'uid'], TRUE, TRUE);
4711 if ($this->deleteTree) {
4715 if ($brExist != -1) {
4718 foreach ($pagesInBranch as $pageInBranch) {
4719 if (!$this->BE_USER->recordEditAccessInternals(
'pages', $pageInBranch, FALSE, FALSE, TRUE)) {
4720 return 'Attempt to delete page which has prohibited localizations.';
4723 return $pagesInBranch;
4725 return 'Attempt to delete records from disallowed tables';
4728 return 'Attempt to delete pages in branch without permissions';
4734 if ($brExist ==
'') {
4736 if ($this->BE_USER->recordEditAccessInternals(
'pages',
$uid, FALSE, FALSE, TRUE)) {
4739 return 'Attempt to delete page which has prohibited localizations.';
4742 return 'Attempt to delete records from disallowed tables';
4745 return 'Attempt to delete page which has subpages';
4749 return 'Attempt to delete page without permissions';
4762 if ($table ===
'pages') {
4764 return is_array($res) ? FALSE : $res;
4766 return $this->
doesRecordExist($table, $id,
'delete') ? FALSE :
'No permission to delete record';
4779 $record = BackendUtility::getRecord($table,
$uid,
'pid',
'', FALSE);
4780 if ($record[
'pid']) {
4781 $page = BackendUtility::getRecord(
'pages', $record[
'pid'],
'deleted, title, uid',
'', FALSE);
4783 if (!$page[
'deleted']) {
4786 $this->
log($table,
$uid,
'isRecordUndeletable',
'', 1,
'Record cannot be undeleted since the page containing it is deleted! Undelete page "' . $page[
'title'] .
' (UID: ' . $page[
'uid'] .
')" first');
4807 $conf =
$GLOBALS[
'TCA'][$table][
'columns'];
4808 $row = BackendUtility::getRecord($table,
$uid,
'*',
'', FALSE);
4812 foreach ($row as $field => $value) {
4813 $this->deleteRecord_procBasedOnFieldType($table,
$uid, $field, $value, $conf[$field][
'config'], $undeleteRecord);
4831 public function deleteRecord_procBasedOnFieldType($table,
$uid, $field, $value, $conf, $undeleteRecord = FALSE) {
4832 if ($conf[
'type'] ==
'inline') {
4833 $foreign_table = $conf[
'foreign_table'];
4834 if ($foreign_table) {
4836 if ($inlineType ==
'list' || $inlineType ==
'field') {
4839 $dbAnalysis->start($value, $conf[
'foreign_table'],
'',
$uid, $table, $conf);
4840 $dbAnalysis->undeleteRecord = TRUE;
4842 $enableCascadingDelete = TRUE;
4844 if (isset($conf[
'behaviour'][
'enableCascadingDelete']) && $conf[
'behaviour'][
'enableCascadingDelete'] == FALSE) {
4845 $enableCascadingDelete = FALSE;
4849 foreach ($dbAnalysis->itemArray as $v) {
4850 if (!$undeleteRecord) {
4851 if ($enableCascadingDelete) {
4861 $allowedTables = $conf[
'type'] ==
'group' ? $conf[
'allowed'] : $conf[
'foreign_table'] .
',' . $conf[
'neg_foreign_table'];
4862 $prependName = $conf[
'type'] ==
'group' ? $conf[
'prepend_tname'] : $conf[
'neg_foreign_table'];
4864 $dbAnalysis->start($value, $allowedTables, $conf[
'MM'],
$uid, $table, $conf);
4865 foreach ($dbAnalysis->itemArray as $v) {
4866 $this->updateRefIndexStack[$table][
$uid][] = array($v[
'table'], $v[
'id']);
4885 if (isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
4886 $where =
' AND t3ver_oid=0';
4889 if (is_array($l10nRecords)) {
4890 foreach ($l10nRecords as $record) {
4899 $this->
deleteAction($table, (
int)$record[
't3ver_oid'] > 0 ? (
int)$record[
't3ver_oid'] : (
int)$record[
'uid']);
4928 if (
$GLOBALS[
'TCA'][$table] &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] && $id > 0) {
4931 $row = $this->recordInfo($table, $id,
'pid,t3ver_id,t3ver_state');
4932 if (is_array($row)) {
4934 if ($row[
'pid'] >= 0) {
4939 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
't3ver_id', $table,
'((pid=-1 && t3ver_oid=' . $id .
') OR uid=' . $id .
')' . $this->
deleteClause($table),
'',
't3ver_id DESC',
'1');
4940 list($highestVerNumber) =
$GLOBALS[
'TYPO3_DB']->sql_fetch_row($res);
4941 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
4943 $subVer = $row[
't3ver_id'] .
'.' . ($highestVerNumber + 1);
4945 $overrideArray = array(
4946 't3ver_id' => $highestVerNumber + 1,
4948 't3ver_label' => $label ?: $subVer .
' / ' . date(
'd-m-Y H:m:s'),
4949 't3ver_wsid' => $this->BE_USER->workspace,
4955 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']) {
4956 $overrideArray[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']] = 0;
4959 if ($this->BE_USER->workspace !== 0) {
4964 if (empty($versionRecord[
'uid'])) {
4970 $workspaceOptions = array(
4971 'delete' => $delete,
4974 return $this->
copyRecord_raw($table, $id, -1, $overrideArray, $workspaceOptions);
4979 return $versionRecord[
'uid'];
4985 $this->
newlog(
'Record cannot be versioned because it is a placeholder for a moving operation', 1);
4988 $this->
newlog(
'Record "' . $table .
':' . $id .
'" you wanted to versionize was already a version in archive (pid=-1)!', 1);
4991 $this->
newlog(
'Record "' . $table .
':' . $id .
'" you wanted to versionize did not exist!', 1);
4994 $this->
newlog(
'You didnt have correct permissions to make a new version (copy) of this record "' . $table .
'" / ' . $id, 1);
4997 $this->
newlog(
'Versioning is not supported for this table "' . $table .
'" / ' . $id, 1);
5011 public function version_remapMMForVersionSwap($table, $id, $swapWith) {
5013 $currentRec = BackendUtility::getRecord($table, $id);
5014 $swapRec = BackendUtility::getRecord($table, $swapWith);
5015 $this->version_remapMMForVersionSwap_reg = array();
5016 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $fConf) {
5017 $conf = $fConf[
'config'];
5019 $allowedTables = $conf[
'type'] ==
'group' ? $conf[
'allowed'] : $conf[
'foreign_table'] .
',' . $conf[
'neg_foreign_table'];
5020 $prependName = $conf[
'type'] ==
'group' ? $conf[
'prepend_tname'] : $conf[
'neg_foreign_table'];
5024 $dbAnalysis->start(
'', $allowedTables, $conf[
'MM'], $id, $table, $conf);
5025 if (count($dbAnalysis->getValueArray($prependName))) {
5026 $this->version_remapMMForVersionSwap_reg[$id][$field] = array($dbAnalysis, $conf[
'MM'], $prependName);
5030 $dbAnalysis->start(
'', $allowedTables, $conf[
'MM'], $swapWith, $table, $conf);
5031 if (count($dbAnalysis->getValueArray($prependName))) {
5032 $this->version_remapMMForVersionSwap_reg[$swapWith][$field] = array($dbAnalysis, $conf[
'MM'], $prependName);
5035 } elseif ($conf[
'type'] ==
'flex') {
5039 if (is_array($currentValueArray)) {
5040 $this->
checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table, $id, $field),
'version_remapMMForVersionSwap_flexFormCallBack');
5045 if (is_array($currentValueArray)) {
5046 $this->
checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table, $swapWith, $field),
'version_remapMMForVersionSwap_flexFormCallBack');
5067 public function version_remapMMForVersionSwap_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path) {
5069 list($table,
$uid, $field) = $pParams;
5071 $allowedTables = $dsConf[
'type'] ==
'group' ? $dsConf[
'allowed'] : $dsConf[
'foreign_table'] .
',' . $dsConf[
'neg_foreign_table'];
5072 $prependName = $dsConf[
'type'] ==
'group' ? $dsConf[
'prepend_tname'] : $dsConf[
'neg_foreign_table'];
5073 if ($dsConf[
'MM']) {
5076 $dbAnalysis->start(
'', $allowedTables, $dsConf[
'MM'],
$uid, $table, $dsConf);
5077 $this->version_remapMMForVersionSwap_reg[
$uid][$field .
'/' . $path] = array($dbAnalysis, $dsConf[
'MM'], $prependName);
5094 if (is_array($this->version_remapMMForVersionSwap_reg[$id])) {
5095 foreach ($this->version_remapMMForVersionSwap_reg[$id] as $field => $str) {
5096 $str[0]->remapMM($str[1], $id, -$id, $str[2]);
5099 if (is_array($this->version_remapMMForVersionSwap_reg[$swapWith])) {
5100 foreach ($this->version_remapMMForVersionSwap_reg[$swapWith] as $field => $str) {
5101 $str[0]->remapMM($str[1], $swapWith, $id, $str[2]);
5104 if (is_array($this->version_remapMMForVersionSwap_reg[$id])) {
5105 foreach ($this->version_remapMMForVersionSwap_reg[$id] as $field => $str) {
5106 $str[0]->remapMM($str[1], -$id, $swapWith, $str[2]);
5126 $copyTCE->stripslashes_values = $stripslashesValues;
5143 if (count($this->registerDBList)) {
5144 foreach ($this->registerDBList as $table => $records) {
5145 foreach ($records as
$uid => $fields) {
5147 $theUidToUpdate = $this->copyMappingArray_merged[$table][
$uid];
5149 foreach ($fields as $fieldName => $value) {
5150 $conf =
$GLOBALS[
'TCA'][$table][
'columns'][$fieldName][
'config'];
5151 switch ($conf[
'type']) {
5156 if (is_array($vArray)) {
5157 $newData[$fieldName] = implode(
',', $vArray);
5161 if ($value ==
'FlexForm_reference') {
5163 $origRecordRow = $this->recordInfo($table, $theUidToUpdate,
'*');
5164 if (is_array($origRecordRow)) {
5170 $currentValueArray[
'data'] = $this->
checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table, $theUidToUpdate, $fieldName),
'remapListedDBRecords_flexFormCallBack');
5172 if (is_array($currentValueArray[
'data'])) {
5173 $newData[$fieldName] = $this->checkValue_flexArray2Xml($currentValueArray, TRUE);
5179 $this->remapListedDBRecords_procInline($conf, $value,
$uid, $table);
5182 debug(
'Field type should not appear here: ' . $conf[
'type']);
5186 if (count($newData)) {
5187 $this->
updateDB($table, $theUidToUpdate_saveTo, $newData);
5208 list($table,
$uid, $field) = $pParams;
5212 if (is_array($vArray)) {
5213 $dataValue = implode(
',', $vArray);
5217 return array(
'value' => $dataValue);
5236 $allowedTables = $conf[
'type'] ==
'group' ? $conf[
'allowed'] : $conf[
'foreign_table'] .
',' . $conf[
'neg_foreign_table'];
5238 $prependName = $conf[
'type'] ==
'group' ? $conf[
'prepend_tname'] :
'';
5243 $dbAnalysis->registerNonTableValues = $conf[
'type'] ==
'select' && $conf[
'allowNonIdValues'] ? 1 : 0;
5244 $dbAnalysis->start($value, $allowedTables, $conf[
'MM'], $MM_localUid, $table, $conf);
5246 foreach ($dbAnalysis->itemArray as $k => $v) {
5247 $mapID = $this->copyMappingArray_merged[$v[
'table']][$v[
'id']];
5248 if ($mapID && !in_array($v[
'table'], $dontRemapTables)) {
5249 $dbAnalysis->itemArray[$k][
'id'] = $mapID;
5253 if (!empty($conf[
'MM'])) {
5255 $dbAnalysis->purgeItemArray();
5256 if ($dbAnalysis->isPurged()) {
5262 if (!empty($this->copyMappingArray_merged[$table])) {
5263 $originalId = array_search($MM_localUid, $this->copyMappingArray_merged[$table]);
5265 if (!empty($liveId) && !empty($originalId) && (
int)$liveId === (
int)$originalId) {
5267 $liveRelations->setWorkspaceId(0);
5268 $liveRelations->start(
'', $allowedTables, $conf[
'MM'], $liveId, $table, $conf);
5270 $liveRelations->purgeItemArray(0);
5271 if ($liveRelations->isPurged()) {
5272 $liveRelations->writeMM($conf[
'MM'], $liveId, $prependName);
5279 $dbAnalysis->writeMM($conf[
'MM'], $MM_localUid, $prependName);
5281 $vArray = $dbAnalysis->getValueArray($prependName);
5282 if ($conf[
'type'] ==
'select') {
5283 $vArray = $dbAnalysis->convertPosNeg($vArray, $conf[
'foreign_table'], $conf[
'neg_foreign_table']);
5300 public function remapListedDBRecords_procInline($conf, $value,
$uid, $table) {
5301 $theUidToUpdate = $this->copyMappingArray_merged[$table][
$uid];
5302 if ($conf[
'foreign_table']) {
5304 if ($inlineType ==
'mm') {
5306 } elseif ($inlineType !== FALSE) {
5309 $dbAnalysis->start($value, $conf[
'foreign_table'],
'', 0, $table, $conf);
5312 $originalItemArray = $dbAnalysis->itemArray;
5313 foreach ($dbAnalysis->itemArray as &$item) {
5315 if (!empty($versionedId)) {
5316 $item[
'id'] = $versionedId;
5321 if ($inlineType ==
'field') {
5322 $dbAnalysis->writeForeignField($conf,
$uid, $theUidToUpdate);
5325 if ($table ==
'pages') {
5326 $thePidToUpdate = $theUidToUpdate;
5327 } elseif (isset($this->registerDBPids[$table][
$uid])) {
5328 $thePidToUpdate = $this->registerDBPids[$table][
$uid];
5329 $thePidToUpdate = $this->copyMappingArray_merged[
'pages'][$thePidToUpdate];
5332 if ($thePidToUpdate) {
5333 $updateValues = array(
'pid' => $thePidToUpdate);
5334 foreach ($originalItemArray as $v) {
5336 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($v[
'table'],
'uid=' . (
int)$v[
'id'], $updateValues);
5353 if (is_array($this->remapStack)) {
5354 $remapFlexForms = array();
5356 foreach ($this->remapStack as $remapAction) {
5358 if (!is_array($remapAction[
'pos'])) {
5362 $field = $remapAction[
'field'];
5363 $id = $remapAction[
'args'][$remapAction[
'pos'][
'id']];
5365 $table = $remapAction[
'args'][$remapAction[
'pos'][
'table']];
5366 $valueArray = $remapAction[
'args'][$remapAction[
'pos'][
'valueArray']];
5367 $tcaFieldConf = $remapAction[
'args'][$remapAction[
'pos'][
'tcaFieldConf']];
5368 $additionalData = $remapAction[
'additionalData'];
5370 if (strpos($id,
'NEW') !== FALSE) {
5372 $id = $this->substNEWwithIDs[$id];
5374 if (isset($this->autoVersionIdMap[$table][$id])) {
5375 $id = $this->autoVersionIdMap[$table][$id];
5377 $remapAction[
'args'][$remapAction[
'pos'][
'id']] = $id;
5380 if (is_array($valueArray)) {
5381 $foreign_table = $tcaFieldConf[
'foreign_table'];
5382 foreach ($valueArray as $key => $value) {
5383 if (strpos($value,
'NEW') !== FALSE) {
5384 $value = $this->substNEWwithIDs[$value];
5386 if (isset($this->autoVersionIdMap[$foreign_table][$value])) {
5387 $value = $this->autoVersionIdMap[$foreign_table][$value];
5390 $this->newRelatedIDs[$foreign_table][] = $value;
5391 $valueArray[$key] = $value;
5394 $remapAction[
'args'][$remapAction[
'pos'][
'valueArray']] = $valueArray;
5397 $newValue = call_user_func_array(array($this, $remapAction[
'func']), $remapAction[
'args']);
5399 if (is_array($newValue)) {
5403 if (!empty($field)) {
5404 $this->
updateDB($table, $id, array($field => $newValue));
5406 } elseif (!empty($additionalData[
'flexFormId']) && !empty($additionalData[
'flexFormPath'])) {
5407 $flexFormId = $additionalData[
'flexFormId'];
5408 $flexFormPath = $additionalData[
'flexFormPath'];
5410 if (!isset($remapFlexForms[$flexFormId])) {
5411 $remapFlexForms[$flexFormId] = array();
5414 $remapFlexForms[$flexFormId][$flexFormPath] = $newValue;
5417 if (isset($this->remapStackRecords[$table][$rawId][
'processDatamap_afterDatabaseOperations'])) {
5418 $hookArgs = $this->remapStackRecords[$table][$rawId][
'processDatamap_afterDatabaseOperations'];
5420 $hookArgs[
'fieldArray'][$field] = $newValue;
5422 $hookObjectsArr = $hookArgs[
'hookObjectsArr'];
5423 foreach ($hookObjectsArr as $hookObj) {
5424 if (method_exists($hookObj,
'processDatamap_afterDatabaseOperations')) {
5425 $hookObj->processDatamap_afterDatabaseOperations($hookArgs[
'status'], $table, $rawId, $hookArgs[
'fieldArray'], $this);
5431 if ($remapFlexForms) {
5432 foreach ($remapFlexForms as $flexFormId => $modifications) {
5438 if ($this->remapStackActions) {
5439 foreach ($this->remapStackActions as $action) {
5440 if (isset($action[
'callback']) && isset($action[
'arguments'])) {
5441 call_user_func_array($action[
'callback'], $action[
'arguments']);
5446 foreach ($this->remapStackRefIndex as $table => $idArray) {
5447 foreach ($idArray as $id) {
5448 $this->updateRefIndex($table, $id);
5449 unset($this->remapStackRefIndex[$table][$id]);
5453 $this->remapStack = array();
5454 $this->remapStackRecords = array();
5455 $this->remapStackActions = array();
5456 $this->remapStackRefIndex = array();
5467 list ($table,
$uid, $field) = explode(
':', $flexFormId, 3);
5470 $uid = $this->substNEWwithIDs[
$uid];
5473 $record = $this->recordInfo($table, $uid,
'*');
5475 if (!$table || !$uid || !$field || !is_array($record)) {
5485 foreach ($modifications as $path => $value) {
5487 $valueStructure[
'data'], $path, $value
5491 if (is_array($valueStructure[
'data'])) {
5494 $field => $this->checkValue_flexArray2Xml($valueStructure, TRUE),
5497 $this->
updateDB($table, $uid, $values);
5516 protected function triggerRemapAction($table, $id, array $callback, array $arguments, $forceRemapStackActions = FALSE) {
5518 if (!$forceRemapStackActions && !isset($this->remapStackRecords[$table][$id]) && !isset($this->remapStackChildIds[$id])) {
5519 call_user_func_array($callback, $arguments);
5535 $this->remapStackActions[] = array(
5540 'callback' => $callback,
5541 'arguments' => $arguments
5553 $this->remapStackRefIndex[$table][$id] = $id;
5571 foreach ($incomingFieldArray as $field => $value) {
5572 $fieldConf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
5573 if (
$registerDBList[$table][$id][$field] && ($foreignTable = $fieldConf[
'foreign_table'])) {
5574 $newValueArray = array();
5575 $origValueArray = explode(
',', $value);
5577 foreach ($origValueArray as $childId) {
5578 $newValueArray[] = $this->autoVersionIdMap[$foreignTable][$childId] ? $this->autoVersionIdMap[$foreignTable][$childId] : $childId;
5581 $incomingFieldArray[$field] = implode(
',', $newValueArray);
5604 public function checkModifyAccessList($table) {
5609 $hookObject->checkModifyAccessList($res, $table, $this);
5623 if (!isset($this->isRecordInWebMount_Cache[($table .
':' . $id)])) {
5625 $this->isRecordInWebMount_Cache[$table .
':' . $id] = $this->
isInWebMount($recP[
'event_pid']);
5627 return $this->isRecordInWebMount_Cache[$table .
':' . $id];
5638 if (!isset($this->isInWebMount_Cache[$pid])) {
5639 $this->isInWebMount_Cache[$pid] = $this->BE_USER->isInWebMount($pid);
5641 return $this->isInWebMount_Cache[$pid];
5656 if (is_array($hookObjectsArr)) {
5657 foreach ($hookObjectsArr as $hookObj) {
5658 if (method_exists($hookObj,
'checkRecordUpdateAccess')) {
5659 $res = $hookObj->checkRecordUpdateAccess($table, $id, $data, $res, $this);
5663 if ($res === 1 || $res === 0) {
5668 if (
$GLOBALS[
'TCA'][$table] && (
int)$id > 0) {
5670 if (isset($this->recUpdateAccessCache[$table][$id])) {
5671 return $this->recUpdateAccessCache[$table][$id];
5676 $this->recUpdateAccessCache[$table][$id] = $res;
5697 if (isset($this->recInsertAccessCache[$insertTable][$pid])) {
5698 return $this->recInsertAccessCache[$insertTable][$pid];
5702 if ($insertTable ===
'pages') {
5703 $perms = $this->pMap[
'new'];
5705 } elseif (($insertTable ===
'sys_file_reference') && array_key_exists(
'pages', $this->datamap)) {
5706 $perms = $this->pMap[
'edit'];
5708 $perms = $this->pMap[
'editcontent'];
5717 $this->recInsertAccessCache[$insertTable][$pid] = $res;
5720 $this->
log($insertTable, $pid, $action, 0, 1,
'Attempt to insert record on page \'%s\' (%s) where this table, %s, is not allowed', 11, array($propArr[
'header'], $pid, $insertTable), $propArr[
'event_pid']);
5724 $this->
log($insertTable, $pid, $action, 0, 1,
'Attempt to insert a record on page \'%s\' (%s) from table \'%s\' without permissions. Or non-existing page.', 12, array($propArr[
'header'], $pid, $insertTable), $propArr[
'event_pid']);
5738 $page_uid = (int)$page_uid;
5739 $rootLevelSetting = (int)
$GLOBALS[
'TCA'][$checkTable][
'ctrl'][
'rootLevel'];
5741 if ($checkTable !==
'pages' && $rootLevelSetting !== -1 && ($rootLevelSetting xor !$page_uid)) {
5752 $doktype = $this->
pageInfo($page_uid,
'doktype');
5753 $allowedTableList = isset(
$GLOBALS[
'PAGES_TYPES'][$doktype][
'allowedTables'])
5754 ?
$GLOBALS[
'PAGES_TYPES'][$doktype][
'allowedTables']
5755 :
$GLOBALS[
'PAGES_TYPES'][
'default'][
'allowedTables'];
5758 if (strpos($allowedTableList,
'*') !== FALSE || in_array($checkTable, $allowedArray)) {
5778 if ($this->bypassAccessCheckForRecords) {
5783 if ($table !=
'pages') {
5791 if ($table ===
'sys_file_reference' && array_key_exists(
'pages', $this->datamap)) {
5794 $perms =
'editcontent';
5799 $perms = (int)$this->pMap[$perms];
5801 $perms = (int)$perms;
5804 throw new \RuntimeException(
'Internal ERROR: no permissions to check for non-admin user', 1270853920);
5808 if (is_array(
$GLOBALS[
'TCA'][$table]) && $id > 0 && ($isWebMountRestrictionIgnored || $this->
isRecordInWebMount($table, $id) || $this->admin)) {
5809 if ($table !=
'pages') {
5811 $mres =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid,pid', $table,
'uid=' . (
int)$id . $this->
deleteClause($table));
5813 $output =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($mres);
5816 if (is_array($output)) {
5819 $pageRec =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($mres);
5822 if (is_array($pageRec) || !$output[
'pid'] && ($isRootLevelRestrictionIgnored || $this->admin)) {
5829 return $GLOBALS[
'TYPO3_DB']->sql_num_rows($mres);
5845 return $GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid',
'pages',
'uid=' . (
int)$id . $this->
deleteClause(
'pages') . ($perms && !$this->admin ?
' AND ' . $this->BE_USER->getPagePermsClause($perms) :
'') . (!$this->admin &&
$GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'editlock'] && $perms & 2 + 4 + 16 ?
' AND ' .
$GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'editlock'] .
'=0' :
''));
5864 $perms = (int)$perms;
5866 $mres =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid, perms_userid, perms_groupid, perms_user, perms_group, perms_everybody',
'pages',
'pid=' . (
int)$pid . $this->
deleteClause(
'pages'),
'',
'sorting');
5867 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($mres)) {
5869 if ($this->admin || $this->BE_USER->doesUserHaveAccess($row, $perms)) {
5870 $inList .= $row[
'uid'] .
',';
5873 $inList = $this->
doesBranchExist($inList, $row[
'uid'], $perms, $recurse);
5874 if ($inList == -1) {
5883 $GLOBALS[
'TYPO3_DB']->sql_free_result($mres);
5897 return $GLOBALS[
'TCA'][$table][
'ctrl'][
'readOnly'] ? TRUE : FALSE;
5909 return $GLOBALS[
'TCA'][$table][
'ctrl'][
'adminOnly'] ? TRUE : FALSE;
5928 while ($dest != 0 && $loopCheck > 0) {
5930 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'pid, uid, t3ver_oid,t3ver_wsid',
'pages',
'uid=' . (
int)$dest . $this->
deleteClause(
'pages'));
5931 if ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
5933 if ($row[
'pid'] == $id) {
5936 $dest = $row[
'pid'];
5941 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
5955 foreach (
$GLOBALS[
'TCA'] as $table => $_) {
5956 if (isset(
$GLOBALS[
'TCA'][$table][
'columns'])) {
5957 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $config) {
5958 if ($config[
'exclude'] && !
GeneralUtility::inList($this->BE_USER->groupData[
'non_exclude_fields'], ($table .
':' . $field))) {
5959 $list[] = $table .
'-' . $field;
5976 $page_uid = (int)$page_uid;
5981 $allowedTableList = isset(
$GLOBALS[
'PAGES_TYPES'][$doktype][
'allowedTables']) ?
$GLOBALS[
'PAGES_TYPES'][$doktype][
'allowedTables'] :
$GLOBALS[
'PAGES_TYPES'][
'default'][
'allowedTables'];
5984 if (strstr($allowedTableList,
'*')) {
5988 $tableList = array();
5989 foreach (
$GLOBALS[
'TCA'] as $table => $_) {
5991 if (!in_array($table, $allowedArray)) {
5992 $count =
$GLOBALS[
'TYPO3_DB']->exec_SELECTcountRows(
'uid', $table,
'pid=' . (
int)$page_uid);
5994 $tableList[] = $table;
5998 return implode(
',', $tableList);
6016 if (!isset($this->pageCache[$id])) {
6017 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'*',
'pages',
'uid=' . (
int)$id);
6018 if (
$GLOBALS[
'TYPO3_DB']->sql_num_rows($res)) {
6019 $this->pageCache[$id] =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res);
6021 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
6023 return $this->pageCache[$id][$field];
6035 public function recordInfo($table, $id, $fieldList) {
6037 if ((
int)$id === 0 || !isset(
$GLOBALS[
'TCA'][$table])) {
6042 $result = $db->exec_SELECTgetSingleRow($fieldList, $table,
'uid=' . (
int)$id);
6059 $row = $table ==
'pages' && !$id ? array(
'title' =>
'[root-level]',
'uid' => 0,
'pid' => 0) : $this->recordInfo($table, $id,
'*');
6079 'pid' => $row[
'pid'],
6080 'event_pid' => $this->
eventPid($table, isset($row[
'_ORIG_pid']) ? $row[
't3ver_oid'] : $row[
'uid'], $row[
'pid']),
6081 't3ver_state' =>
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] ? $row[
't3ver_state'] :
'',
6082 '_ORIG_pid' => $row[
'_ORIG_pid']
6096 return $table ==
'pages' ?
$uid : $pid;
6115 if (is_array($fieldArray) && is_array(
$GLOBALS[
'TCA'][$table]) && (
int)$id) {
6117 unset($fieldArray[
'uid']);
6118 if (count($fieldArray)) {
6121 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$id, $fieldArray);
6123 if (!
$GLOBALS[
'TYPO3_DB']->sql_error()) {
6124 if ($this->checkStoredRecords) {
6128 $this->updateRefIndex($table, $id);
6131 $theLogId = $this->
log($table, $id, 2, $propArr[
'pid'], 0,
'Record \'%s\' (%s) was updated.' . ($propArr[
'_ORIG_pid'] == -1 ?
' (Offline version).' :
' (Online).'), 10, array($propArr[
'header'], $table .
':' . $id), $propArr[
'event_pid']);
6137 if ($table ==
'pages') {
6138 unset($this->pageCache[$id]);
6141 $this->
log($table, $id, 2, 0, 2,
'SQL error: \'%s\' (%s)', 12, array(
$GLOBALS[
'TYPO3_DB']->sql_error(), $table .
':' . $id));
6160 public function insertDB($table, $id, $fieldArray, $newVersion = FALSE, $suggestedUid = 0, $dontSetNewIdIndex = FALSE) {
6161 if (is_array($fieldArray) && is_array(
$GLOBALS[
'TCA'][$table]) && isset($fieldArray[
'pid'])) {
6163 unset($fieldArray[
'uid']);
6164 if (count($fieldArray)) {
6169 $suggestedUid = (int)$suggestedUid;
6170 if ($this->BE_USER->isAdmin() && $suggestedUid && $this->suggestedInsertUids[$table .
':' . $suggestedUid]) {
6172 if ($this->suggestedInsertUids[$table .
':' . $suggestedUid] ===
'DELETE') {
6174 $GLOBALS[
'TYPO3_DB']->exec_DELETEquery($table,
'uid=' . (
int)$suggestedUid);
6176 $fieldArray[
'uid'] = $suggestedUid;
6180 $GLOBALS[
'TYPO3_DB']->exec_INSERTquery($table, $fieldArray);
6182 if (!
$GLOBALS[
'TYPO3_DB']->sql_error()) {
6186 $id =
$GLOBALS[
'TYPO3_DB']->sql_insert_id();
6187 if (!$dontSetNewIdIndex) {
6188 $this->substNEWwithIDs[$NEW_id] = $id;
6189 $this->substNEWwithIDs_table[$NEW_id] = $table;
6192 if ($this->checkStoredRecords) {
6196 $this->updateRefIndex($table, $id);
6199 $this->
log($table, $id, 1, 0, 0,
'New version created of table \'%s\', uid \'%s\'. UID of new version is \'%s\'', 10, array($table, $fieldArray[
't3ver_oid'], $id), $propArr[
'event_pid'], $NEW_id);
6203 $this->
log($table, $id, 1, 0, 0,
'Record \'%s\' (%s) was inserted on page \'%s\' (%s)', 10, array($propArr[
'header'], $table .
':' . $id, $page_propArr[
'header'], $newRow[
'pid']), $newRow[
'pid'], $NEW_id);
6209 $this->
log($table, $id, 1, 0, 2,
'SQL error: \'%s\' (%s)', 12, array(
$GLOBALS[
'TYPO3_DB']->sql_error(), $table .
':' . $id));
6228 if (is_array(
$GLOBALS[
'TCA'][$table]) && $id) {
6229 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'*', $table,
'uid=' . (
int)$id);
6230 if ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
6232 $errorString = array();
6233 foreach ($fieldArray as $key => $value) {
6234 if ($this->checkStoredRecords_loose && !$value && !$row[$key]) {
6236 } elseif ((
string)$value !== (
string)$row[$key]) {
6237 $errorString[] = $key;
6241 if (count($errorString)) {
6242 $this->
log($table, $id, $action, 0, 1,
'These fields are not properly updated in database: (' . implode(
',', $errorString) .
') Probably value mismatch with fieldtype.');
6247 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
6261 if (isset($this->historyRecords[$table .
':' . $id]) && (
int)$logId > 0) {
6262 $fields_values = array();
6263 $fields_values[
'history_data'] = serialize($this->historyRecords[$table .
':' . $id]);
6264 $fields_values[
'fieldlist'] = implode(
',', array_keys($this->historyRecords[$table .
':' . $id][
'newRecord']));
6265 $fields_values[
'tstamp'] =
$GLOBALS[
'EXEC_TIME'];
6266 $fields_values[
'tablename'] = $table;
6267 $fields_values[
'recuid'] = $id;
6268 $fields_values[
'sys_log_uid'] = $logId;
6269 $GLOBALS[
'TYPO3_DB']->exec_INSERTquery(
'sys_history', $fields_values);
6282 public function updateRefIndex($table, $id) {
6286 $refIndexObj->setWorkspaceId($this->BE_USER->workspace);
6288 $refIndexObj->updateRefIndexTable($table, $id);
6307 if (
$GLOBALS[
'TCA'][$table] &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']) {
6308 $sortRow =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
6312 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery($sortRow .
',pid,uid', $table,
'pid=' . (
int)$pid . $this->
deleteClause($table),
'', $sortRow .
' ASC',
'1');
6314 if ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
6316 if ($row[
'uid'] ==
$uid) {
6317 return $row[$sortRow];
6320 if ($row[$sortRow] < 1) {
6321 $this->
resorting($table, $pid, $sortRow, 0);
6326 return floor($row[$sortRow] / 2);
6336 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery($sortRow .
',pid,uid', $table,
'uid=' . abs($pid) . $this->
deleteClause($table));
6338 if ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
6341 $row = $lookForLiveVersion;
6345 $row = $movePlaceholder;
6348 if ($row[
'uid'] ==
$uid) {
6349 $sortNumber = $row[$sortRow];
6351 $subres =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery($sortRow .
',pid,uid', $table,
'pid=' . (
int)$row[
'pid'] .
' AND ' . $sortRow .
'>=' . (
int)$row[$sortRow] . $this->
deleteClause($table),
'', $sortRow .
' ASC',
'2');
6354 if (
$GLOBALS[
'TYPO3_DB']->sql_num_rows($subres) == 2) {
6356 $GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($subres);
6358 $subrow =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($subres);
6360 $sortNumber = $row[$sortRow] + floor(($subrow[$sortRow] - $row[$sortRow]) / 2);
6362 if ($sortNumber <= $row[$sortRow] || $sortNumber >= $subrow[$sortRow]) {
6364 $sortNumber = $this->
resorting($table, $row[
'pid'], $sortRow, $row[
'uid']);
6370 $GLOBALS[
'TYPO3_DB']->sql_free_result($subres);
6372 return array(
'pid' => $row[
'pid'],
'sortNumber' => $sortNumber);
6376 $this->
log($table,
$uid, 4, 0, 1,
'Attempt to move record \'%s\' (%s) to after a non-existing record (uid=%s)', 1, array($propArr[
'header'], $table .
':' .
$uid, abs($pid)), $propArr[
'pid']);
6397 public function resorting($table, $pid, $sortRow, $return_SortNumber_After_This_Uid) {
6398 if (
$GLOBALS[
'TCA'][$table] && $sortRow &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'] == $sortRow) {
6401 $i = $intervals * 2;
6402 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid', $table,
'pid=' . (
int)$pid . $this->
deleteClause($table),
'', $sortRow .
' ASC');
6403 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
6404 $uid = (int)$row[
'uid'];
6406 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)
$uid, array($sortRow => $i));
6408 if ($uid == $return_SortNumber_After_This_Uid) {
6409 $i = $i + $intervals;
6413 die(
'Fatal ERROR!! No Uid at resorting.');
6415 $i = $i + $intervals;
6417 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
6433 $previousLocalizedRecordUid =
$uid;
6434 if (
$GLOBALS[
'TCA'][$table] &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']) {
6435 $sortRow =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
6436 $select = $sortRow .
',pid,uid';
6438 if ($table ===
'tt_content') {
6439 $select .=
',colPos';
6442 $row = BackendUtility::getRecord($table,
$uid, $select);
6443 if (is_array($row)) {
6445 $where =
'pid=' . (int)$pid .
' AND ' .
'sys_language_uid=0' .
' AND ' . $sortRow .
'<' . (
int)$row[$sortRow];
6447 if ($table ===
'tt_content') {
6448 $where .=
' AND colPos=' . (int)$row[
'colPos'];
6450 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery($select, $table, $where . $this->
deleteClause($table),
'', $sortRow .
' DESC',
'1');
6452 if ($previousRow =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
6454 if (is_array($previousLocalizedRecord[0])) {
6455 $previousLocalizedRecordUid = $previousLocalizedRecord[0][
'uid'];
6458 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
6461 return $previousLocalizedRecordUid;
6474 if ((
string)$TSConfig_p[
'userid'] !==
'') {
6475 $fieldArray[
'perms_userid'] = (int)$TSConfig_p[
'userid'];
6477 if ((
string)$TSConfig_p[
'groupid'] !==
'') {
6478 $fieldArray[
'perms_groupid'] = (int)$TSConfig_p[
'groupid'];
6480 if ((
string)$TSConfig_p[
'user'] !==
'') {
6483 if ((
string)$TSConfig_p[
'group'] !==
'') {
6486 if ((
string)$TSConfig_p[
'everybody'] !==
'') {
6501 $fieldArray = array();
6502 if (is_array(
$GLOBALS[
'TCA'][$table][
'columns'])) {
6503 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $content) {
6504 if (isset($this->defaultValues[$table][$field])) {
6505 $fieldArray[$field] = $this->defaultValues[$table][$field];
6506 } elseif (isset($content[
'config'][
'default'])) {
6507 $fieldArray[$field] = $content[
'config'][
'default'];
6512 if ($table ===
'pages') {
6514 $fieldArray[
'perms_groupid'] = (int)$this->BE_USER->firstMainGroup;
6515 $fieldArray[
'perms_user'] = $this->assemblePermissions($this->defaultPermissions[
'user']);
6516 $fieldArray[
'perms_group'] = $this->
assemblePermissions($this->defaultPermissions[
'group']);
6517 $fieldArray[
'perms_everybody'] = $this->
assemblePermissions($this->defaultPermissions[
'everybody']);
6532 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']) {
6533 if (!isset($incomingFieldArray[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']])) {
6535 $rows = array_merge(array(array(
'uid' => 0)),
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid',
'sys_language',
'pid=0' .
BackendUtility::deleteClause(
'sys_language')), array(array(
'uid' => -1)));
6536 foreach ($rows as $r) {
6537 if ($this->BE_USER->checkLanguageAccess($r[
'uid'])) {
6538 $incomingFieldArray[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']] = $r[
'uid'];
6555 if (is_array($this->overrideValues[$table])) {
6556 $data = array_merge($data, $this->overrideValues[$table]);
6573 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'*', $table,
'uid=' . (
int)$id);
6574 $currentRecord =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res);
6576 if (is_array($currentRecord)) {
6579 $cRecTypes = array();
6580 foreach ($currentRecord as $col => $val) {
6581 $cRecTypes[$col] =
$GLOBALS[
'TYPO3_DB']->sql_field_type($res, $c);
6585 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
6587 foreach ($fieldArray as $col => $val) {
6588 $fieldConfiguration =
$GLOBALS[
'TCA'][$table][
'columns'][$col][
'config'];
6589 $isNullField = (!empty($fieldConfiguration[
'eval']) &&
GeneralUtility::inList($fieldConfiguration[
'eval'],
'null'));
6594 unset($fieldArray[$col]);
6596 if (!isset($this->mmHistoryRecords[($table .
':' . $id)][
'oldRecord'][$col])) {
6597 $this->historyRecords[$table .
':' . $id][
'oldRecord'][$col] = $currentRecord[$col];
6598 } elseif ($this->mmHistoryRecords[$table .
':' . $id][
'oldRecord'][$col] != $this->mmHistoryRecords[$table .
':' . $id][
'newRecord'][$col]) {
6599 $this->historyRecords[$table .
':' . $id][
'oldRecord'][$col] = $this->mmHistoryRecords[$table .
':' . $id][
'oldRecord'][$col];
6601 if (!isset($this->mmHistoryRecords[($table .
':' . $id)][
'newRecord'][$col])) {
6602 $this->historyRecords[$table .
':' . $id][
'newRecord'][$col] = $fieldArray[$col];
6603 } elseif ($this->mmHistoryRecords[$table .
':' . $id][
'newRecord'][$col] != $this->mmHistoryRecords[$table .
':' . $id][
'oldRecord'][$col]) {
6604 $this->historyRecords[$table .
':' . $id][
'newRecord'][$col] = $this->mmHistoryRecords[$table .
':' . $id][
'newRecord'][$col];
6610 $fieldArray = array();
6631 $result = (string)$submittedValue === (
string)$storedValue || $storedType ===
'int' && (int)$storedValue === (
int)$submittedValue;
6634 } elseif ($storedValue !== NULL) {
6636 $submittedValue !== NULL
6642 $result = ($submittedValue === NULL);
6659 foreach ($keyArr as $key) {
6660 if ($key && isset($this->pMap[$key])) {
6661 $value |= $this->pMap[$key];
6675 return rtrim($input,
',');
6686 $token = md5(microtime());
6687 $parts = explode($token, preg_replace(
'/(&#([0-9]+);)/', $token .
'\\2' . $token, $input));
6688 foreach ($parts as $k => $v) {
6693 $parts[$k] = chr((
int)$v);
6697 return implode(
'', $parts);
6708 return PATH_site . $folder;
6732 return ' AND ' . $table .
'.' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'delete'] .
'=0';
6747 if (isset(self::$recordPidsForDeletedRecords[$table][
$uid])) {
6748 return self::$recordPidsForDeletedRecords[$table][
$uid];
6751 return array($parentUid);
6762 if (!isset($this->cachedTSconfig[$tscPID])) {
6765 return $this->cachedTSconfig[$tscPID][
'properties'];
6778 $tA = is_array($TSconfig[
'table.'][$table .
'.']) ? $TSconfig[
'table.'][$table .
'.'] : array();
6779 $dA = is_array($TSconfig[
'default.']) ? $TSconfig[
'default.'] : array();
6793 $res_tmp =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'pid', $table,
'uid=' . (
int)
$uid);
6794 if ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res_tmp)) {
6807 foreach ($this->dbAnalysisStore as $action) {
6810 $action[0]->writeMM($action[1], $id, $action[3]);
6822 foreach ($this->removeFilesStore as $file) {
6823 if (@is_file($file)) {
6843 if ((
int)$this->BE_USER->workspace === 0) {
6844 $workspaceStatement =
' AND t3ver_wsid=0';
6846 $workspaceStatement =
' AND t3ver_wsid IN (0,' . (int)$this->BE_USER->workspace .
')';
6848 $addW = !$this->admin ?
' AND ' . $this->BE_USER->getPagePermsClause($this->pMap[
'show']) :
'';
6849 $pages = $this->databaseConnection->exec_SELECTgetRows(
6852 'pid=' . (
int)$pid . $this->
deleteClause(
'pages') . $workspaceStatement . $addW,
6860 if (!empty($pages) && (
int)$this->BE_USER->workspace !== 0) {
6861 $pages = array_reverse(
6862 $this->resolveVersionedRecords(
6872 foreach ($pages as $page) {
6873 if ($page[
'uid'] != $rootID) {
6874 $CPtable[$page[
'uid']] = $pid;
6877 $CPtable = $this->
int_pageTreeInfo($CPtable, $page[
'uid'], $counter - 1, $rootID);
6892 return array_keys(
$GLOBALS[
'TCA']);
6904 if (empty(
$GLOBALS[
'TCA'][$table])) {
6907 $curData = $this->recordInfo($table,
$uid,
'*');
6909 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $conf) {
6910 if ($conf[
'config'][
'type'] ===
'input' && (
string)$curData[$field] !==
'') {
6912 if (in_array(
'uniqueInPid', $evalCodesArray)) {
6913 $newV = $this->
getUnique($table, $field, $curData[$field],
$uid, $curData[
'pid']);
6914 if ((
string)$newV !== (
string)$curData[$field]) {
6915 $newData[$field] = $newV;
6921 if (!empty($newData)) {
6939 if (
$GLOBALS[
'TCA'][$table] &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'copyAfterDuplFields']) {
6940 $prevData = $this->recordInfo($table, $prevUid,
'*');
6942 foreach ($theFields as $field) {
6943 if (
$GLOBALS[
'TCA'][$table][
'columns'][$field] && ($update || !isset($newData[$field]))) {
6944 $newData[$field] = $prevData[$field];
6947 if ($update && count($newData)) {
6963 if (isset(
$GLOBALS[
'TCA'][$table][
'columns'])) {
6964 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $configArr) {
6965 if ($configArr[
'config'][
'type'] ==
'group' && ($configArr[
'config'][
'internal_type'] ==
'file' || $configArr[
'config'][
'internal_type'] ==
'file_reference')) {
6966 $listArr[] = $field;
6983 if (
$GLOBALS[
'TCA'][$table][
'columns']) {
6984 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $configArr) {
6985 if ($configArr[
'config'][
'type'] ===
'input') {
6987 if (in_array(
'uniqueInPid', $evalCodesArray) || in_array(
'unique', $evalCodesArray)) {
6988 $listArr[] = $field;
7004 return $conf[
'type'] ==
'group' && $conf[
'internal_type'] ==
'db' || $conf[
'type'] ==
'select' && $conf[
'foreign_table'];
7016 if ($conf[
'type'] !==
'inline' || !$conf[
'foreign_table']) {
7019 if ($conf[
'foreign_field']) {
7022 } elseif ($conf[
'MM']) {
7043 public function getCopyHeader($table, $pid, $field, $value, $count, $prevTitle =
'') {
7046 $checkTitle = $value . rtrim((
' ' . sprintf($this->
prependLabel($table), $count)));
7048 $checkTitle = $value;
7051 if ($prevTitle != $checkTitle || $count < 100) {
7052 $rowCount =
$GLOBALS[
'TYPO3_DB']->exec_SELECTcountRows(
'uid', $table,
'pid=' . (
int)$pid .
' AND ' . $field .
'=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($checkTitle, $table) . $this->
deleteClause($table));
7054 return $this->
getCopyHeader($table, $pid, $field, $value, $count + 1, $checkTitle);
7071 $label =
$GLOBALS[
'LANG']->sL(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'prependAtCopy']);
7073 list($label) = explode(
'|',
$GLOBALS[
'TCA'][$table][
'ctrl'][
'prependAtCopy']);
7089 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'pid', $table,
'uid=' . abs($pid));
7090 $row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res);
7091 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
7097 $row = $lookForLiveVersion;
7099 $pid = (int)$row[
'pid'];
7113 $regex =
'/' . sprintf(quotemeta($this->
prependLabel($table)),
'[0-9]*') .
'$/';
7114 return @preg_replace($regex,
'', $value);
7128 $uploadFolder =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'uploadfolder'];
7129 if ($uploadFolder && trim($filelist) &&
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'internal_type'] ==
'file') {
7131 $fileArray = explode(
',', $filelist);
7132 foreach ($fileArray as $theFile) {
7133 $theFile = trim($theFile);
7137 $theFileFullPath = $uploadPath .
'/' . $theFile;
7138 if (@is_file($theFileFullPath)) {
7142 $this->
log($table, 0, 3, 0, 100,
'Delete: Referenced file that was supposed to be deleted together with it\'s record didn\'t exist');
7159 $inList = trim($this->
rmComma(trim($inList)));
7160 if ($inList && !$this->admin) {
7161 foreach (
$GLOBALS[
'TCA'] as $table => $_) {
7163 if ($count && ($this->
tableReadOnly($table) || !$this->checkModifyAccessList($table))) {
7181 if (isset($this->copyMappingArray[$table][
$uid])) {
7183 } elseif (isset($this->copyMappingArray[$table]) && in_array($uid, array_values($this->copyMappingArray[$table]))) {
7207 if (!is_array(static::$recordsToClearCacheFor[$table])) {
7208 static::$recordsToClearCacheFor[$table] = array();
7210 static::$recordsToClearCacheFor[$table][] = (int)
$uid;
7211 if ($pid !== null) {
7212 if (!is_array(static::$recordPidsForDeletedRecords[$table])) {
7213 static::$recordPidsForDeletedRecords[$table] = array();
7215 static::$recordPidsForDeletedRecords[$table][
$uid][] = (int)$pid;
7231 $originalValues = static::$recordsToClearCacheFor;
7233 static::$recordsToClearCacheFor = array();
7234 static::$recordsToClearCacheFor[$table] = array();
7235 static::$recordsToClearCacheFor[$table][] = (int)
$uid;
7237 $this->processClearCacheQueue();
7239 static::$recordsToClearCacheFor = $originalValues;
7246 protected function processClearCacheQueue() {
7247 $tagsToClear = array();
7248 $clearCacheCommands = array();
7250 foreach (static::$recordsToClearCacheFor as $table => $uids) {
7251 foreach (array_unique($uids) as
$uid) {
7252 if (!isset(
$GLOBALS[
'TCA'][$table]) || $uid <= 0) {
7257 foreach ($pageUids as $originalParent) {
7258 list($tagsToClearFromPrepare, $clearCacheCommandsFromPrepare)
7260 $tagsToClear = array_merge($tagsToClear, $tagsToClearFromPrepare);
7261 $clearCacheCommands = array_merge($clearCacheCommands, $clearCacheCommandsFromPrepare);
7268 foreach ($tagsToClear as $tag => $_) {
7269 $cacheManager->flushCachesInGroupByTag(
'pages', $tag);
7273 foreach ($clearCacheCommands as $command) {
7278 static::$recordsToClearCacheFor = array();
7281 static::$recordPidsForDeletedRecords = array();
7294 $tagsToClear = array();
7295 $clearCacheCommands = array();
7299 if (empty($TSConfig[
'clearCache_disable'])) {
7301 $pageIdsThatNeedCacheFlush = array();
7302 if ($table ===
'pages' || $table ===
'pages_language_overlay') {
7303 if ($table ===
'pages_language_overlay') {
7309 $res_tmp =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'A.pid AS pid, B.uid AS uid',
'pages A, pages B',
'A.uid=' . (
int)$pageUid .
' AND B.pid=A.pid AND B.deleted=0 AND A.pid >= 0');
7311 while ($row_tmp =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res_tmp)) {
7312 $pageIdsThatNeedCacheFlush[] = (int)$row_tmp[
'uid'];
7313 $pid_tmp = (int)$row_tmp[
'pid'];
7315 if ($TSConfig[
'clearCache_pageSiblingChildren']) {
7316 $res_tmp2 =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid',
'pages',
'pid=' . (
int)$row_tmp[
'uid'] .
' AND deleted=0');
7317 while ($row_tmp2 =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res_tmp2)) {
7318 $pageIdsThatNeedCacheFlush[] = (int)$row_tmp2[
'uid'];
7320 $GLOBALS[
'TYPO3_DB']->sql_free_result($res_tmp2);
7323 $GLOBALS[
'TYPO3_DB']->sql_free_result($res_tmp);
7326 $pageIdsThatNeedCacheFlush[] = (int)$pid_tmp;
7329 if ($TSConfig[
'clearCache_pageGrandParent']) {
7330 $res_tmp =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'pid',
'pages',
'uid=' . (
int)$pid_tmp);
7331 if ($row_tmp =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res_tmp)) {
7332 $pageIdsThatNeedCacheFlush[] = (int)$row_tmp[
'pid'];
7334 $GLOBALS[
'TYPO3_DB']->sql_free_result($res_tmp);
7338 $pageIdsThatNeedCacheFlush[] = $pageUid = (int)$this->
getPID($table,
$uid);
7341 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearPageCacheEval'])) {
7342 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearPageCacheEval'] as $funcName) {
7343 $_params = array(
'pageIdArray' => &$pageIdsThatNeedCacheFlush,
'table' => $table,
'uid' =>
$uid,
'functionID' =>
'clear_cache()');
7349 foreach ($pageIdsThatNeedCacheFlush as $pageId) {
7354 $tagsToClear[
'pageId_' . $pageId] = TRUE;
7358 $tagsToClear[$table] = TRUE;
7359 $tagsToClear[$table .
'_' .
$uid] = TRUE;
7362 if (!empty($TSConfig[
'clearCacheCmd'])) {
7364 $clearCacheCommands = array_unique($commands);
7367 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearCachePostProc'])) {
7368 $_params = array(
'table' => $table,
'uid' =>
$uid,
'uid_page' => $pageUid,
'TSConfig' => $TSConfig);
7369 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearCachePostProc'] as $_funcRef) {
7419 if (is_object($this->BE_USER)) {
7420 $this->BE_USER->writelog(3, 1, 0, 0,
'User %s has cleared the cache (cacheCmd=%s)', array($this->BE_USER->user[
'username'], $cacheCmd));
7423 switch (strtolower($cacheCmd)) {
7425 if ($this->admin || $this->BE_USER->getTSConfigVal(
'options.clearCache.pages')) {
7430 if ($this->admin || $this->BE_USER->getTSConfigVal(
'options.clearCache.all')) {
7433 $GLOBALS[
'TYPO3_DB']->exec_TRUNCATEquery(
'cache_treelist');
7435 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearAllCache_additionalTables'])) {
7436 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearAllCache_additionalTables'] as $tableName) {
7437 GeneralUtility::deprecationLog(
'Hook clearAllCache_additionalTables in DataHandler is deprecated in 6.2 and will be removed two versions later. Use the caching framework with database backend instead.');
7438 if (!preg_match(
'/[^[:alnum:]_]/', $tableName) && substr($tableName, -5) ===
'cache') {
7439 $GLOBALS[
'TYPO3_DB']->exec_TRUNCATEquery($tableName);
7441 throw new \RuntimeException(
'TYPO3 Fatal Error: Trying to flush table "' . $tableName .
'" with "Clear All Cache"', 1270853922);
7450 if ($this->admin || $this->BE_USER->getTSConfigVal(
'options.clearCache.system')
7451 || ((bool)
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'clearCacheSystem'] === TRUE && $this->admin)) {
7457 $tagsToFlush = array();
7460 $list_cache = array($cacheCmd);
7462 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearPageCacheEval'])) {
7463 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearPageCacheEval'] as $funcName) {
7464 $_params = array(
'pageIdArray' => &$list_cache,
'cacheCmd' => $cacheCmd,
'functionID' =>
'clear_cacheCmd()');
7470 if (is_array($list_cache)) {
7471 foreach ($list_cache as $pageId) {
7472 $tagsToFlush[] =
'pageId_' . (int)$pageId;
7478 $cacheTag = substr($cacheCmd, 9);
7479 $tagsToFlush[] = $cacheTag;
7482 if (count($tagsToFlush) > 0) {
7483 foreach (array_unique($tagsToFlush) as $tag) {
7489 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearCachePostProc'])) {
7490 $_params = array(
'cacheCmd' => strtolower($cacheCmd));
7491 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearCachePostProc'] as $_funcRef) {
7518 public function log($table, $recuid, $action, $recpid, $error, $details, $details_nr = -1, $data = array(), $event_pid = -1, $NEWid =
'') {
7519 if (!$this->enableLogging) {
7524 if (!$this->storeLogMessages) {
7528 $detailMessage = $details;
7529 if (is_array($data)) {
7530 $detailMessage = vsprintf($details, $data);
7532 $this->errorLog[] =
'[' . $type .
'.' . $action .
'.' . $details_nr .
']: ' . $detailMessage;
7534 return $this->BE_USER->writelog($type, $action, $error, $details_nr, $details, $data, $table, $recuid, $recpid, $event_pid, $NEWid);
7546 public function newlog($message, $error = 0) {
7547 return $this->
log(
'', 0, 0, 0, $error,
'[newlog()] ' . $message, -1);
7562 public function newlog2($message, $table,
$uid, $pid = FALSE, $error = 0) {
7563 if ($pid === FALSE) {
7565 $pid = $propArr[
'pid'];
7567 return $this->
log($table,
$uid, 0, 0, $error, $message, -1, array(), $this->
eventPid($table,
$uid, $pid));
7577 public function printLogErrorMessages($redirect) {
7578 $res_log =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'*',
'sys_log',
'type=1 AND action<256 AND userid=' . (
int)$this->BE_USER->user[
'uid'] .
' AND tstamp=' . (
int)
$GLOBALS[
'EXEC_TIME'] .
' AND error<>0');
7579 while ($row = $GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res_log)) {
7580 $log_data = unserialize($row[
'log_data']);
7581 $msg = $row[
'error'] .
': ' . sprintf($row[
'details'], $log_data[0], $log_data[1], $log_data[2], $log_data[3], $log_data[4]);
7582 $flashMessage =
GeneralUtility::makeInstance(
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($msg),
'', \
TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, TRUE);
7586 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
7587 $defaultFlashMessageQueue->enqueue($flashMessage);
7589 $GLOBALS[
'TYPO3_DB']->sql_free_result($res_log);
7621 foreach ($fieldArray as $field => $value) {
7622 switch (
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'type']) {
7624 if (
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'foreign_field']) {
7644 if (isset($this->autoVersionIdMap[$table][$id])) {
7645 $result = $this->autoVersionIdMap[$table][$id];
7659 if (is_null($autoVersionId) === FALSE) {
7660 $id = $autoVersionId;
7672 foreach ($idValues as $idValue) {
7673 if (strpos($idValue,
'NEW') === 0) {
7674 $this->remapStackChildIds[$idValue] = TRUE;
7689 protected function resolveVersionedRecords($tableName, $fieldNames, $sortingField, array $liveIds) {
7692 'TYPO3\\CMS\\Core\\DataHandling\\PlainDataResolver',
7698 $resolver->setWorkspaceId($this->BE_USER->workspace);
7699 $resolver->setKeepDeletePlaceholder(FALSE);
7700 $resolver->setKeepMovePlaceholder(FALSE);
7701 $resolver->setKeepLiveIds(TRUE);
7702 $recordIds = $resolver->get();
7705 foreach ($recordIds as $recordId) {
7706 $records[$recordId] = BackendUtility::getRecord($tableName, $recordId, $fieldNames);
7720 if (!isset($this->outerMostInstance)) {
7721 $stack = array_reverse(debug_backtrace());
7722 foreach ($stack as $stackItem) {
7723 if (isset($stackItem[
'object']) && $stackItem[
'object'] instanceof \
TYPO3\CMS\Core\DataHandling\
DataHandler) {
7724 $this->outerMostInstance = $stackItem[
'object'];
7762 $nestedElementCalls = (array)$this->runtimeCache->get($this->cachePrefixNestedElementCalls);
7763 return isset($nestedElementCalls[$identifier][$table][$id]);
7776 $nestedElementCalls = (array)$this->runtimeCache->get($this->cachePrefixNestedElementCalls);
7777 $nestedElementCalls[$identifier][$table][$id] = TRUE;
7778 $this->runtimeCache->set($this->cachePrefixNestedElementCalls, $nestedElementCalls);
7787 $this->runtimeCache->remove($this->cachePrefixNestedElementCalls);
7802 $elementsToBeDeleted = (array)$this->runtimeCache->get(
'core-datahandler-elementsToBeDeleted');
7803 return isset($elementsToBeDeleted[$table][$id]);
7813 $elementsToBeDeleted = (array)$this->runtimeCache->get(
'core-datahandler-elementsToBeDeleted');
7814 $this->runtimeCache->set(
'core-datahandler-elementsToBeDeleted', array_merge($elementsToBeDeleted, $this->
getCommandMapElements(
'delete')));
7824 $this->runtimeCache->remove(
'core-datahandler-elementsToBeDeleted');
7836 foreach ($elements as $key => $value) {
7837 if (empty($value)) {
7838 unset($elements[$key]);
7851 $elements = array();
7852 foreach ($this->cmdmap as $tableName => $idArray) {
7853 foreach ($idArray as $id => $commandArray) {
7854 foreach ($commandArray as $command => $value) {
7855 if ($value && $command == $needle) {
7856 $elements[$tableName][$id] = TRUE;
7871 if (!empty($this->control[
'active'])) {
7873 $this->control[
'active'],
7889 foreach ($active as $key => $value) {
7891 if (is_array($value)) {
7898 } elseif ($value == 0) {
7899 $haystack[$key] = NULL;
7911 return 'core-datahandler-eval-' . md5($additionalIdentifier);
7937 return \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
version_remapMMForVersionSwap_execSwap($table, $id, $swapWith)
getRecordProperties($table, $id, $noWSOL=FALSE)
addNewValuesToRemapStackChildIds(array $idValues)
static idnaEncode($value)
updateFlexFormData($flexFormId, array $modifications)
$isRecordInWebMount_Cache
static stripSlashesOnArray(array &$theArray)
static getTSconfig_pidValue($table, $uid, $pid)
int_pageTreeInfo($CPtable, $pid, $counter, $rootID)
copyRecord_fixRTEmagicImages($table, $theNewSQLID)
static $recordPidsForDeletedRecords
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
moveRecord_procBasedOnFieldType($table, $uid, $destPid, $field, $value, $conf)
applyFiltersToValues(array $tcaFieldConfiguration, array $values)
checkValue_flex($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field)
static getRecordWSOL($table, $uid, $fields=' *', $where='', $useDeleteClause=TRUE, $unsetMovePointers=FALSE)
doesBranchExist($inList, $pid, $perms, $recurse)
$dontProcessTransformations
getOriginalParentOfRecord($table, $uid)
static mkdir_deep($directory, $deepDirectory='')
clearPrefixFromValue($table, $value)
static getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields=' *')
hook_processDatamap_afterDatabaseOperations(&$hookObjectsArr, &$status, &$table, &$id, &$fieldArray)
getPreviousLocalizedRecordUid($table, $uid, $pid, $language)
static writeFile($file, $content, $changePermissions=FALSE)
getUnique($table, $field, $value, $id, $newPid=0)
static setValueByPath(array $array, $path, $value, $delimiter='/')
checkValue_text_Eval($value, $evalArray, $is_in)
deleteAction($table, $id)
insertNewCopyVersion($table, $fieldArray, $realPid)
static getItemLabel($table, $col, $printAllWrap='')
static getRecordsByField($theTable, $theField, $theValue, $whereClause='', $groupBy='', $orderBy='', $limit='', $useDeleteClause=TRUE)
eventPid($table, $uid, $pid)
deleteL10nOverlayRecords($table, $uid)
fixUniqueInPid($table, $uid)
isElementToBeDeleted($table, $id)
static isTableWorkspaceEnabled($table)
static getTCAtypeValue($table, $row)
clear_cacheCmd($cacheCmd)
checkStoredRecord($table, $id, $fieldArray, $action)
copyRecord_flexFormCallBack($pParams, $dsConf, $dataValue, $_1, $_2, $_3=null, $workspaceOptions=array())
checkValue($table, $field, $value, $id, $status, $realPid, $tscPID)
overrideFieldArray($table, $data)
static isFirstPartOfStr($str, $partStr)
addRemapStackRefIndex($table, $id)
clear_cache($table, $uid)
isRecordInWebMount($table, $id)
fixCopyAfterDuplFields($table, $uid, $prevUid, $update, $newData=array())
setTSconfigPermissions($fieldArray, $TSConfig_p)
convNumEntityToByteValue($input)
$checkStoredRecords_loose
static workspaceOL($table, &$row, $wsid=-99, $unsetMovePointers=FALSE)
moveRecord_procFields($table, $uid, $destPid)
checkValue_radio($res, $value, $tcaFieldConf, $PP)
assemblePermissions($string)
versionizeRecord($table, $id, $label, $delete=FALSE)
checkValue_inline($res, $value, $tcaFieldConf, $PP, $field, array $additionalData=NULL)
setNullValues(array $active, array &$haystack)
static canBeInterpretedAsInteger($var)
deleteVersionsForRecord($table, $uid, $forceHardDelete)
resetElementsToBeDeleted()
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
registerNestedElementCall($table, $id, $identifier)
static getMovePlaceholder($table, $uid, $fields=' *', $workspace=NULL)
moveL10nOverlayRecords($table, $uid, $destPid, $originalRecordDestinationPid)
getTCEMAIN_TSconfig($tscPID)
setHistory($table, $id, $logId)
registerElementsToBeDeleted()
checkValue_check($res, $value, $tcaFieldConf, $PP, $field='')
start($data, $cmd, $altUserObject='')
static logDeprecatedFunction()
unsetElementsToBeDeleted(array $elements)
deleteRecord_flexFormCallBack($dsArr, $dataValue, $PA, $structurePath, $pObj)
triggerRemapAction($table, $id, array $callback, array $arguments, $forceRemapStackActions=FALSE)
getRecordsWithSameValue($tableName, $uid, $fieldName, $value, $pageId=0)
static makeInstance($className)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
copyRecord_raw($table, $uid, $pid, $overrideArray=array(), array $workspaceOptions=array())
static getFlexFormDS($conf, $row, $table, $fieldName='', $WSOL=TRUE, $newRecordPidValue=0)
$updateModeL10NdiffDataClear
copyMovedRecordToNewLocation($table, $uid)
overlayAutoVersionId($table, $id)
checkValue_flex_procInData_travDS(&$dataValues, $dataValues_current, $uploadedFiles, $DSelements, $pParams, $callBackFunc, $structurePath, $workspaceOptions=array())
deleteRecord($table, $uid, $noRecordCheck=FALSE, $forceHardDelete=FALSE, $undeleteRecord=FALSE)
resorting($table, $pid, $sortRow, $return_SortNumber_After_This_Uid)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
undeleteRecord($table, $uid)
getCheckModifyAccessListHookObjects()
getTableEntries($table, $TSconfig)
static getTSCpid($table, $uid, $pid)
static wsMapId($table, $uid)
doesRecordExist($table, $id, $perms)
addRemapAction($table, $id, array $callback, array $arguments)
checkValue_SW($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $field, $uploadedFiles, $tscPID, array $additionalData=NULL)
insertUpdateDB_preprocessBasedOnFieldType($table, $fieldArray)
static getRecordTitle($table, $row, $prep=FALSE, $forceResult=TRUE)
$cachePrefixNestedElementCalls
getRecordPropertiesFromRow($table, $row)
static getLiveVersionIdOfRecord($table, $uid)
static isWebMountRestrictionIgnored($table)
moveRecord($table, $uid, $destPid)
destPathFromUploadFolder($folder)
updateDB($table, $id, $fieldArray)
placeholderShadowing($table, $id)
$bypassAccessCheckForRecords
static getInlineLocalizationMode($table, $fieldOrConfig)
static split_fileref($fileNameWithPath)
static deprecationLog($msg)
prepareCacheFlush($table, $uid, $pid)
checkValue_group_select_explodeSelectGroupValue($value)
checkRecordUpdateAccess($table, $id, $data=FALSE, &$hookObjectsArr=FALSE)
$bypassWorkspaceRestrictions
setDefaultsFromUserTS($userTS)
static isRootLevelRestrictionIgnored($table)
destNotInsideSelf($dest, $id)
static resolveSheetDefInDS($dataStructArray, $sheet='sDEF')
checkValue_input_Eval($value, $evalArray, $is_in)
getVersionizedIncomingFieldArray($table, $id, &$incomingFieldArray, &$registerDBList)
isTableAllowedForThisPage($page_uid, $checkTable)
compareFieldArrayWithCurrentAndUnset($table, $id, $fieldArray)
remapListedDBRecords_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2)
internal_clearPageCache()
registerRecordIdForPageCacheClearing($table, $uid, $pid=null)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
static getUrl($url, $includeHeader=0, $requestHeaders=FALSE, &$report=NULL)
checkValue_flex_procInData($dataPart, $dataPart_current, $uploadedFiles, $dataStructArray, $pParams, $callBackFunc='', $workspaceOptions=array())
static getRecordLocalization($table, $uid, $language, $andWhereClause='')
deleteEl($table, $uid, $noRecordCheck=FALSE, $forceHardDelete=FALSE)
checkRecordInsertAccess($insertTable, $pid, $action=1)
getPlaceholderTitleForTableLabel($table, $placeholderContent=NULL)
deleteSpecificPage($uid, $forceHardDelete=FALSE)
static fixWindowsFilePath($theFile)
log($table, $recuid, $action, $recpid, $error, $details, $details_nr=-1, $data=array(), $event_pid=-1, $NEWid='')
checkValue_checkMax($tcaFieldConf, $valueArray)
getAutoVersionId($table, $id)
static getTCAtypes($table, $rec, $useFieldNameAsKey=0)
resetNestedElementCalls()
addDefaultPermittedLanguageIfNotSet($table, &$incomingFieldArray)
static getRecordRaw($table, $where='', $fields=' *')
isSubmittedValueEqualToStoredValue($submittedValue, $storedValue, $storedType, $allowNull=FALSE)
$checkValue_currentRecord
doesPageHaveUnallowedTables($page_uid, $doktype)
static RTEsetup($RTEprop, $table, $field, $type='')
getInlineFieldType($conf)
static formatSize($sizeInBytes, $labels='')
debug($variable='', $name=' *variable *', $line=' *line *', $file=' *file *', $recursiveDepth=3, $debugLevel=E_DEBUG)
$checkModifyAccessListHookObjects
static array_merge(array $arr1, array $arr2)
static selectVersionsOfRecord($table, $uid, $fields=' *', $workspace=0, $includeDeletedRecords=FALSE, $row=NULL)
copySpecificPage($uid, $destPid, $copyTablesArray, $first=0)
setControl(array $control)
getCopyHeader($table, $pid, $field, $value, $count, $prevTitle='')
cannotDeleteRecord($table, $id)
static fixVersioningPid($table, &$rr, $ignoreWorkspaceMatch=FALSE)
_ACTION_FLEX_FORMdata(&$valueArray, $actionCMDs)
deleteRecord_procFields($table, $uid, $undeleteRecord=FALSE)
static getOriginalTranslationTable($table)
getCommandMapElements($needle)
static getSpecConfParts($str, $defaultExtras)
$clear_flexFormData_vDEFbase
checkValue_text($res, $value, $tcaFieldConf, $PP, $field='')
static getLiveVersionOfRecord($table, $uid, $fields=' *')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
newlog($message, $error=0)
static removeArrayEntryByValue(array $array, $cmpValue)
process_uploads_traverseArray(&$outputArr, $inputArr, $keyToSet)
$version_remapMMForVersionSwap_reg
static inList($list, $item)
static xml2array($string, $NSprefix='', $reportDocTag=FALSE)
noRecordsFromUnallowedTables($inList)
moveRecord_raw($table, $uid, $destPid)
static getFileAbsFileName($filename, $onlyRelative=TRUE, $relToTYPO3_mainDir=FALSE)
deletePages($uid, $force=FALSE, $forceHardDelete=FALSE)
copyPages($uid, $destPid)
static stripPathSitePrefix($path)
static evalWriteFile($pArr, $currentRecord)
static getPagesTSconfig($id, $rootLine=NULL, $returnPartArray=FALSE)
process_uploads($postFiles)
static isTableLocalizable($table)
const NEW_PLACEHOLDER_VERSION
static arrayDiffAssocRecursive(array $array1, array $array2)
static $recordsToClearCacheFor
copyL10nOverlayRecords($table, $uid, $destPid, $first=0, $overrideValues=array(), $excludeFields='')
checkValue_group_select($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field)
remapListedDBRecords_procDBRefs($conf, $value, $MM_localUid, $table)
extFileFunctions($table, $field, $filelist, $func)
static deleteClause($table, $tableAlias='')
doesRecordExist_pageLookUp($id, $perms)
isNestedElementCallRegistered($table, $id, $identifier)
insertDB($table, $id, $fieldArray, $newVersion=FALSE, $suggestedUid=0, $dontSetNewIdIndex=FALSE)
checkValue_input($res, $value, $tcaFieldConf, $PP, $field='')
static upload_copy_move($source, $destination)
newlog2($message, $table, $uid, $pid=FALSE, $error=0)
getLocalTCE($stripslashesValues=FALSE, $dontProcessTransformations=TRUE)
getSortNumber($table, $uid, $pid)
isRecordUndeletable($table, $uid)
createRelationHandlerInstance()
getFieldEvalCacheIdentifier($additionalIdentifier)
isRecordCopied($table, $uid)