2 namespace TYPO3\CMS\Core\DataHandling;
333 public $pagetreeRefreshFieldsFromPages = array(
'pid',
'sorting',
'deleted',
'hidden',
'title',
'doktype',
'is_siteroot',
'fe_group',
'nav_hide',
'nav_title',
'module',
'starttime',
'endtime',
'content_from_pid');
383 'user' =>
'show,edit,delete,new,editcontent',
384 'group' =>
'show,edit,new,editcontent',
699 $this->databaseConnection =
$GLOBALS[
'TYPO3_DB'];
721 public function start($data, $cmd, $altUserObject = null)
724 $this->BE_USER = is_object($altUserObject) ? $altUserObject :
$GLOBALS[
'BE_USER'];
725 $this->userid = $this->BE_USER->user[
'uid'];
726 $this->username = $this->BE_USER->user[
'username'];
727 $this->admin = $this->BE_USER->user[
'admin'];
728 if ($this->BE_USER->uc[
'recursiveDelete']) {
729 $this->deleteTree = 1;
731 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'explicitConfirmationOfTranslation'] && $this->updateModeL10NdiffData ===
true) {
732 $this->updateModeL10NdiffData =
false;
750 if (is_array($data)) {
752 $this->datamap = $data;
754 if (is_array($cmd)) {
756 $this->cmdmap = $cmd;
769 if (!is_array($mirror)) {
773 foreach ($mirror as $table => $uid_array) {
774 if (!isset($this->datamap[$table])) {
778 foreach ($uid_array as $id => $uidList) {
779 if (!isset($this->datamap[$table][$id])) {
784 foreach ($theIdsInArray as $copyToUid) {
785 $this->datamap[$table][$copyToUid] = $this->datamap[$table][$id];
799 if (!is_array($userTS)) {
803 foreach ($userTS as $k => $v) {
804 $k = substr($k, 0, -1);
805 if (!$k || !is_array($v) || !isset(
$GLOBALS[
'TCA'][$k])) {
809 if (is_array($this->defaultValues[$k])) {
810 $this->defaultValues[$k] = array_merge($this->defaultValues[$k], $v);
812 $this->defaultValues[$k] = $v;
826 if (!is_array($postFiles)) {
831 if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec[
'freeze']) {
832 if ($this->enableLogging) {
833 $this->
newlog(
'All editing in this workspace has been frozen!', 1);
837 $subA = reset($postFiles);
838 if (is_array($subA)) {
839 if (is_array($subA[
'name']) && is_array($subA[
'type']) && is_array($subA[
'tmp_name']) && is_array($subA[
'size'])) {
841 $this->uploadedFileArray = array();
843 foreach ($subA as $key => $values) {
847 $this->uploadedFileArray = $subA;
864 if (is_array($inputArr)) {
865 foreach ($inputArr as $key => $value) {
869 $outputArr[$keyToSet] = $inputArr;
895 if (!isset($this->remapStackRecords[$table][$id])) {
896 foreach ($hookObjectsArr as $hookObj) {
897 if (method_exists($hookObj,
'processDatamap_afterDatabaseOperations')) {
898 $hookObj->processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $this);
902 $this->remapStackRecords[$table][$id][
'processDatamap_afterDatabaseOperations'] = array(
904 'fieldArray' => $fieldArray,
905 'hookObjectsArr' => $hookObjectsArr
919 if (!isset($this->checkModifyAccessListHookObjects)) {
920 $this->checkModifyAccessListHookObjects = array();
921 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkModifyAccessList'])) {
922 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkModifyAccessList'] as $classData) {
925 throw new \UnexpectedValueException(
'$hookObject must implement interface \\TYPO3\\CMS\\Core\\DataHandling\\DataHandlerCheckModifyAccessListHookInterface', 1251892472);
927 $this->checkModifyAccessListHookObjects[] = $hookObject;
945 public function process_datamap()
954 if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec[
'freeze']) {
955 if ($this->enableLogging) {
956 $this->
newlog(
'All editing in this workspace has been frozen!', 1);
961 $hookObjectsArr = array();
962 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processDatamapClass'])) {
963 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processDatamapClass'] as $classRef) {
965 if (method_exists($hookObject,
'processDatamap_beforeStart')) {
966 $hookObject->processDatamap_beforeStart($this);
968 $hookObjectsArr[] = $hookObject;
972 $orderOfTables = array();
974 if (isset($this->datamap[
'pages'])) {
975 $orderOfTables[] =
'pages';
977 $orderOfTables = array_unique(array_merge($orderOfTables, array_keys($this->datamap)));
979 foreach ($orderOfTables as $table) {
985 $modifyAccessList = $this->checkModifyAccessList($table);
986 if ($this->enableLogging && !$modifyAccessList) {
987 $this->
log($table, 0, 2, 0, 1,
'Attempt to modify table \'%s\' without permission', 1, array($table));
989 if (!isset(
$GLOBALS[
'TCA'][$table]) || $this->
tableReadOnly($table) || !is_array($this->datamap[$table]) || !$modifyAccessList) {
993 if ($this->reverseOrder) {
994 $this->datamap[$table] = array_reverse($this->datamap[$table], 1);
999 foreach ($this->datamap[$table] as $id => $incomingFieldArray) {
1000 if (!is_array($incomingFieldArray)) {
1006 $dateTimeFormats = $this->databaseConnection->getDateTimeFormats($table);
1007 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $column => $config) {
1008 if (isset($incomingFieldArray[$column])) {
1009 if (isset($config[
'config'][
'dbType']) && ($config[
'config'][
'dbType'] ===
'date' || $config[
'config'][
'dbType'] ===
'datetime')) {
1010 $emptyValue = $dateTimeFormats[$config[
'config'][
'dbType']][
'empty'];
1011 $format = $dateTimeFormats[$config[
'config'][
'dbType']][
'format'];
1012 $incomingFieldArray[$column] = $incomingFieldArray[$column] ? gmdate($format, $incomingFieldArray[$column]) : $emptyValue;
1017 foreach ($hookObjectsArr as $hookObj) {
1018 if (method_exists($hookObj,
'processDatamap_preProcessFieldArray')) {
1019 $hookObj->processDatamap_preProcessFieldArray($incomingFieldArray, $table, $id, $this);
1025 $createNewVersion =
false;
1026 $recordAccess =
false;
1027 $old_pid_value =
'';
1028 $this->autoVersioningUpdate =
false;
1034 if (isset($incomingFieldArray[
'pid'])) {
1036 $pid_value = $incomingFieldArray[
'pid'];
1040 if (strstr($pid_value,
'NEW')) {
1041 if ($pid_value[0] ===
'-') {
1043 $pid_value = substr($pid_value, 1);
1048 if (isset($this->substNEWwithIDs[$pid_value])) {
1049 if ($negFlag === 1) {
1050 $old_pid_value = $this->substNEWwithIDs[$pid_value];
1052 $pid_value = (int)($negFlag * $this->substNEWwithIDs[$pid_value]);
1057 $pid_value = (int)$pid_value;
1060 $sortRow =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
1062 if ($pid_value >= 0) {
1065 $fieldArray[$sortRow] = $this->
getSortNumber($table, 0, $pid_value);
1068 $fieldArray[
'pid'] = $pid_value;
1075 $fieldArray[
'pid'] = $tempArray[
'pid'];
1076 $fieldArray[$sortRow] = $tempArray[
'sortNumber'];
1079 $tempdata = $this->
recordInfo($table, abs($pid_value),
'pid');
1080 $fieldArray[
'pid'] = $tempdata[
'pid'];
1085 $theRealPid = $fieldArray[
'pid'];
1087 if ($theRealPid >= 0) {
1090 if ($recordAccess) {
1092 $recordAccess = $this->BE_USER->recordEditAccessInternals($table, $incomingFieldArray,
true);
1093 if (!$recordAccess) {
1094 if ($this->enableLogging) {
1095 $this->
newlog(
'recordEditAccessInternals() check failed. [' . $this->BE_USER->errorMsg .
']', 1);
1097 }
elseif (!$this->bypassWorkspaceRestrictions) {
1100 if ($res = $this->BE_USER->workspaceAllowLiveRecordsInPID($theRealPid, $table)) {
1102 $recordAccess =
false;
1103 if ($this->enableLogging) {
1104 $this->
newlog(
'Stage for versioning root point and users access level did not allow for editing', 1);
1109 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
1110 $createNewVersion =
true;
1112 $recordAccess =
false;
1113 if ($this->enableLogging) {
1114 $this->
newlog(
'Record could not be created in this workspace in this branch', 1);
1121 debug(
'Internal ERROR: pid should not be less than zero!');
1127 $fieldArray = array();
1129 if (!$recordAccess) {
1130 if ($this->enableLogging) {
1132 $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']);
1137 $recordAccess = $this->BE_USER->recordEditAccessInternals($table, $id);
1138 if (!$recordAccess) {
1139 if ($this->enableLogging) {
1140 $this->
newlog(
'recordEditAccessInternals() check failed. [' . $this->BE_USER->errorMsg .
']', 1);
1144 $tempdata = $this->
recordInfo($table, $id,
'pid' . (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] ?
',t3ver_wsid,t3ver_stage' :
''));
1145 $theRealPid = $tempdata[
'pid'];
1148 if ($this->autoVersionIdMap[$table][$id]) {
1153 $id = $this->autoVersionIdMap[$table][$id];
1154 $recordAccess =
true;
1155 $this->autoVersioningUpdate =
true;
1156 }
elseif (!$this->bypassWorkspaceRestrictions && ($errorCode = $this->BE_USER->workspaceCannotEditRecord($table, $tempdata))) {
1157 $recordAccess =
false;
1162 $id = $WSversion[
'uid'];
1163 $recordAccess =
true;
1164 }
elseif ($this->BE_USER->workspaceAllowAutoCreation($table, $id, $theRealPid)) {
1166 $this->pagetreeNeedsRefresh =
true;
1170 $tce->stripslashes_values =
false;
1173 $cmd[$table][$id][
'version'] = array(
1177 'label' =>
'Auto-created for WS #' . $this->BE_USER->workspace
1179 $tce->start(array(), $cmd);
1180 $tce->process_cmdmap();
1181 $this->errorLog = array_merge($this->errorLog, $tce->errorLog);
1183 if ($tce->copyMappingArray[$table][$id]) {
1184 foreach ($tce->copyMappingArray as $origTable => $origIdArray) {
1185 foreach ($origIdArray as $origId => $newId) {
1186 $this->uploadedFileArray[$origTable][$newId] = $this->uploadedFileArray[$origTable][$origId];
1187 $this->autoVersionIdMap[$origTable][$origId] = $newId;
1198 $id = $this->autoVersionIdMap[$table][$id];
1199 $recordAccess =
true;
1200 $this->autoVersioningUpdate =
true;
1201 }
elseif ($this->enableLogging) {
1202 $this->
newlog(
'Could not be edited in offline workspace in the branch where found (failure state: \'' . $errorCode .
'\'). Auto-creation of version failed!
', 1);
1204 } elseif ($this->enableLogging) {
1205 $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);
1209 // The default is 'update
'
1212 // If access was granted above, proceed to create or update record:
1213 if (!$recordAccess) {
1217 // Here the "pid" is set IF NOT the old pid was a string pointing to a place in the subst-id array.
1218 list($tscPID) = BackendUtility::getTSCpid($table, $id, $old_pid_value ? $old_pid_value : $fieldArray['pid
']);
1219 if ($status === 'new' && $table === 'pages
') {
1220 $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
1221 if (isset($TSConfig['permissions.
']) && is_array($TSConfig['permissions.
'])) {
1222 $fieldArray = $this->setTSconfigPermissions($fieldArray, $TSConfig['permissions.
']);
1225 // Processing of all fields in incomingFieldArray and setting them in $fieldArray
1226 $fieldArray = $this->fillInFieldArray($table, $id, $fieldArray, $incomingFieldArray, $theRealPid, $status, $tscPID);
1227 $newVersion_placeholderFieldArray = array();
1228 if ($createNewVersion) {
1229 // create a placeholder array with already processed field content
1230 $newVersion_placeholderFieldArray = $fieldArray;
1232 // NOTICE! All manipulation beyond this point bypasses both "excludeFields" AND possible "MM" relations / file uploads to field!
1233 // Forcing some values unto field array:
1234 // NOTICE: This overriding is potentially dangerous; permissions per field is not checked!!!
1235 $fieldArray = $this->overrideFieldArray($table, $fieldArray);
1236 if ($createNewVersion) {
1237 $newVersion_placeholderFieldArray = $this->overrideFieldArray($table, $newVersion_placeholderFieldArray);
1239 // Setting system fields
1240 if ($status == 'new
') {
1241 if ($GLOBALS['TCA
'][$table]['ctrl
']['crdate
']) {
1242 $fieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['crdate
']] = $GLOBALS['EXEC_TIME
'];
1243 if ($createNewVersion) {
1244 $newVersion_placeholderFieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['crdate
']] = $GLOBALS['EXEC_TIME
'];
1247 if ($GLOBALS['TCA
'][$table]['ctrl
']['cruser_id
']) {
1248 $fieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['cruser_id
']] = $this->userid;
1249 if ($createNewVersion) {
1250 $newVersion_placeholderFieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['cruser_id
']] = $this->userid;
1253 } elseif ($this->checkSimilar) {
1254 // Removing fields which are equal to the current value:
1255 $fieldArray = $this->compareFieldArrayWithCurrentAndUnset($table, $id, $fieldArray);
1257 if ($GLOBALS['TCA
'][$table]['ctrl
']['tstamp
'] && !empty($fieldArray)) {
1258 $fieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['tstamp
']] = $GLOBALS['EXEC_TIME
'];
1259 if ($createNewVersion) {
1260 $newVersion_placeholderFieldArray[$GLOBALS['TCA
'][$table]['ctrl
']['tstamp
']] = $GLOBALS['EXEC_TIME
'];
1263 // Set stage to "Editing" to make sure we restart the workflow
1264 if ($GLOBALS['TCA
'][$table]['ctrl
']['versioningWS
']) {
1265 $fieldArray['t3ver_stage
'] = 0;
1267 // Hook: processDatamap_postProcessFieldArray
1268 foreach ($hookObjectsArr as $hookObj) {
1269 if (method_exists($hookObj, 'processDatamap_postProcessFieldArray
')) {
1270 $hookObj->processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $this);
1273 // Performing insert/update. If fieldArray has been unset by some userfunction (see hook above), don't
do anything
1275 if (is_array($fieldArray)) {
1276 if ($status ==
'new') {
1277 if ($table ===
'pages') {
1279 $this->pagetreeNeedsRefresh =
true;
1283 if ($createNewVersion) {
1285 $this->pagetreeNeedsRefresh =
true;
1287 $newVersion_placeholderFieldArray[
't3ver_label'] =
'INITIAL PLACEHOLDER';
1291 $newVersion_placeholderFieldArray[
't3ver_wsid'] = $this->BE_USER->workspace;
1294 $this->
insertDB($table, $id, $newVersion_placeholderFieldArray,
false);
1296 $fieldArray[
'pid'] = -1;
1297 $fieldArray[
't3ver_oid'] = $this->substNEWwithIDs[$id];
1298 $fieldArray[
't3ver_id'] = 1;
1301 $fieldArray[
't3ver_label'] =
'First draft version';
1302 $fieldArray[
't3ver_wsid'] = $this->BE_USER->workspace;
1304 $phShadowId = $this->
insertDB($table, $id, $fieldArray,
true, 0,
true);
1307 $this->
triggerRemapAction($table, $id, array($this,
'placeholderShadowing'), array($table, $phShadowId));
1309 $this->autoVersionIdMap[$table][$this->substNEWwithIDs[$id]] = $phShadowId;
1312 $this->
insertDB($table, $id, $fieldArray,
false, $incomingFieldArray[
'uid']);
1315 if ($table ===
'pages') {
1318 $fieldsToCheck = array_intersect($this->pagetreeRefreshFieldsFromPages, array_keys($fieldArray));
1319 if (!empty($fieldsToCheck)) {
1320 $this->pagetreeNeedsRefresh =
true;
1323 $this->
updateDB($table, $id, $fieldArray);
1339 foreach ($hookObjectsArr as $hookObj) {
1340 if (method_exists($hookObj,
'processDatamap_afterAllOperations')) {
1341 $hookObj->processDatamap_afterAllOperations($this);
1345 $this->processClearCacheQueue();
1362 $newRecord = array();
1363 $shadowCols = $GLOBALS[
'TCA'][$table][
'ctrl'][
'shadowColumnsForNewPlaceholders'];
1364 $shadowCols .=
',' . $GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'];
1365 $shadowCols .=
',' . $GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'];
1366 $shadowCols .=
',' . $GLOBALS[
'TCA'][$table][
'ctrl'][
'type'];
1367 $shadowCols .=
',' . $GLOBALS[
'TCA'][$table][
'ctrl'][
'label'];
1369 foreach ($shadowColumns as $fieldName) {
1370 if ((
string)$justStoredRecord[$fieldName] !== (
string)$liveRec[$fieldName] && isset($GLOBALS[
'TCA'][$table][
'columns'][$fieldName]) && $fieldName !==
'uid' && $fieldName !==
'pid') {
1371 $newRecord[$fieldName] = $justStoredRecord[$fieldName];
1374 if (!empty($newRecord)) {
1375 if ($this->enableLogging) {
1376 $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']);
1378 $this->
updateDB($table, $liveRec[
'uid'], $newRecord);
1393 if ($placeholderContent === null) {
1394 $placeholderContent =
'PLACEHOLDER';
1397 $labelPlaceholder =
'[' . $placeholderContent .
', WS#' . $this->BE_USER->workspace .
']';
1398 $labelField = $GLOBALS[
'TCA'][$table][
'ctrl'][
'label'];
1399 if (!isset($GLOBALS[
'TCA'][$table][
'columns'][$labelField][
'config'][
'eval'])) {
1400 return $labelPlaceholder;
1404 return isset($transformedLabel[
'value']) ? $transformedLabel[
'value'] : $labelPlaceholder;
1420 public function fillInFieldArray($table, $id, $fieldArray, $incomingFieldArray, $realPid, $status, $tscPID)
1423 $originalLanguageRecord = null;
1424 $originalLanguage_diffStorage = null;
1425 $diffStorageFlag =
false;
1427 if (strstr($id,
'NEW')) {
1429 $currentRecord = ($checkValueRecord = $fieldArray);
1432 if (is_array($incomingFieldArray) && is_array($checkValueRecord)) {
1437 $currentRecord = ($checkValueRecord = $this->
recordInfo($table, $id,
'*'));
1441 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) {
1442 $lookUpTable = $GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable'] ?: $table;
1443 $originalLanguageRecord = $this->
recordInfo($lookUpTable, $currentRecord[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']],
'*');
1445 $originalLanguage_diffStorage = unserialize($currentRecord[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField']]);
1448 $this->checkValue_currentRecord = $checkValueRecord;
1455 foreach ($incomingFieldArray as $field => $fieldValue) {
1456 if (isset($this->excludedTablesAndFields[$table .
'-' . $field]) || $this->data_disableFields[$table][$id][$field]) {
1462 $languageDeny = $GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] && (string)$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] === (
string)$field && !$this->BE_USER->checkLanguageAccess($fieldValue);
1463 if ($languageDeny) {
1469 if ($this->stripslashes_values) {
1471 'The option stripslash_values is typically set to FALSE as data should be properly prepared before sending to DataHandler. Do not rely on DataHandler removing extra slashes. The option will be removed in TYPO3 CMS 8.'
1473 if (is_array($fieldValue)) {
1476 $fieldValue = stripslashes($fieldValue);
1484 case 'perms_userid':
1485 case 'perms_groupid':
1488 case 'perms_everybody':
1490 if ($table ==
'pages' && ($this->admin || $status ==
'new' || $this->
pageInfo($id,
'perms_userid') == $this->userid)) {
1491 $value = (int)$fieldValue;
1493 case 'perms_userid':
1494 $fieldArray[$field] = $value;
1496 case 'perms_groupid':
1497 $fieldArray[$field] = $value;
1500 if ($value >= 0 && $value < pow(2, 5)) {
1501 $fieldArray[$field] = $value;
1512 case 't3ver_tstamp':
1516 if (isset($GLOBALS[
'TCA'][$table][
'columns'][$field])) {
1518 $res = $this->
checkValue($table, $field, $fieldValue, $id, $status, $realPid, $tscPID);
1519 if (array_key_exists(
'value', $res)) {
1520 $fieldArray[$field] = $res[
'value'];
1523 if ($this->updateModeL10NdiffData && $GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField']) {
1524 $originalLanguage_diffStorage[$field] = $this->updateModeL10NdiffDataClear ?
'' : $originalLanguageRecord[$field];
1525 $diffStorageFlag =
true;
1532 if ($this->autoVersioningUpdate ===
true) {
1533 if (is_array($this->RTEmagic_copyIndex[$table][$id][$field])) {
1534 foreach ($this->RTEmagic_copyIndex[$table][$id][$field] as $oldRTEmagicName => $newRTEmagicName) {
1535 $fieldArray[$field] = str_replace(
' src="' . $oldRTEmagicName .
'"',
' src="' . $newRTEmagicName .
'"', $fieldArray[$field]);
1539 }
elseif ($GLOBALS[
'TCA'][$table][
'ctrl'][
'origUid'] === $field) {
1541 $fieldArray[$field] = $fieldValue;
1546 if ($diffStorageFlag && !isset($fieldArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField']])) {
1548 $fieldArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField']] = serialize($originalLanguage_diffStorage);
1552 $theTypeString = null;
1553 if (is_array($types_fieldConfig)) {
1554 foreach ($types_fieldConfig as $vconf) {
1556 if ($this->dontProcessTransformations || !isset($fieldArray[$vconf[
'field']])) {
1561 if ((
string)$incomingFieldArray[(
'_TRANSFORM_' . $vconf[
'field'])] ===
'RTE') {
1562 if ($theTypeString === null) {
1568 $fieldArray[$vconf[
'field']], $table, $vconf[
'field'], $vconf[
'spec'], $thisConfig, $currentRecord[
'pid']
1590 if ($defaultExtras[
'rte_transform']) {
1593 if ($parameters[
'mode']) {
1596 $parseHTML->init($table .
':' . $field, $pid);
1597 $parseHTML->setRelPath(
'');
1599 $value = $parseHTML->RTE_transform($value, $defaultExtras,
'db', $thisConfig);
1625 public function checkValue($table, $field, $value, $id, $status, $realPid, $tscPID)
1631 if (($table ===
'pages' || $table ===
'pages_language_overlay') && $field ===
'doktype') {
1634 if ($this->enableLogging) {
1636 $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']);
1640 if ($status ==
'update') {
1642 $onlyAllowedTables = isset($GLOBALS[
'PAGES_TYPES'][$value][
'onlyAllowedTables']) ? $GLOBALS[
'PAGES_TYPES'][$value][
'onlyAllowedTables'] : $GLOBALS[
'PAGES_TYPES'][
'default'][
'onlyAllowedTables'];
1643 if ($onlyAllowedTables) {
1645 if ($theWrongTables) {
1646 if ($this->enableLogging) {
1648 $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']);
1657 if ((
int)$id !== 0) {
1659 $curValueRec = $this->
recordInfo($table, $id, $field);
1661 if ($curValueRec !== null && array_key_exists($field, $curValueRec)) {
1662 $curValue = $curValueRec[$field];
1667 $tcaFieldConf = $GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
1671 $tcaFieldConf[
'type'] ===
'flex'
1672 || $tcaFieldConf[
'type'] ===
'group' && ($tcaFieldConf[
'internal_type'] ===
'file' || $tcaFieldConf[
'internal_type'] ===
'file_reference')
1674 $recFID = $table .
':' . $id .
':' . $field;
1680 $res = $this->
checkValue_SW($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $field, $this->uploadedFileArray[$table][$id][$field], $tscPID);
1703 public function checkValue_SW($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $field, $uploadedFiles, $tscPID, array $additionalData = null)
1706 if ($value === null && !empty($tcaFieldConf[
'eval']) &&
GeneralUtility::inList($tcaFieldConf[
'eval'],
'null')) {
1707 $res = array(
'value' => null);
1711 switch ($tcaFieldConf[
'type']) {
1716 case 'imageManipulation':
1718 $res[
'value'] = $value;
1721 $res = $this->
checkValueForInput($value, $tcaFieldConf, $table, $id, $realPid, $field);
1724 $res = $this->
checkValueForCheck($res, $value, $tcaFieldConf, $table, $id, $realPid, $field);
1727 $res = $this->
checkValueForRadio($res, $value, $tcaFieldConf, $table, $id, $realPid, $field);
1731 $res = $this->
checkValueForGroupSelect($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $recFID, $uploadedFiles, $field);
1734 $res = $this->
checkValueForInline($res, $value, $tcaFieldConf, $table, $id, $status, $field, $additionalData);
1739 $res = $this->
checkValueForFlex($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $tscPID, $uploadedFiles, $field);
1774 if (!isset($tcaFieldConf[
'eval']) || $tcaFieldConf[
'eval'] ===
'') {
1775 return array(
'value' => $value);
1778 if ($this->runtimeCache->has($cacheId)) {
1779 $evalCodesArray = $this->runtimeCache->get($cacheId);
1782 $this->runtimeCache->set($cacheId, $evalCodesArray);
1801 list($table, $id, , , $realPid) = $PP;
1802 return $this->
checkValueForInput($value, $tcaFieldConf, $table, $id, $realPid, $field);
1819 $isDateOrDateTimeField =
false;
1822 if (isset($tcaFieldConf[
'dbType']) && ($tcaFieldConf[
'dbType'] ===
'date' || $tcaFieldConf[
'dbType'] ===
'datetime')) {
1823 $isDateOrDateTimeField =
true;
1824 $dateTimeFormats = $this->databaseConnection->getDateTimeFormats($table);
1826 $emptyValue = $dateTimeFormats[$tcaFieldConf[
'dbType']][
'empty'];
1827 $format = $dateTimeFormats[$tcaFieldConf[
'dbType']][
'format'];
1829 $timeZone = new \DateTimeZone(
'UTC');
1830 $dateTime = \DateTime::createFromFormat(
'!' . $format, $value, $timeZone);
1831 $value = $value === $emptyValue ? 0 : $dateTime->getTimestamp();
1834 if ((
int)$tcaFieldConf[
'max'] > 0) {
1835 $value = $GLOBALS[
'LANG']->csConvObj->substr($GLOBALS[
'LANG']->charSet, (
string)$value, 0, (
int)$tcaFieldConf[
'max']);
1839 if ($tcaFieldConf[
'range'] && $value != $tcaFieldConf[
'checkbox'] && (
int)$value !== (
int)$tcaFieldConf[
'default']) {
1840 if (isset($tcaFieldConf[
'range'][
'upper']) && (
int)$value > (
int)$tcaFieldConf[
'range'][
'upper']) {
1841 $value = $tcaFieldConf[
'range'][
'upper'];
1843 if (isset($tcaFieldConf[
'range'][
'lower']) && (
int)$value < (
int)$tcaFieldConf[
'range'][
'lower']) {
1844 $value = $tcaFieldConf[
'range'][
'lower'];
1848 if (empty($tcaFieldConf[
'eval'])) {
1849 $res = array(
'value' => $value);
1853 if ($this->runtimeCache->has($cacheId)) {
1854 $evalCodesArray = $this->runtimeCache->get($cacheId);
1857 $this->runtimeCache->set($cacheId, $evalCodesArray);
1864 if ($field && $realPid >= 0 && !empty($res[
'value'])) {
1865 if (in_array(
'uniqueInPid', $evalCodesArray,
true)) {
1866 $res[
'value'] = $this->
getUnique($table, $field, $res[
'value'], $id, $realPid);
1868 if ($res[
'value'] && in_array(
'unique', $evalCodesArray,
true)) {
1869 $res[
'value'] = $this->
getUnique($table, $field, $res[
'value'], $id);
1875 if ($isDateOrDateTimeField) {
1877 $res[
'value'] = $res[
'value'] ? date($format, $res[
'value']) : $emptyValue;
1896 list($table, $id, , , $realPid) = $PP;
1897 return $this->
checkValueForCheck($res, $value, $tcaFieldConf, $table, $id, $realPid, $field);
1914 $itemC = count($tcaFieldConf[
'items']);
1918 $maxV = pow(2, $itemC) - 1;
1922 if ($value > $maxV) {
1925 if ($field && $realPid >= 0 && $value > 0 && !empty($tcaFieldConf[
'eval'])) {
1927 $otherRecordsWithSameValue = array();
1928 $maxCheckedRecords = 0;
1929 if (in_array(
'maximumRecordsCheckedInPid', $evalCodesArray,
true)) {
1931 $maxCheckedRecords = (int)$tcaFieldConf[
'validation'][
'maximumRecordsCheckedInPid'];
1933 if (in_array(
'maximumRecordsChecked', $evalCodesArray,
true)) {
1935 $maxCheckedRecords = (int)$tcaFieldConf[
'validation'][
'maximumRecordsChecked'];
1940 if ($maxCheckedRecords && count($otherRecordsWithSameValue) >= $maxCheckedRecords) {
1942 if ($this->enableLogging) {
1943 $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));
1947 $res[
'value'] = $value;
1965 return $this->
checkValueForRadio($res, $value, $tcaFieldConf, $PP[0], $PP[1], $PP[4],
'');
1982 if (is_array($tcaFieldConf[
'items'])) {
1983 foreach ($tcaFieldConf[
'items'] as $set) {
1984 if ((
string)$set[1] === (
string)$value) {
1985 $res[
'value'] = $value;
1992 if ($tcaFieldConf[
'itemsProcFunc'] && empty($res[
'value'])) {
1994 $processedItems = $processingService->getProcessingItems($table, $pid, $field, $this->checkValue_currentRecord,
1995 $tcaFieldConf, $tcaFieldConf[
'items']);
1997 foreach ($processedItems as $set) {
1998 if ((
string)$set[1] === (
string)$value) {
1999 $res[
'value'] = $value;
2023 list($table, $id, $curValue, $status, , $recFID) = $PP;
2024 return $this->
checkValueForGroupSelect($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $recFID, $uploadedFiles, $field);
2042 protected function checkValueForGroupSelect($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $recFID, $uploadedFiles, $field)
2045 if (is_array($value)) {
2046 $value = implode(
',', $value);
2054 if (!$tcaFieldConf[
'multiple']) {
2055 $valueArray = array_unique($valueArray);
2058 if ($tcaFieldConf[
'type'] ==
'select' && $tcaFieldConf[
'exclusiveKeys']) {
2060 foreach ($valueArray as $index => $key) {
2061 if (in_array($key, $exclusiveKeys,
true)) {
2062 $valueArray = array($index => $key);
2071 if ($tcaFieldConf[
'type'] ==
'select' && $tcaFieldConf[
'authMode']) {
2072 $preCount = count($valueArray);
2073 foreach ($valueArray as $index => $key) {
2074 if (!$this->BE_USER->checkAuthMode($table, $field, $key, $tcaFieldConf[
'authMode'])) {
2075 unset($valueArray[$index]);
2079 if ($preCount && empty($valueArray)) {
2084 if ($tcaFieldConf[
'type'] ==
'group') {
2085 switch ($tcaFieldConf[
'internal_type']) {
2086 case 'file_reference':
2089 $valueArray = $this->checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue, $uploadedFiles, $status, $table, $id, $recFID);
2092 $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status,
'group', $table, $field);
2097 $unsetResult =
false;
2098 if ($tcaFieldConf[
'type'] ==
'select' && $tcaFieldConf[
'foreign_table']) {
2100 if (strpos($value,
'NEW') !==
false) {
2101 $this->remapStackRecords[$table][$id] = array(
'remapStackIndex' => count($this->remapStack));
2103 $this->remapStack[] = array(
2104 'func' =>
'checkValue_group_select_processDBdata',
2105 'args' => array($valueArray, $tcaFieldConf, $id, $status,
'select', $table, $field),
2106 'pos' => array(
'valueArray' => 0,
'tcaFieldConf' => 1,
'id' => 2,
'table' => 5),
2109 $unsetResult =
true;
2111 $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status,
'select', $table, $field);
2114 if (!$unsetResult) {
2118 unset($res[
'value']);
2133 if (empty($tcaFieldConfiguration[
'filter']) || !is_array($tcaFieldConfiguration[
'filter'])) {
2136 foreach ($tcaFieldConfiguration[
'filter'] as $filter) {
2137 if (empty($filter[
'userFunc'])) {
2140 $parameters = $filter[
'parameters'] ?: array();
2141 $parameters[
'values'] = $values;
2142 $parameters[
'tcaFieldConfig'] = $tcaFieldConfiguration;
2144 if (!is_array($values)) {
2145 throw new \RuntimeException(
'Failed calling filter userFunc.', 1336051942);
2167 public function checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue,
$uploadedFileArray, $status, $table, $id, $recFID)
2170 if (!$this->bypassFileHandling) {
2180 if (!empty($uploadedFileArray[
'name']) && $uploadedFileArray[
'tmp_name'] !==
'none') {
2181 $valueArray[] = $uploadedFileArray[
'tmp_name'];
2182 $this->alternativeFileName[$uploadedFileArray[
'tmp_name']] = $uploadedFileArray[
'name'];
2186 if (!$this->fileFunc) {
2188 $this->include_filefunctions = 1;
2191 $all_files = array();
2192 $all_files[
'webspace'][
'allow'] = $tcaFieldConf[
'allowed'];
2193 $all_files[
'webspace'][
'deny'] = $tcaFieldConf[
'disallowed'] ?:
'*';
2194 $all_files[
'ftpspace'] = $all_files[
'webspace'];
2195 $this->fileFunc->init(
'', $all_files);
2198 if ($tcaFieldConf[
'uploadfolder'] && $tcaFieldConf[
'internal_type'] ==
'file') {
2199 $currentFilesForHistory = null;
2201 if (!$this->bypassFileHandling) {
2207 if ($status ==
'update') {
2217 if ($this->autoVersioningUpdate ===
true) {
2218 foreach ($valueArray as $key => $theFile) {
2220 if ($theFile === basename($theFile)) {
2221 $valueArray[$key] = PATH_site . $tcaFieldConf[
'uploadfolder'] .
'/' . $theFile;
2226 $theFileValues = array();
2228 if ($tcaFieldConf[
'MM']) {
2231 $dbAnalysis->start(
'',
'files', $tcaFieldConf[
'MM'], $id);
2232 foreach ($dbAnalysis->itemArray as $item) {
2234 $theFileValues[] = $item[
'id'];
2240 $currentFilesForHistory = implode(
',', $theFileValues);
2242 if (!empty($theFileValues)) {
2244 foreach ($valueArray as $key => $theFile) {
2250 foreach ($theFileValues as $key => $theFile) {
2251 $theFile = trim($theFile);
2252 if (@is_file(($dest .
'/' . $theFile))) {
2253 $this->removeFilesStore[] = $dest .
'/' . $theFile;
2254 }
elseif ($this->enableLogging && $theFile) {
2255 $this->
log($table, $id, 5, 0, 1,
'Could not delete file \'%s\' (does not exist). (%s)', 10, array($dest .
'/' . $theFile, $recFID), $propArr[
'event_pid']);
2261 foreach ($valueArray as $key => $theFile) {
2263 $maxSize = (int)$tcaFieldConf[
'max_size'];
2270 $theFile = $fileObject->getForLocalProcessing(
false);
2277 if (@is_dir($dest) && (@is_file($theFile) || @is_uploaded_file($theFile))) {
2279 if (is_uploaded_file($theFile) && $theFile == $uploadedFileArray[
'tmp_name']) {
2280 $fileSize = $uploadedFileArray[
'size'];
2282 $fileSize = filesize($theFile);
2285 if (!$maxSize || $fileSize <= $maxSize * 1024) {
2287 $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
2290 if ($this->fileFunc->checkIfAllowed($fI[
'fileext'], $dest, $theEndFileName)) {
2291 $theDestFile = $this->fileFunc->getUniqueName($this->fileFunc->cleanFileName($fI[
'file']), $dest);
2296 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processUpload'])) {
2297 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processUpload'] as $classRef) {
2299 if (!$hookObject instanceof DataHandlerProcessUploadHookInterface) {
2300 throw new \UnexpectedValueException(
'$hookObject must implement interface TYPO3\\CMS\\Core\\DataHandling\\DataHandlerProcessUploadHookInterface', 1279962349);
2302 $hookObject->processUpload_postProcessAction($theDestFile, $this);
2305 $this->copiedFileMap[$theFile] = $theDestFile;
2307 if ($this->enableLogging && !@is_file($theDestFile)) {
2308 $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']);
2310 }
elseif ($this->enableLogging) {
2311 $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']);
2313 }
elseif ($this->enableLogging) {
2314 $this->
log($table, $id, 5, 0, 1,
'File extension \'%s\' not allowed. (%s)', 12, array($fI[
'fileext'], $recFID), $propArr[
'event_pid']);
2316 }
elseif ($this->enableLogging) {
2317 $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']);
2319 }
elseif ($this->enableLogging) {
2320 $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']);
2323 if (@is_file($theDestFile)) {
2326 $valueArray[$key] = $info[
'file'];
2329 unset($valueArray[$key]);
2335 if ($tcaFieldConf[
'MM']) {
2339 $dbAnalysis->tableArray[
'files'] = array();
2340 foreach ($valueArray as $key => $theFile) {
2342 $dbAnalysis->itemArray[][
'id'] = $theFile;
2344 if ($status ==
'update') {
2345 $dbAnalysis->writeMM($tcaFieldConf[
'MM'], $id, 0);
2346 $newFiles = implode(
',', $dbAnalysis->getValueArray());
2347 list(, , $recFieldName) = explode(
':', $recFID);
2348 if ($currentFilesForHistory != $newFiles) {
2349 $this->mmHistoryRecords[$table .
':' . $id][
'oldRecord'][$recFieldName] = $currentFilesForHistory;
2350 $this->mmHistoryRecords[$table .
':' . $id][
'newRecord'][$recFieldName] = $newFiles;
2352 $this->mmHistoryRecords[$table .
':' . $id][
'oldRecord'][$recFieldName] =
'';
2353 $this->mmHistoryRecords[$table .
':' . $id][
'newRecord'][$recFieldName] =
'';
2356 $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf[
'MM'], $id, 0);
2358 $valueArray = $dbAnalysis->countItems();
2361 if (!empty($valueArray)) {
2363 if (!$this->bypassFileHandling) {
2366 foreach ($valueArray as &$theFile) {
2370 $theFile = $fileObject->getForLocalProcessing(
false);
2372 if ($this->alternativeFilePath[$theFile]) {
2375 if (@is_file((PATH_site . $this->alternativeFilePath[$theFile]))) {
2376 $theFile = PATH_site . $this->alternativeFilePath[$theFile];
2377 }
elseif (@is_file($theFile)) {
2378 $dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]);
2379 if (!@is_dir($dest)) {
2383 $maxSize = (int)$tcaFieldConf[
'max_size'];
2386 $fileSize = filesize($theFile);
2388 if (!$maxSize || $fileSize <= $maxSize * 1024) {
2390 $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
2393 if ($this->fileFunc->checkIfAllowed($fI[
'fileext'], $dest, $theEndFileName)) {
2394 $theDestFile = PATH_site . $this->alternativeFilePath[$theFile];
2398 $this->copiedFileMap[$theFile] = $theDestFile;
2400 if ($this->enableLogging && !@is_file($theDestFile)) {
2401 $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']);
2403 }
elseif ($this->enableLogging) {
2404 $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']);
2406 }
elseif ($this->enableLogging) {
2407 $this->
log($table, $id, 5, 0, 1,
'File extension \'%s\' not allowed. (%s)', 12, array($fI[
'fileext'], $recFID), $propArr[
'event_pid']);
2409 }
elseif ($this->enableLogging) {
2410 $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']);
2413 if (@is_file($theDestFile)) {
2415 $theFile = $theDestFile;
2422 if (!empty($theFile)) {
2451 list($table, $id, $curValue, $status, $realPid, $recFID, $tscPID) = $PP;
2452 $this->
checkValueForFlex($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $tscPID, $uploadedFiles, $field);
2472 protected function checkValueForFlex($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $tscPID, $uploadedFiles, $field)
2474 if (is_array($value)) {
2479 $newRecordPidValue = $status ==
'new' ? $realPid : 0;
2483 if (!is_array($currentValueArray)) {
2484 $currentValueArray = array();
2486 if (isset($currentValueArray[
'meta'][
'currentLangId'])) {
2488 unset($currentValueArray[
'meta'][
'currentLangId']);
2492 $value[
'data'] = $this->
checkValue_flex_procInData($value[
'data'], $currentValueArray[
'data'], $uploadedFiles[
'data'], $dataStructArray, array($table, $id, $curValue, $status, $realPid, $recFID, $tscPID));
2494 $xmlValue = $this->checkValue_flexArray2Xml($value,
true);
2500 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkFlexFormValue'])) {
2501 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'checkFlexFormValue'] as $classRef) {
2503 if (method_exists($hookObject,
'checkFlexFormValue_beforeMerge')) {
2504 $hookObject->checkFlexFormValue_beforeMerge($this, $currentValueArray, $arrValue);
2510 $xmlValue = $this->checkValue_flexArray2Xml($currentValueArray,
true);
2515 if (is_array($actionCMDs[$table][$id][$field][
'data'])) {
2518 $xmlValue = $this->checkValue_flexArray2Xml($arrValue,
true);
2522 $res[
'value'] .= $xmlValue;
2525 $res[
'value'] = $value;
2538 public function checkValue_flexArray2Xml($array, $addPrologue =
false)
2542 return $flexObj->flexArray2Xml($array, $addPrologue);
2554 if (!is_array($valueArray) || !is_array($actionCMDs)) {
2558 foreach ($actionCMDs as $key => $value) {
2559 if ($key ==
'_ACTION') {
2561 if (current($actionCMDs[$key]) ===
'') {
2565 asort($actionCMDs[$key]);
2566 $newValueArray = array();
2567 foreach ($actionCMDs[$key] as $idx => $order) {
2568 if (substr($idx, 0, 3) ==
'ID-') {
2569 $idx = $this->newIndexMap[$idx];
2572 if ($order !=
'DELETE') {
2573 $newValueArray[$idx] = $valueArray[$idx];
2575 unset($valueArray[$idx]);
2577 $valueArray = $valueArray + $newValueArray;
2578 }
elseif (is_array($actionCMDs[$key]) && isset($valueArray[$key])) {
2596 public function checkValue_inline($res, $value, $tcaFieldConf, $PP, $field, array $additionalData = null)
2598 list($table, $id, , $status) = $PP;
2599 $this->
checkValueForInline($res, $value, $tcaFieldConf, $table, $id, $status, $field, $additionalData);
2616 public function checkValueForInline($res, $value, $tcaFieldConf, $table, $id, $status, $field, array $additionalData = null)
2618 if (!$tcaFieldConf[
'foreign_table']) {
2625 $valueArray = array_unique($valueArray);
2630 $this->remapStackRecords[$table][$id] = array(
'remapStackIndex' => count($this->remapStack));
2632 $this->remapStack[] = array(
2633 'func' =>
'checkValue_inline_processDBdata',
2634 'args' => array($valueArray, $tcaFieldConf, $id, $status, $table, $field, $additionalData),
2635 'pos' => array(
'valueArray' => 0,
'tcaFieldConf' => 1,
'id' => 2,
'table' => 4),
2636 'additionalData' => $additionalData,
2639 unset($res[
'value']);
2641 $res[
'value'] = $this->checkValue_inline_processDBdata($valueArray, $tcaFieldConf, $id, $status, $table, $field, $additionalData);
2657 $valueArrayC = count($valueArray);
2659 $maxI = isset($tcaFieldConf[
'maxitems']) ? (int)$tcaFieldConf[
'maxitems'] : 1;
2660 if ($valueArrayC > $maxI) {
2661 $valueArrayC = $maxI;
2666 foreach ($valueArray as $nextVal) {
2667 if ($valueArrayC == 0) {
2671 $newVal[] = $nextVal;
2691 public function getUnique($table, $field, $value, $id, $newPid = 0)
2697 $whereAdd .=
' AND pid=' . (int)$newPid;
2699 $whereAdd .=
' AND pid>=0';
2704 if (is_array($GLOBALS[
'TCA'][$table]) && is_array($GLOBALS[
'TCA'][$table][
'columns'][$field])) {
2706 $res = $this->databaseConnection->exec_SELECTquery(
'uid', $table, $field .
'=' . $this->databaseConnection->fullQuoteStr($value, $table) .
' AND uid<>' . (int)$id . $whereAdd);
2709 while ($this->databaseConnection->sql_num_rows($res)) {
2710 $newValue = $value . $counter;
2711 $res = $this->databaseConnection->exec_SELECTquery(
'uid', $table, $field .
'=' . $this->databaseConnection->fullQuoteStr($newValue, $table) .
' AND uid<>' . (int)$id . $whereAdd);
2713 if ($counter > 100) {
2717 $this->databaseConnection->sql_free_result($res);
2719 $value = $newValue !==
'' ? $newValue : $value;
2738 if (!empty($GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName])) {
2740 $pageId = (int)$pageId;
2741 $whereStatement =
' AND uid <> ' . $uid .
' AND ' . ($pageId ?
'pid = ' . $pageId :
'pid >= 0');
2757 foreach ($evalArray as $func) {
2760 $value = trim($value);
2768 if (isset($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tce'][
'formevals'][$func])) {
2769 if (class_exists($func)) {
2771 if (method_exists($evalObj,
'evaluateFieldValue')) {
2772 $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
2779 $res[
'value'] = $value;
2796 foreach ($evalArray as $func) {
2802 $value = (int)$value;
2806 $value = (int)$value;
2807 if ($value > 0 && !$this->dontProcessTransformations) {
2808 $value -= date(
'Z', $value);
2812 $value = preg_replace(
'/[^0-9,\\.-]/',
'', $value);
2813 $negative = $value[0] ===
'-';
2814 $value = strtr($value, array(
',' =>
'.',
'-' =>
''));
2815 if (strpos($value,
'.') ===
false) {
2818 $valueArray = explode(
'.', $value);
2819 $dec = array_pop($valueArray);
2820 $value = join(
'', $valueArray) .
'.' . $dec;
2824 $value = number_format($value, 2,
'.',
'');
2827 if (strlen($value) != 32) {
2832 $value = trim($value);
2835 $value = $GLOBALS[
'LANG']->csConvObj->conv_case($GLOBALS[
'LANG']->charSet, $value,
'toUpper');
2838 $value = $GLOBALS[
'LANG']->csConvObj->conv_case($GLOBALS[
'LANG']->charSet, $value,
'toLower');
2841 if (!isset($value) || $value ===
'') {
2846 $c = strlen($value);
2849 for ($a = 0; $a < $c; $a++) {
2850 $char = substr($value, $a, 1);
2851 if (strpos($is_in, $char) !==
false) {
2859 $value = str_replace(
' ',
'', $value);
2862 $value = preg_replace(
'/[^a-zA-Z]/',
'', $value);
2865 $value = preg_replace(
'/[^0-9]/',
'', $value);
2868 $value = preg_replace(
'/[^a-zA-Z0-9]/',
'', $value);
2871 $value = preg_replace(
'/[^a-zA-Z0-9_-]/',
'', $value);
2874 if (!preg_match(
'/^[a-z0-9.\\-]*$/i', $value)) {
2879 $this->checkValue_input_ValidateEmail($value, $set);
2882 if (isset($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tce'][
'formevals'][$func])) {
2883 if (class_exists($func)) {
2885 if (method_exists($evalObj,
'evaluateFieldValue')) {
2886 $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
2893 $res[
'value'] = $value;
2909 protected function checkValue_input_ValidateEmail($value, &$set)
2918 sprintf($GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:error.invalidEmail'), $value),
2925 $flashMessageService->getMessageQueueByIdentifier()->enqueue($message);
2940 public function checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, $type, $currentTable, $currentField)
2942 $tables = $type ==
'group' ? $tcaFieldConf[
'allowed'] : $tcaFieldConf[
'foreign_table'];
2943 $prep = $type ==
'group' ? $tcaFieldConf[
'prepend_tname'] :
'';
2944 $newRelations = implode(
',', $valueArray);
2947 $dbAnalysis->registerNonTableValues = !empty($tcaFieldConf[
'allowNonIdValues']);
2948 $dbAnalysis->start($newRelations, $tables,
'', 0, $currentTable, $tcaFieldConf);
2949 if ($tcaFieldConf[
'MM']) {
2950 if ($status ==
'update') {
2953 $oldRelations_dbAnalysis->registerNonTableValues = !empty($tcaFieldConf[
'allowNonIdValues']);
2955 $oldRelations_dbAnalysis->start(
'', $tables, $tcaFieldConf[
'MM'], $id, $currentTable, $tcaFieldConf);
2956 $oldRelations = implode(
',', $oldRelations_dbAnalysis->getValueArray());
2957 $dbAnalysis->writeMM($tcaFieldConf[
'MM'], $id, $prep);
2958 if ($oldRelations != $newRelations) {
2959 $this->mmHistoryRecords[$currentTable .
':' . $id][
'oldRecord'][$currentField] = $oldRelations;
2960 $this->mmHistoryRecords[$currentTable .
':' . $id][
'newRecord'][$currentField] = $newRelations;
2962 $this->mmHistoryRecords[$currentTable .
':' . $id][
'oldRecord'][$currentField] =
'';
2963 $this->mmHistoryRecords[$currentTable .
':' . $id][
'newRecord'][$currentField] =
'';
2966 $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf[
'MM'], $id, $prep, $currentTable);
2968 $valueArray = $dbAnalysis->countItems();
2970 $valueArray = $dbAnalysis->getValueArray($prep);
2985 foreach ($valueArray as &$newVal) {
2986 $temp = explode(
'|', $newVal, 2);
2987 $newVal = str_replace(
',',
'', str_replace(
'|',
'', rawurldecode($temp[0])));
3009 if (is_array($dataPart)) {
3010 foreach ($dataPart as $sKey => $sheetDef) {
3012 if (is_array($dataStruct) && $actualSheet == $sKey && is_array($sheetDef)) {
3013 foreach ($sheetDef as $lKey => $lData) {
3014 $this->
checkValue_flex_procInData_travDS($dataPart[$sKey][$lKey], $dataPart_current[$sKey][$lKey], $uploadedFiles[$sKey][$lKey], $dataStruct[
'ROOT'][
'el'], $pParams, $callBackFunc, $sKey .
'/' . $lKey .
'/');
3038 if (!is_array($DSelements)) {
3043 foreach ($DSelements as $key => $dsConf) {
3045 if ($DSelements[$key][
'type'] ==
'array') {
3046 if (!is_array($dataValues[$key][
'el'])) {
3050 if ($DSelements[$key][
'section']) {
3051 $newIndexCounter = 0;
3052 foreach ($dataValues[$key][
'el'] as $ik => $el) {
3053 if (!is_array($el)) {
3057 if (!is_array($dataValues_current[$key][
'el'])) {
3058 $dataValues_current[$key][
'el'] = array();
3061 if (!is_array($dataValues[$key][
'el'][$ik][$theKey][
'el'])) {
3065 $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/');
3068 if (substr($ik, 0, 3) ==
'ID-') {
3071 $this->newIndexMap[$ik] = (is_array($dataValues_current[$key][
'el']) && !empty($dataValues_current[$key][
'el']) ? max(array_keys($dataValues_current[$key][
'el'])) : 0) + $newIndexCounter;
3073 $dataValues[$key][
'el'][$this->newIndexMap[$ik]] = $dataValues[$key][
'el'][$ik];
3075 unset($dataValues[$key][
'el'][$ik]);
3079 if (!isset($dataValues[$key][
'el'])) {
3080 $dataValues[$key][
'el'] = array();
3082 $this->
checkValue_flex_procInData_travDS($dataValues[$key][
'el'], $dataValues_current[$key][
'el'], $uploadedFiles[$key][
'el'], $DSelements[$key][
'el'], $pParams, $callBackFunc, $structurePath . $key .
'/el/');
3085 if (!is_array($dsConf[
'TCEforms'][
'config']) || !is_array($dataValues[$key])) {
3089 foreach ($dataValues[$key] as $vKey => $data) {
3090 if ($callBackFunc) {
3091 if (is_object($this->callBackObj)) {
3092 $res = $this->callBackObj->{$callBackFunc}($pParams, $dsConf[
'TCEforms'][
'config'], $dataValues[$key][$vKey], $dataValues_current[$key][$vKey], $uploadedFiles[$key][$vKey], $structurePath . $key .
'/' . $vKey .
'/');
3094 $res = $this->{$callBackFunc}($pParams, $dsConf[
'TCEforms'][
'config'], $dataValues[$key][$vKey], $dataValues_current[$key][$vKey], $uploadedFiles[$key][$vKey], $structurePath . $key .
'/' . $vKey .
'/');
3098 list($CVtable, $CVid, $CVcurValue, $CVstatus, $CVrealPid, $CVrecFID, $CVtscPID) = $pParams;
3100 $additionalData = array(
3101 'flexFormId' => $CVrecFID,
3102 'flexFormPath' => trim(rtrim($structurePath,
'/') .
'/' . $key .
'/' . $vKey,
'/'),
3105 $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);
3107 if ($dataValues[$key][
'_TRANSFORM_' . $vKey] ==
'RTE' && !$this->dontProcessTransformations) {
3109 unset($dataValues[$key][
'_TRANSFORM_' . $vKey]);
3110 if (isset($res[
'value'])) {
3112 list(, , $recFieldName) = explode(
':', $CVrecFID);
3119 $res[
'value'], $CVtable, $recFieldName, $specConf, $thisConfig, $CVrealPid
3125 if (isset($res[
'value'])) {
3126 $dataValues[$key][$vKey] = $res[
'value'];
3130 if (substr($vKey, -9) !=
'.vDEFbase') {
3132 if ($this->clear_flexFormData_vDEFbase) {
3133 $dataValues[$key][$vKey .
'.vDEFbase'] =
'';
3134 }
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')) {
3136 if (isset($dataValues[$key][
'vDEF'])) {
3137 $diffValue = $dataValues[$key][
'vDEF'];
3140 $diffValue = $dataValues_current[$key][
'vDEF'];
3143 $dataValues[$key][$vKey .
'.vDEFbase'] = $this->updateModeL10NdiffDataClear ?
'' : $diffValue;
3163 protected function checkValue_inline_processDBdata($valueArray, $tcaFieldConf, $id, $status, $table, $field, array $additionalData = null)
3166 $foreignTable = $tcaFieldConf[
'foreign_table'];
3167 $transOrigPointer = 0;
3168 $keepTranslation =
false;
3173 $dbAnalysis->start(implode(
',', $valueArray), $foreignTable,
'', 0, $table, $tcaFieldConf);
3176 if ($localizationMode ==
'keep' && $status ==
'update') {
3179 if (is_array($row)) {
3180 $language = (int)$row[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']];
3181 $transOrigPointer = (int)$row[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']];
3183 if ($language > 0 && $transOrigPointer) {
3184 $id = $transOrigPointer;
3187 $keepTranslation =
true;
3192 if ($tcaFieldConf[
'foreign_field']) {
3194 $skipSorting = (bool)$this->callFromImpExp;
3196 $dbAnalysis->writeForeignField($tcaFieldConf, $id, 0, $skipSorting);
3197 $newValue = $keepTranslation ? 0 : $dbAnalysis->countItems(
false);
3201 $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status,
'select', $table, $field);
3202 $newValue = $keepTranslation ? 0 : $valueArray[0];
3204 $valueArray = $dbAnalysis->getValueArray();
3209 if ($keepTranslation) {
3210 $this->
updateDB($table, $transOrigPointer, array($field => $valueData));
3212 $newValue = $valueData;
3230 public function process_cmdmap()
3233 if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec[
'freeze']) {
3234 if ($this->enableLogging) {
3235 $this->
newlog(
'All editing in this workspace has been frozen!', 1);
3240 $hookObjectsArr = array();
3241 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processCmdmapClass'])) {
3242 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processCmdmapClass'] as $classRef) {
3244 if (method_exists($hookObj,
'processCmdmap_beforeStart')) {
3245 $hookObj->processCmdmap_beforeStart($this);
3247 $hookObjectsArr[] = $hookObj;
3250 $pasteDatamap = array();
3252 foreach ($this->cmdmap as $table => $_) {
3254 $modifyAccessList = $this->checkModifyAccessList($table);
3255 if ($this->enableLogging && !$modifyAccessList) {
3256 $this->
log($table, 0, 2, 0, 1,
'Attempt to modify table \'%s\' without permission', 1, array($table));
3259 if (!isset($GLOBALS[
'TCA'][$table]) || $this->
tableReadOnly($table) || !is_array($this->cmdmap[$table]) || !$modifyAccessList) {
3264 foreach ($this->cmdmap[$table] as $id => $incomingCmdArray) {
3265 if (!is_array($incomingCmdArray)) {
3269 if ($table ===
'pages') {
3271 $this->pagetreeNeedsRefresh =
true;
3274 foreach ($incomingCmdArray as $command => $value) {
3275 $pasteUpdate =
false;
3276 if (is_array($value) && isset($value[
'action']) && $value[
'action'] ===
'paste') {
3280 $pasteUpdate = $value[
'update'];
3281 $value = $value[
'target'];
3283 foreach ($hookObjectsArr as $hookObj) {
3284 if (method_exists($hookObj,
'processCmdmap_preProcess')) {
3285 $hookObj->processCmdmap_preProcess($command, $table, $id, $value, $this, $pasteUpdate);
3291 $this->copyMappingArray = array();
3293 $commandIsProcessed =
false;
3294 foreach ($hookObjectsArr as $hookObj) {
3295 if (method_exists($hookObj,
'processCmdmap')) {
3296 $hookObj->processCmdmap($command, $table, $id, $value, $commandIsProcessed, $this, $pasteUpdate);
3300 if (!$commandIsProcessed) {
3308 if ($table ===
'pages') {
3311 $this->copyRecord($table, $id, $value, 1);
3313 $procId = $this->copyMappingArray[$table][$id];
3316 $this->localize($table, $id, $value);
3318 case 'inlineLocalizeSynchronize':
3319 $this->inlineLocalizeSynchronize($table, $id, $value);
3328 if (is_array($pasteUpdate)) {
3329 $pasteDatamap[$table][$procId] = $pasteUpdate;
3332 foreach ($hookObjectsArr as $hookObj) {
3333 if (method_exists($hookObj,
'processCmdmap_postProcess')) {
3334 $hookObj->processCmdmap_postProcess($command, $table, $id, $value, $this, $pasteUpdate, $pasteDatamap);
3344 $copyTCE->start($pasteDatamap,
'', $this->BE_USER);
3345 $copyTCE->process_datamap();
3346 $this->errorLog = array_merge($this->errorLog, $copyTCE->errorLog);
3353 foreach ($hookObjectsArr as $hookObj) {
3354 if (method_exists($hookObj,
'processCmdmap_afterFinish')) {
3355 $hookObj->processCmdmap_afterFinish($this);
3359 $this->processClearCacheQueue();
3382 public function copyRecord($table, $uid, $destPid, $first =
false,
$overrideValues = array(), $excludeFields =
'', $language = 0, $ignoreLocalization =
false)
3384 $uid = ($origUid = (int)$uid);
3386 if (empty($GLOBALS[
'TCA'][$table]) || $uid === 0) {
3391 $this->
log($table, $uid, 5, 0, 1,
'Repeated attempt to copy record "' . $table .
':' . $uid .
'" with override values');
3398 if ($this->enableLogging) {
3399 $this->
log($table, $uid, 3, 0, 1,
'Attempt to copy record without permission');
3406 if ($this->enableLogging) {
3407 $this->
log($table, $uid, 3, 0, 1,
'Attempt to insert record on a page that can\'t store record type.');
3412 $fullLanguageCheckNeeded = $table !=
'pages';
3414 if (!$ignoreLocalization && ($language <= 0 || !$this->BE_USER->checkLanguageAccess($language)) && !$this->BE_USER->recordEditAccessInternals($table, $uid,
false,
false, $fullLanguageCheckNeeded)) {
3415 if ($this->enableLogging) {
3416 $this->
log($table, $uid, 3, 0, 1,
'Attempt to copy record without having permissions to do so. [' . $this->BE_USER->errorMsg .
'].');
3422 $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));
3425 if (!is_array($row)) {
3426 if ($this->enableLogging) {
3427 $this->
log($table, $uid, 3, 0, 1,
'Attempt to copy record that did not exist!');
3434 $enableField = isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns']) ? $GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled'] :
'';
3435 $headerField = $GLOBALS[
'TCA'][$table][
'ctrl'][
'label'];
3439 $copyAfterFields = $destPid < 0 ? $this->
fixCopyAfterDuplFields($table, $uid, abs($destPid), 0) : array();
3447 foreach ($row as $field => $value) {
3448 if (!in_array($field, $nonFields,
true)) {
3450 $conf = $GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
3455 if ($field ==
'pid') {
3460 }
elseif (array_key_exists($field, $copyAfterFields)) {
3462 $value = $copyAfterFields[$field];
3463 }
elseif ($GLOBALS[
'TCA'][$table][
'ctrl'][
'setToDefaultOnCopy'] && isset($setDefaultOnCopyArray[$field])) {
3464 $value = $defaultData[$field];
3467 if ($first && $field == $enableField && $GLOBALS[
'TCA'][$table][
'ctrl'][
'hideAtCopy'] && !$this->neverHideAtCopy && !$tE[
'disableHideAtCopy']) {
3471 if ($first && $field == $headerField && $GLOBALS[
'TCA'][$table][
'ctrl'][
'prependAtCopy'] && !$tE[
'disablePrependAtCopy']) {
3478 $data[$table][$theNewID][$field] = $value;
3482 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']) {
3483 $data[$table][$theNewID][$GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']] = 0;
3486 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'origUid']) {
3487 $data[$table][$theNewID][$GLOBALS[
'TCA'][$table][
'ctrl'][
'origUid']] = $uid;
3492 $copyTCE->start($data,
'', $this->BE_USER);
3493 $copyTCE->process_datamap();
3495 $theNewSQLID = $copyTCE->substNEWwithIDs[$theNewID];
3498 $this->copyMappingArray[$table][$origUid] = $theNewSQLID;
3500 if (isset($copyTCE->autoVersionIdMap[$table][$theNewSQLID])) {
3501 $this->autoVersionIdMap[$table][$theNewSQLID] = $copyTCE->autoVersionIdMap[$table][$theNewSQLID];
3505 $this->cachedTSconfig = $copyTCE->cachedTSconfig;
3506 $this->errorLog = array_merge($this->errorLog, $copyTCE->errorLog);
3508 if (!$ignoreLocalization && $language == 0) {
3510 $overrideValues[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']] = $theNewSQLID;
3514 return $theNewSQLID;
3529 $destPid = (int)$destPid;
3532 $copyTablesArray = $this->admin ? $this->
compileAdminTables() : explode(
',', $this->BE_USER->groupData[
'tables_modify']);
3534 if (!strstr($this->copyWhichTables,
'*')) {
3536 foreach ($copyTablesArray as $k => $table) {
3538 if (!$table || !isset($copyWhichTablesArray[$table])) {
3539 unset($copyTablesArray[$k]);
3543 $copyTablesArray = array_unique($copyTablesArray);
3545 if ($this->admin || in_array(
'pages', $copyTablesArray,
true)) {
3547 $theNewRootID = $this->
copySpecificPage($uid, $destPid, $copyTablesArray, 1);
3549 if ($theNewRootID && $this->copyTree) {
3551 $CPtable = $this->
int_pageTreeInfo(array(), $uid, (
int)$this->copyTree, $theNewRootID);
3553 foreach ($CPtable as $thePageUid => $thePagePid) {
3554 $newPid = $this->copyMappingArray[
'pages'][$thePagePid];
3555 if (isset($newPid)) {
3558 if ($this->enableLogging) {
3559 $this->
log(
'pages', $uid, 5, 0, 1,
'Something went wrong during copying branch');
3565 }
elseif ($this->enableLogging) {
3566 $this->
log(
'pages', $uid, 5, 0, 1,
'Attempt to copy page without permission to this table');
3582 $theNewRootID = $this->copyRecord(
'pages', $uid, $destPid, $first);
3584 if ($theNewRootID) {
3585 foreach ($copyTablesArray as $table) {
3587 if ($table && is_array($GLOBALS[
'TCA'][$table]) && $table !=
'pages') {
3589 $languageField = null;
3590 $transOrigPointerField = null;
3592 $languageField = $GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'];
3593 $transOrigPointerField = $GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'];
3594 $fields .=
',' . $languageField .
',' . $transOrigPointerField;
3596 $rows = $this->databaseConnection->exec_SELECTgetRows(
3601 (!empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']) ? $GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'] .
' DESC' :
''),
3605 foreach ($rows as $row) {
3608 $transOrigPointer = $row[$transOrigPointerField];
3609 if ($row[$languageField] > 0 && $transOrigPointer > 0 && isset($rows[$transOrigPointer])) {
3613 $this->copyRecord($table, $row[
'uid'], $theNewRootID);
3618 return $theNewRootID;
3638 public function copyRecord_raw($table, $uid, $pid, $overrideArray = array(), array $workspaceOptions = array())
3647 if (!$GLOBALS[
'TCA'][$table] || !$uid || $this->
isRecordCopied($table, $uid)) {
3651 if ($this->enableLogging) {
3652 $this->
log($table, $uid, 3, 0, 1,
'Attempt to rawcopy/versionize record without copy permission');
3658 $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');
3661 if (!is_array($row)) {
3662 if ($this->enableLogging) {
3663 $this->
log($table, $uid, 3, 0, 1,
'Attempt to rawcopy/versionize record that did not exist!');
3669 $row = array_merge($row, $overrideArray);
3671 foreach ($row as $field => $value) {
3672 if (!in_array($field, $nonFields,
true)) {
3674 $conf = $GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
3675 if (is_array($conf)) {
3680 $row[$field] = $value;
3686 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'origUid']) {
3687 $row[$GLOBALS[
'TCA'][$table][
'ctrl'][
'origUid']] = $uid;
3693 $this->dbAnalysisStore = array();
3695 return $this->copyMappingArray[$table][$uid] = $theNewSQLID;
3714 $this->checkValue_currentRecord = $fieldArray;
3717 $this->dontProcessTransformations =
true;
3719 foreach ($fieldArray as $field => $fieldValue) {
3720 if (isset($GLOBALS[
'TCA'][$table][
'columns'][$field])) {
3722 $res = $this->
checkValue($table, $field, $fieldValue, $id,
'new', $realPid, 0);
3723 if (isset($res[
'value'])) {
3724 $fieldArray[$field] = $res[
'value'];
3729 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'crdate']) {
3730 $fieldArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'crdate']] = $GLOBALS[
'EXEC_TIME'];
3732 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'cruser_id']) {
3733 $fieldArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'cruser_id']] =
$this->userid;
3735 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']) {
3736 $fieldArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']] = $GLOBALS[
'EXEC_TIME'];
3739 $this->
insertDB($table, $id, $fieldArray,
true);
3741 $this->dontProcessTransformations = $backupDontProcessTransformations;
3743 return $this->substNEWwithIDs[$id];
3765 $value = $this->copyRecord_procFilesRefs($conf, $uid, $value);
3771 $value = $this->copyRecord_processManyToMany($table, $uid, $field, $value, $conf, $language, $localizationMode, $inlineSubType);
3772 }
elseif ($inlineSubType !==
false) {
3773 $value = $this->copyRecord_processInline($table, $uid, $field, $value, $row, $conf, $realDestPid, $language, $workspaceOptions, $localizationMode, $inlineSubType);
3776 if ($conf[
'type'] ==
'flex') {
3781 if (is_array($currentValueArray)) {
3782 $currentValueArray[
'data'] = $this->
checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table, $uid, $field, $realDestPid),
'copyRecord_flexFormCallBack');
3784 $value = $currentValueArray;
3803 protected function copyRecord_processManyToMany($table, $uid, $field, $value, $conf, $language, $localizationMode, $inlineSubType)
3805 $allowedTables = $conf[
'type'] ==
'group' ? $conf[
'allowed'] : $conf[
'foreign_table'];
3806 $prependName = $conf[
'type'] ==
'group' ? $conf[
'prepend_tname'] :
'';
3807 $mmTable = isset($conf[
'MM']) && $conf[
'MM'] ? $conf[
'MM'] :
'';
3809 $localizeReferences = $localizeForeignTable && isset($conf[
'localizeReferencesAtParentLocalization']) && $conf[
'localizeReferencesAtParentLocalization'];
3810 $localizeChildren = $localizeForeignTable && isset($conf[
'behaviour'][
'localizeChildrenAtParentLocalization']) && $conf[
'behaviour'][
'localizeChildrenAtParentLocalization'];
3813 $dbAnalysis->start($value, $allowedTables, $mmTable, $uid, $table, $conf);
3815 $localizingNonManyToManyFieldReferences = $localizeReferences && empty($mmTable);
3816 $isInlineFieldInSelectMode = $localizationMode ===
'select' && $inlineSubType ===
'mm';
3817 $purgeItems =
false;
3818 if ($language > 0 && ($localizingNonManyToManyFieldReferences || $isInlineFieldInSelectMode)) {
3819 foreach ($dbAnalysis->itemArray as $index => $item) {
3822 if ($recordLocalization) {
3823 $dbAnalysis->itemArray[$index][
'id'] = $recordLocalization[0][
'uid'];
3825 if ($localizingNonManyToManyFieldReferences || $localizeChildren) {
3826 $dbAnalysis->itemArray[$index][
'id'] = $this->localize($item[
'table'], $item[
'id'], $language);
3828 unset($dbAnalysis->itemArray[$index]);
3835 if ($purgeItems || $mmTable) {
3836 $dbAnalysis->purgeItemArray();
3837 $value = implode(
',', $dbAnalysis->getValueArray($prependName));
3841 $this->registerDBList[$table][$uid][$field] = $value;
3863 protected function copyRecord_processInline($table, $uid, $field, $value, $row, $conf, $realDestPid, $language,
3864 array $workspaceOptions, $localizationMode, $inlineSubType)
3867 if ($language > 0 && $localizationMode ==
'keep') {
3868 $value = $inlineSubType ==
'field' ? 0 :
'';
3873 $dbAnalysis->start($value, $conf[
'foreign_table'],
'', $uid, $table, $conf);
3875 foreach ($dbAnalysis->itemArray as $k => $v) {
3880 if ($localizationMode !=
false && isset($conf[
'behaviour'][
'localizeChildrenAtParentLocalization']) && $conf[
'behaviour'][
'localizeChildrenAtParentLocalization']) {
3881 $newId = $this->localize($v[
'table'], $v[
'id'], $language);
3885 $newId = $this->copyRecord($v[
'table'], $v[
'id'], -$v[
'id']);
3890 if (!empty($workspaceOptions)) {
3895 $v[
'table'], $v[
'id'],
3896 (isset($workspaceOptions[
'label']) ? $workspaceOptions[
'label'] :
'Auto-created for WS #' . $this->BE_USER->workspace),
3897 (isset($workspaceOptions[
'delete']) ? $workspaceOptions[
'delete'] :
false)
3903 if (isset($this->copyMappingArray[$v[
'table']][$v[
'id']])) {
3904 $newId = $this->copyMappingArray[$v[
'table']][$v[
'id']];
3906 $newId = $this->copyRecord($v[
'table'], $v[
'id'], $realDestPid);
3912 if (isset($this->copyMappingArray[$v[
'table']][$v[
'id']])) {
3913 $newId = $this->copyMappingArray[$v[
'table']][$v[
'id']];
3915 $newId = $this->
copyRecord_raw($v[
'table'], $v[
'id'], $realDestPid, array(), $workspaceOptions);
3920 if ($table ==
'pages') {
3921 $this->registerDBPids[$v[
'table']][$v[
'id']] = $uid;
3922 }
elseif (isset($this->registerDBPids[$table][$uid])) {
3923 $this->registerDBPids[$v[
'table']][$v[
'id']] = $this->registerDBPids[$table][$uid];
3925 $dbAnalysis->itemArray[$k][
'id'] = $newId;
3928 $value = implode(
',', $dbAnalysis->getValueArray());
3929 $this->registerDBList[$table][$uid][$field] = $value;
3949 list($table, $uid, $field, $realDestPid) = $pParams;
3951 $dataValue = $this->copyRecord_procFilesRefs($dsConf, $uid, $dataValue);
3955 $this->registerDBList[$table][$uid][$field] =
'FlexForm_reference';
3958 return array(
'value' => $dataValue);
3972 public function copyRecord_procFilesRefs($conf, $uid, $value)
3975 if ($conf[
'type'] !=
'group' || ($conf[
'internal_type'] !=
'file' && $conf[
'internal_type'] !=
'file_reference')) {
3981 $theFileValues = array();
3984 $dbAnalysis->start(
'',
'files', $conf[
'MM'], $uid);
3985 foreach ($dbAnalysis->itemArray as $somekey => $someval) {
3986 if ($someval[
'id']) {
3987 $theFileValues[] = $someval[
'id'];
3994 $uploadFolder = $conf[
'internal_type'] ==
'file' ? $conf[
'uploadfolder'] :
'';
3996 $newValue = array();
3997 foreach ($theFileValues as $file) {
3999 $realFile = str_replace(
'//',
'/', $dest .
'/' . trim($file));
4000 if (@is_file($realFile)) {
4001 $newValue[] = $realFile;
4006 $value = implode(
',', $newValue);
4021 public function copyRecord_fixRTEmagicImages($table, $theNewSQLID)
4024 if (!$this->fileFunc) {
4026 $this->include_filefunctions = 1;
4029 $where = join(
' AND ', array(
4030 'ref_table=' . $this->databaseConnection->fullQuoteStr(
'_FILE',
'sys_refindex'),
4031 'ref_string LIKE ' . $this->databaseConnection->fullQuoteStr(
'%/RTEmagic%',
'sys_refindex'),
4032 'softref_key=' . $this->databaseConnection->fullQuoteStr(
'images',
'sys_refindex'),
4033 'tablename=' . $this->databaseConnection->fullQuoteStr($table,
'sys_refindex'),
4034 'recuid=' . (int)$theNewSQLID,
4036 $rteFileRecords = $this->databaseConnection->exec_SELECTgetRows(
'*',
'sys_refindex', $where,
'',
'sorting DESC');
4038 if (!is_array($rteFileRecords)) {
4041 foreach ($rteFileRecords as $rteFileRecord) {
4042 $filename = basename($rteFileRecord[
'ref_string']);
4046 $fileInfo = array();
4047 $fileInfo[
'exists'] = @is_file((PATH_site . $rteFileRecord[
'ref_string']));
4048 $fileInfo[
'original'] = substr($rteFileRecord[
'ref_string'], 0, -strlen(
$filename)) .
'RTEmagicP_' . preg_replace(
'/\\.[[:alnum:]]+$/',
'', substr(
$filename, 10));
4049 $fileInfo[
'original_exists'] = @is_file((PATH_site . $fileInfo[
'original']));
4051 if (!$fileInfo[
'exists'] || !$fileInfo[
'original_exists']) {
4052 if ($this->enableLogging) {
4053 $this->
newlog(
'Trying to copy RTEmagic files (' . $rteFileRecord[
'ref_string'] .
' / ' . $fileInfo[
'original'] .
') but one or both were missing', 1);
4058 $dirPrefix = dirname($rteFileRecord[
'ref_string']) .
'/';
4059 $rteOrigName = basename($fileInfo[
'original']);
4064 $origDestName = $this->fileFunc->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
4066 $pI = pathinfo($rteFileRecord[
'ref_string']);
4067 $copyDestName = dirname($origDestName) .
'/RTEmagicC_' . substr(basename($origDestName), 10) .
'.' . $pI[
'extension'];
4074 $this->RTEmagic_copyIndex[$rteFileRecord[
'tablename']][$rteFileRecord[
'recuid']][$rteFileRecord[
'field']][$rteFileRecord[
'ref_string']] =
PathUtility::stripPathSitePrefix($copyDestName);
4076 if (@is_file($copyDestName)) {
4080 if ($this->enableLogging && $error) {
4081 echo $this->
newlog(ReferenceIndex::class .
'::setReferenceValue(): ' . $error, 1);
4083 }
elseif ($this->enableLogging) {
4084 $this->
newlog(
'File "' . $copyDestName .
'" was not created!', 1);
4086 }
elseif ($this->enableLogging) {
4087 $this->
newlog(
'Could not construct new unique names for file!', 1);
4089 }
elseif ($this->enableLogging) {
4090 $this->
newlog(
'Maybe directory of file was not within "uploads/"?', 1);
4109 if (!
BackendUtility::isTableLocalizable($table) || !empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'transForeignTable']) || !empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable'])) {
4113 if (isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) && $GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
4114 $where =
' AND t3ver_oid=0';
4120 if (is_array($l10nRecords)) {
4121 $localizedDestPids = array();
4127 if (is_array($destL10nRecords)) {
4128 foreach ($destL10nRecords as $record) {
4129 $localizedDestPids[$record[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]] = -$record[
'uid'];
4134 foreach ($l10nRecords as $record) {
4135 $localizedDestPid = (int)$localizedDestPids[$record[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]];
4136 if ($localizedDestPid < 0) {
4137 $this->copyRecord($table, $record[
'uid'], $localizedDestPid, $first,
$overrideValues, $excludeFields, $record[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]);
4139 $this->copyRecord($table, $record[
'uid'], $destPid < 0 ? $tscPID : $destPid, $first,
$overrideValues, $excludeFields, $record[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]);
4160 if (!$GLOBALS[
'TCA'][$table]) {
4170 $uid = $lookForLiveVersion[
'uid'];
4173 $destPid = (int)$destPid;
4178 $resolvedPid = $this->
resolvePid($table, $destPid);
4181 if ($table !=
'pages' || $resolvedPid == $moveRec[
'pid']) {
4188 if ($table !=
'pages' || $resolvedPid != $moveRec[
'pid']) {
4195 $fullLanguageCheckNeeded = $table !=
'pages';
4196 $mayEditAccess = $this->BE_USER->recordEditAccessInternals($table, $uid,
false,
false, $fullLanguageCheckNeeded);
4198 if (!$mayEditAccess) {
4199 if ($this->enableLogging) {
4200 $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']);
4205 if (!$mayMoveAccess) {
4206 if ($this->enableLogging) {
4207 $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']);
4212 if (!$mayInsertAccess) {
4213 if ($this->enableLogging) {
4214 $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']);
4219 $recordWasMoved =
false;
4221 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'moveRecordClass'])) {
4222 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'moveRecordClass'] as $classRef) {
4224 if (method_exists($hookObj,
'moveRecord')) {
4225 $hookObj->moveRecord($table, $uid, $destPid, $propArr, $moveRec, $resolvedPid, $recordWasMoved, $this);
4230 if (!$recordWasMoved) {
4247 $sortRow = $GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
4248 $origDestPid = $destPid;
4250 $resolvedPid = $this->
resolvePid($table, $destPid);
4253 if ($destPid < 0 && !$sortRow || $destPid >= 0) {
4254 $destPid = $resolvedPid;
4260 $hookObjectsArr = array();
4261 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'moveRecordClass'])) {
4262 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'moveRecordClass'] as $classRef) {
4267 $updateFields = array();
4268 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']) {
4269 $updateFields[$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']] = $GLOBALS[
'EXEC_TIME'];
4272 if ($destPid >= 0) {
4277 $updateFields[
'pid'] = $destPid;
4281 $updateFields[$sortRow] = $sortNumber;
4286 $this->databaseConnection->exec_UPDATEquery($table,
'uid=' . (
int)$uid, $updateFields);
4290 foreach ($hookObjectsArr as $hookObj) {
4291 if (method_exists($hookObj,
'moveRecord_firstElementPostProcess')) {
4292 $hookObj->moveRecord_firstElementPostProcess($table, $uid, $destPid, $moveRec, $updateFields, $this);
4295 if ($this->enableLogging) {
4298 if ($destPid != $propArr[
'pid']) {
4302 $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']);
4304 $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);
4307 $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);
4314 if ($origDestPid < 0) {
4317 }
elseif ($this->enableLogging) {
4319 $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']);
4326 $originalRecordDestinationPid = $destPid;
4329 $destPid = $sortInfo[
'pid'];
4331 if (is_array($sortInfo)) {
4336 $updateFields[
'pid'] = $destPid;
4337 $updateFields[$sortRow] = $sortInfo[
'sortNumber'];
4341 $this->databaseConnection->exec_UPDATEquery($table,
'uid=' . (
int)$uid, $updateFields);
4345 foreach ($hookObjectsArr as $hookObj) {
4346 if (method_exists($hookObj,
'moveRecord_afterAnotherElementPostProcess')) {
4347 $hookObj->moveRecord_afterAnotherElementPostProcess($table, $uid, $destPid, $origDestPid, $moveRec, $updateFields, $this);
4350 if ($this->enableLogging) {
4353 if ($destPid != $propArr[
'pid']) {
4357 $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']);
4359 $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);
4362 $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);
4370 if ($origDestPid < 0) {
4373 }
elseif ($this->enableLogging) {
4375 $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']);
4378 }
elseif ($this->enableLogging) {
4379 $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']);
4395 $conf = $GLOBALS[
'TCA'][$table][
'columns'];
4397 if (is_array($row)) {
4398 foreach ($row as $field => $value) {
4417 if ($conf[
'type'] ==
'inline') {
4418 $foreign_table = $conf[
'foreign_table'];
4419 $moveChildrenWithParent = !isset($conf[
'behaviour'][
'disableMovingChildrenWithParent']) || !$conf[
'behaviour'][
'disableMovingChildrenWithParent'];
4420 if ($foreign_table && $moveChildrenWithParent) {
4422 if ($inlineType ==
'list' || $inlineType ==
'field') {
4423 if ($table ==
'pages') {
4429 $dbAnalysis->start($value, $conf[
'foreign_table'],
'', $uid, $table, $conf);
4434 if (isset($dbAnalysis)) {
4437 foreach (array_reverse($dbAnalysis->itemArray) as $v) {
4438 $this->
moveRecord($v[
'table'], $v[
'id'], $destPid);
4455 if (!
BackendUtility::isTableLocalizable($table) || !empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'transForeignTable']) || !empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable'])) {
4459 if (isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) && $GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
4460 $where =
' AND t3ver_oid=0';
4463 if (is_array($l10nRecords)) {
4464 $localizedDestPids = array();
4466 if ($originalRecordDestinationPid < 0) {
4468 $destL10nRecords =
BackendUtility::getRecordsByField($table, $GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'], abs($originalRecordDestinationPid), $where);
4470 if (is_array($destL10nRecords)) {
4471 foreach ($destL10nRecords as $record) {
4472 $localizedDestPids[$record[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]] = -$record[
'uid'];
4477 foreach ($l10nRecords as $record) {
4478 $localizedDestPid = (int)$localizedDestPids[$record[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']]];
4479 if ($localizedDestPid < 0) {
4480 $this->
moveRecord($table, $record[
'uid'], $localizedDestPid);
4482 $this->
moveRecord($table, $record[
'uid'], $destPid);
4497 public function localize($table, $uid, $language)
4506 if ((!$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] || !$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'] || $GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable']) && $table !==
'pages') {
4507 if ($this->enableLogging) {
4508 $this->
newlog(
'Localization failed; "languageField" and "transOrigPointerField" must be defined for the table!', 1);
4515 if ($this->enableLogging) {
4516 $this->
newlog(
'Sys language UID "' . $language .
'" not found valid!', 1);
4522 if ($this->enableLogging) {
4523 $this->
newlog(
'Attempt to localize record without permission', 1);
4530 if (!is_array($row)) {
4531 if ($this->enableLogging) {
4532 $this->
newlog(
'Attempt to localize record that did not exist!', 1);
4537 if ($row[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']] > 0 && $table !==
'pages') {
4538 if ($this->enableLogging) {
4539 $this->
newlog(
'Localization failed; Source record had another language than "Default" or "All" defined!', 1);
4544 if ($row[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']] != 0 && $table !==
'pages') {
4545 if ($this->enableLogging) {
4546 $this->
newlog(
'Localization failed; Source record contained a reference to an original default record (which is strange)!', 1);
4551 if ($table ===
'pages') {
4552 $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']));
4553 $Ttable =
'pages_language_overlay';
4560 if ($this->enableLogging) {
4561 $this->
newlog(
'Localization failed; There already was a localization for this language of the record!', 1);
4568 $excludeFields = array();
4570 $overrideValues[$GLOBALS[
'TCA'][$Ttable][
'ctrl'][
'languageField']] = $langRec[
'uid'];
4571 $overrideValues[$GLOBALS[
'TCA'][$Ttable][
'ctrl'][
'transOrigPointerField']] = $uid;
4573 if (isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'type']) && isset($GLOBALS[
'TCA'][$Ttable][
'ctrl'][
'type'])) {
4574 $overrideValues[$GLOBALS[
'TCA'][$Ttable][
'ctrl'][
'type']] = $row[$GLOBALS[
'TCA'][$table][
'ctrl'][
'type']];
4577 foreach ($GLOBALS[
'TCA'][$Ttable][
'columns'] as $fN => $fCfg) {
4579 if ($fCfg[
'l10n_mode'] ==
'prefixLangTitle') {
4580 if (($fCfg[
'config'][
'type'] ==
'text' || $fCfg[
'config'][
'type'] ==
'input') && (
string)$row[$fN] !==
'') {
4583 if (!empty($TSConfig[
'translateToMessage'])) {
4584 $translateToMsg = $GLOBALS[
'LANG'] ? $GLOBALS[
'LANG']->sL($TSConfig[
'translateToMessage']) : $TSConfig[
'translateToMessage'];
4585 $translateToMsg = @sprintf($translateToMsg, $langRec[
'title']);
4587 if (empty($translateToMsg)) {
4588 $translateToMsg =
'Translate to ' . $langRec[
'title'] .
':';
4590 $translateToMsg = @sprintf($TSConfig[
'translateToMessage'], $langRec[
'title']);
4595 ($fCfg[
'l10n_mode'] ===
'exclude' || $fCfg[
'l10n_mode'] ===
'noCopy' || $fCfg[
'l10n_mode'] ===
'mergeIfNotBlank')
4596 && $fN != $GLOBALS[
'TCA'][$Ttable][
'ctrl'][
'languageField']
4597 && $fN != $GLOBALS[
'TCA'][$Ttable][
'ctrl'][
'transOrigPointerField']
4601 $excludeFields[] = $fN;
4604 if ($Ttable === $table) {
4608 $newId = $this->copyRecord($table, $uid, -$previousUid, 1,
$overrideValues, implode(
',', $excludeFields), $language);
4610 if (is_null($autoVersionNewId) ===
false) {
4611 $this->
triggerRemapAction($table, $newId, array($this,
'placeholderShadowing'), array($table, $autoVersionNewId),
true);
4617 $copyTCE->start(array($Ttable => array(
'NEW' =>
$overrideValues)),
'', $this->BE_USER);
4618 $copyTCE->process_datamap();
4620 $theNewSQLID = $copyTCE->substNEWwithIDs[
'NEW'];
4623 $this->copyMappingArray[$Ttable][$uid] = $theNewSQLID;
4624 $newId = $theNewSQLID;
4640 protected function inlineLocalizeSynchronize($table, $id, $command)
4650 $config = $GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
4651 $foreignTable = $config[
'foreign_table'];
4653 if ($localizationMode !=
'select') {
4658 $language = (int)$parentRecord[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']];
4659 $transOrigPointer = (int)$parentRecord[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']];
4661 $childTransOrigPointerField = $GLOBALS[
'TCA'][$foreignTable][
'ctrl'][
'transOrigPointerField'];
4663 if (!$parentRecord || !is_array($parentRecord) || $language <= 0 || !$transOrigPointer) {
4670 if ($inlineSubType ===
false) {
4674 $removeArray = array();
4675 $mmTable = $inlineSubType ==
'mm' && isset($config[
'MM']) && $config[
'MM'] ? $config[
'MM'] :
'';
4679 $dbAnalysisOriginal->start($transOrigRecord[$field], $foreignTable, $mmTable, $transOrigRecord[
'uid'], $transOrigTable, $config);
4680 $elementsOriginal = array();
4681 foreach ($dbAnalysisOriginal->itemArray as $item) {
4682 $elementsOriginal[$item[
'id']] = $item;
4684 unset($dbAnalysisOriginal);
4688 $dbAnalysisCurrent->start($parentRecord[$field], $foreignTable, $mmTable, $id, $table, $config);
4690 if ($type ==
'synchronize') {
4691 foreach ($dbAnalysisCurrent->itemArray as $index => $item) {
4693 if (isset($childRecord[$childTransOrigPointerField]) && $childRecord[$childTransOrigPointerField] > 0) {
4694 $childTransOrigPointer = $childRecord[$childTransOrigPointerField];
4696 if (!isset($elementsOriginal[$childTransOrigPointer])) {
4697 unset($dbAnalysisCurrent->itemArray[$index]);
4698 $removeArray[$item[
'table']][$item[
'id']][
'delete'] = 1;
4705 $item = $elementsOriginal[$type];
4706 $item[
'id'] = $this->localize($item[
'table'], $item[
'id'], $language);
4708 $dbAnalysisCurrent->itemArray[] = $item;
4709 }
elseif ($type ===
'localize' || $type ===
'synchronize') {
4710 foreach ($elementsOriginal as $originalId => $item) {
4711 $item[
'id'] = $this->localize($item[
'table'], $item[
'id'], $language);
4713 $dbAnalysisCurrent->itemArray[] = $item;
4717 $value = implode(
',', $dbAnalysisCurrent->getValueArray());
4718 $this->registerDBList[$table][$id][$field] = $value;
4720 if (is_array($removeArray) && !empty($removeArray)) {
4723 $tce->stripslashes_values =
false;
4724 $tce->start(array(), $removeArray);
4725 $tce->process_cmdmap();
4728 $updateFields = array();
4730 if ($inlineSubType ==
'list') {
4731 $updateFields = array($field => $value);
4732 }
elseif ($inlineSubType ==
'field') {
4733 $dbAnalysisCurrent->writeForeignField($config, $id);
4734 $updateFields = array($field => $dbAnalysisCurrent->countItems(
false));
4735 }
elseif ($inlineSubType ==
'mm') {
4736 $dbAnalysisCurrent->writeMM($config[
'MM'], $id);
4737 $updateFields = array($field => $dbAnalysisCurrent->countItems(
false));
4740 if (!empty($updateFields)) {
4741 $this->
updateDB($table, $id, $updateFields);
4761 if (is_array($recordToDelete)) {
4762 $recordWasDeleted =
false;
4763 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processCmdmapClass'])) {
4764 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'processCmdmapClass'] as $classRef) {
4766 if (method_exists($hookObj,
'processCmdmap_deleteAction')) {
4767 $hookObj->processCmdmap_deleteAction($table, $id, $recordToDelete, $recordWasDeleted, $this);
4772 if (!$recordWasDeleted) {
4787 public function deleteEl($table, $uid, $noRecordCheck =
false, $forceHardDelete =
false)
4789 if ($table ==
'pages') {
4790 $this->deletePages($uid, $noRecordCheck, $forceHardDelete);
4793 $this->
deleteRecord($table, $uid, $noRecordCheck, $forceHardDelete);
4808 if (is_array($versions)) {
4809 foreach ($versions as $verRec) {
4810 if (!$verRec[
'_CURRENT_VERSION']) {
4811 if ($table ==
'pages') {
4812 $this->deletePages($verRec[
'uid'],
true, $forceHardDelete);
4814 $this->
deleteRecord($table, $verRec[
'uid'],
true, $forceHardDelete);
4821 $this->
deleteEl($table, $versionMovePlaceholder[
'uid'],
true, $forceHardDelete);
4855 public function deleteRecord($table, $uid, $noRecordCheck =
false, $forceHardDelete =
false, $undeleteRecord =
false)
4858 if (!$GLOBALS[
'TCA'][$table] || !$uid) {
4859 if ($this->enableLogging) {
4860 $this->
log($table, $uid, 3, 0, 1,
'Attempt to delete record without delete-permissions. [' . $this->BE_USER->errorMsg .
']');
4866 $deletedRecord = $forceHardDelete || $undeleteRecord;
4867 $hasEditAccess = $this->BE_USER->recordEditAccessInternals($table, $uid,
false, $deletedRecord,
true);
4868 if (!$hasEditAccess) {
4869 if ($this->enableLogging) {
4870 $this->
log($table, $uid, 3, 0, 1,
'Attempt to delete record without delete-permissions');
4874 if (!$noRecordCheck && !$this->
doesRecordExist($table, $uid,
'delete')) {
4880 $deleteField = $GLOBALS[
'TCA'][$table][
'ctrl'][
'delete'];
4881 if ($deleteField && !$forceHardDelete) {
4882 $updateFields = array(
4883 $deleteField => $undeleteRecord ? 0 : 1
4885 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']) {
4886 $updateFields[$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']] = $GLOBALS[
'EXEC_TIME'];
4889 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'] && !$undeleteRecord) {
4890 $updateFields[$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']] = 1000000000;
4894 $this->databaseConnection->exec_UPDATEquery($table,
'uid=' . (
int)$uid, $updateFields);
4896 if (!$undeleteRecord) {
4901 foreach ($GLOBALS[
'TCA'][$table][
'columns'] as $fieldName => $cfg) {
4902 $conf = $cfg[
'config'];
4903 switch ($conf[
'type']) {
4906 $flexObj->traverseFlexFormXMLData($table, $fieldName,
BackendUtility::getRecordRaw($table,
'uid=' . (
int)$uid), $this,
'deleteRecord_flexFormCallBack');
4912 if (!empty($fileFieldArr)) {
4913 $mres = $this->databaseConnection->exec_SELECTquery(implode(
',', $fileFieldArr), $table,
'uid=' . (
int)$uid);
4914 if ($row = $this->databaseConnection->sql_fetch_assoc($mres)) {
4915 $fArray = $fileFieldArr;
4917 foreach ($fArray as $theField) {
4921 }
elseif ($this->enableLogging) {
4922 $this->
log($table, $uid, 3, 0, 100,
'Delete: Zero rows in result when trying to read filenames from record which should be deleted');
4924 $this->databaseConnection->sql_free_result($mres);
4927 $this->databaseConnection->exec_DELETEquery($table,
'uid=' . (
int)$uid);
4930 if ($this->enableLogging) {
4932 $state = $undeleteRecord ? 1 : 3;
4933 if (!$this->databaseConnection->sql_error()) {
4934 if ($forceHardDelete) {
4935 $message =
'Record \'%s\' (%s) was deleted unrecoverable from page \'%s\' (%s)';
4937 $message = $state == 1 ?
'Record \'%s\' (%s) was restored on page \'%s\' (%s)' :
'Record \'%s\' (%s) was deleted from page \'%s\' (%s)';
4942 $this->
log($table, $uid, $state, 0, 0, $message, 0, array(
4944 $table .
':' . $uid,
4945 $pagePropArr[
'header'],
4947 ), $propArr[
'event_pid']);
4949 $this->
log($table, $uid, $state, 0, 100, $this->databaseConnection->sql_error());
4953 $this->updateRefIndex($table, $uid);
4955 if (is_array($this->updateRefIndexStack[$table]) && is_array($this->updateRefIndexStack[$table][$uid])) {
4956 while ($args = array_pop($this->updateRefIndexStack[$table][$uid])) {
4958 $this->updateRefIndex($args[0], $args[1]);
4960 unset($this->updateRefIndexStack[$table][$uid]);
4974 public function deleteRecord_flexFormCallBack($dsArr, $dataValue, $PA, $structurePath, $pObj)
4979 $files = $refIndexObj->getRelations_procFiles($dataValue, $dsArr[
'TCEforms'][
'config'], $PA[
'uid']);
4981 if (is_array($files) && $dsArr[
'TCEforms'][
'config'][
'internal_type'] ===
'file') {
4982 foreach ($files as $dat) {
4983 if (@is_file($dat[
'ID_absFile'])) {
4986 }
elseif ($this->enableLogging) {
4987 $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');
5001 public function deletePages($uid, $force =
false, $forceHardDelete =
false)
5012 if (is_array($res)) {
5013 foreach ($res as $deleteId) {
5022 $flashMessageService->getMessageQueueByIdentifier()->addMessage($flashMessage);
5024 if ($this->enableLogging) {
5043 foreach ($GLOBALS[
'TCA'] as $table => $_) {
5044 if ($table !=
'pages') {
5045 $mres = $this->databaseConnection->exec_SELECTquery(
'uid', $table,
'pid=' . (
int)$uid . $this->
deleteClause($table));
5046 while ($row = $this->databaseConnection->sql_fetch_assoc($mres)) {
5047 $this->copyMovedRecordToNewLocation($table, $row[
'uid']);
5049 $this->
deleteRecord($table, $row[
'uid'],
true, $forceHardDelete);
5051 $this->databaseConnection->sql_free_result($mres);
5054 $this->copyMovedRecordToNewLocation(
'pages', $uid);
5056 $this->
deleteRecord(
'pages', $uid,
true, $forceHardDelete);
5073 protected function copyMovedRecordToNewLocation($table, $uid)
5075 if ($this->BE_USER->workspace > 0) {
5078 if ($movePlaceholder !==
false) {
5085 'copy' =>
'-' . $movePlaceholder[
'uid']
5091 $dataHandler->stripslashes_values =
false;
5092 $dataHandler->neverHideAtCopy =
true;
5093 $dataHandler->start(array(), $command);
5094 $dataHandler->process_cmdmap();
5095 unset($dataHandler);
5098 $this->
deleteRecord($table, $movePlaceholder[
'uid'],
true,
true);
5113 return 'Attempt to delete page without permissions';
5116 if ($this->deleteTree) {
5118 $brExist = $this->
doesBranchExist(
'', $uid, $this->pMap[
'delete'], 1);
5120 if ($brExist == -1) {
5121 return 'Attempt to delete pages in branch without permissions';
5125 return 'Attempt to delete records from disallowed tables';
5129 foreach ($pagesInBranch as $pageInBranch) {
5130 if (!$this->BE_USER->recordEditAccessInternals(
'pages', $pageInBranch,
false,
false,
true)) {
5131 return 'Attempt to delete page which has prohibited localizations.';
5134 return $pagesInBranch;
5137 $brExist = $this->
doesBranchExist(
'', $uid, $this->pMap[
'delete'], 1);
5139 if ($brExist !=
'') {
5140 return 'Attempt to delete page which has subpages';
5144 return 'Attempt to delete records from disallowed tables';
5147 if ($this->BE_USER->recordEditAccessInternals(
'pages', $uid,
false,
false,
true)) {
5150 return 'Attempt to delete page which has prohibited localizations.';
5164 if ($table ===
'pages') {
5166 return is_array($res) ?
false : $res;
5168 return $this->
doesRecordExist($table, $id,
'delete') ?
false :
'No permission to delete record';
5183 if ($record[
'pid']) {
5186 if (!$page[
'deleted']) {
5188 }
elseif ($this->enableLogging) {
5189 $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');
5210 $conf = $GLOBALS[
'TCA'][$table][
'columns'];
5212 foreach ($row as $field => $value) {
5213 $this->deleteRecord_procBasedOnFieldType($table, $uid, $field, $value, $conf[$field][
'config'], $undeleteRecord);
5230 public function deleteRecord_procBasedOnFieldType($table, $uid, $field, $value, $conf, $undeleteRecord =
false)
5232 if ($conf[
'type'] ==
'inline') {
5233 $foreign_table = $conf[
'foreign_table'];
5234 if ($foreign_table) {
5236 if ($inlineType ==
'list' || $inlineType ==
'field') {
5239 $dbAnalysis->start($value, $conf[
'foreign_table'],
'', $uid, $table, $conf);
5240 $dbAnalysis->undeleteRecord =
true;
5242 $enableCascadingDelete =
true;
5244 if (isset($conf[
'behaviour'][
'enableCascadingDelete']) && $conf[
'behaviour'][
'enableCascadingDelete'] ==
false) {
5245 $enableCascadingDelete =
false;
5249 foreach ($dbAnalysis->itemArray as $v) {
5250 if (!$undeleteRecord) {
5251 if ($enableCascadingDelete) {
5261 $allowedTables = $conf[
'type'] ==
'group' ? $conf[
'allowed'] : $conf[
'foreign_table'];
5263 $dbAnalysis->start($value, $allowedTables, $conf[
'MM'], $uid, $table, $conf);
5264 foreach ($dbAnalysis->itemArray as $v) {
5265 $this->updateRefIndexStack[$table][$uid][] = array($v[
'table'], $v[
'id']);
5280 if (!
BackendUtility::isTableLocalizable($table) || !empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'transForeignTable']) || !empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable'])) {
5284 if (isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) && $GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
5285 $where =
' AND t3ver_oid=0';
5288 if (is_array($l10nRecords)) {
5289 foreach ($l10nRecords as $record) {
5298 $this->
deleteAction($table, (
int)$record[
't3ver_oid'] > 0 ? (
int)$record[
't3ver_oid'] : (
int)$record[
'uid']);
5327 if (!$GLOBALS[
'TCA'][$table] || !$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] || $id <= 0) {
5328 if ($this->enableLogging) {
5329 $this->
newlog(
'Versioning is not supported for this table "' . $table .
'" / ' . $id, 1);
5335 if ($this->enableLogging) {
5336 $this->
newlog(
'You didn\'t have correct permissions to make a new version (copy) of this record "' . $table .
'" / ' . $id, 1);
5342 $row = $this->
recordInfo($table, $id,
'pid,t3ver_id,t3ver_state');
5343 if (!is_array($row)) {
5344 if ($this->enableLogging) {
5345 $this->
newlog(
'Record "' . $table .
':' . $id .
'" you wanted to versionize did not exist!', 1);
5351 if ($row[
'pid'] < 0) {
5352 if ($this->enableLogging) {
5353 $this->
newlog(
'Record "' . $table .
':' . $id .
'" you wanted to versionize was already a version in archive (pid=-1)!', 1);
5360 if ($this->enableLogging) {
5361 $this->
newlog(
'Record cannot be versioned because it is a placeholder for a moving operation', 1);
5367 if ($this->enableLogging) {
5374 $res = $this->databaseConnection->exec_SELECTquery(
't3ver_id', $table,
'((pid=-1 && t3ver_oid=' . $id .
') OR uid=' . $id .
')' . $this->
deleteClause($table),
'',
't3ver_id DESC',
'1');
5375 list($highestVerNumber) = $this->databaseConnection->sql_fetch_row($res);
5376 $this->databaseConnection->sql_free_result($res);
5378 $subVer = $row[
't3ver_id'] .
'.' . ($highestVerNumber + 1);
5380 $overrideArray = array(
5381 't3ver_id' => $highestVerNumber + 1,
5383 't3ver_label' => $label ?: $subVer .
' / ' . date(
'd-m-Y H:m:s'),
5384 't3ver_wsid' => $this->BE_USER->workspace,
5390 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']) {
5391 $overrideArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'editlock']] = 0;
5394 if ($this->BE_USER->workspace !== 0) {
5399 if (empty($versionRecord[
'uid'])) {
5405 $workspaceOptions = array(
5406 'delete' => $delete,
5409 return $this->
copyRecord_raw($table, $id, -1, $overrideArray, $workspaceOptions);
5414 return $versionRecord[
'uid'];
5428 public function version_remapMMForVersionSwap($table, $id, $swapWith)
5433 $this->version_remapMMForVersionSwap_reg = array();
5434 foreach ($GLOBALS[
'TCA'][$table][
'columns'] as $field => $fConf) {
5435 $conf = $fConf[
'config'];
5437 $allowedTables = $conf[
'type'] ==
'group' ? $conf[
'allowed'] : $conf[
'foreign_table'];
5438 $prependName = $conf[
'type'] ==
'group' ? $conf[
'prepend_tname'] :
'';
5442 $dbAnalysis->start(
'', $allowedTables, $conf[
'MM'], $id, $table, $conf);
5443 if (!empty($dbAnalysis->getValueArray($prependName))) {
5444 $this->version_remapMMForVersionSwap_reg[$id][$field] = array($dbAnalysis, $conf[
'MM'], $prependName);
5448 $dbAnalysis->start(
'', $allowedTables, $conf[
'MM'], $swapWith, $table, $conf);
5449 if (!empty($dbAnalysis->getValueArray($prependName))) {
5450 $this->version_remapMMForVersionSwap_reg[$swapWith][$field] = array($dbAnalysis, $conf[
'MM'], $prependName);
5453 }
elseif ($conf[
'type'] ==
'flex') {
5457 if (is_array($currentValueArray)) {
5458 $this->
checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table, $id, $field),
'version_remapMMForVersionSwap_flexFormCallBack');
5463 if (is_array($currentValueArray)) {
5464 $this->
checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table, $swapWith, $field),
'version_remapMMForVersionSwap_flexFormCallBack');
5484 public function version_remapMMForVersionSwap_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path)
5487 list($table, $uid, $field) = $pParams;
5489 $allowedTables = $dsConf[
'type'] ==
'group' ? $dsConf[
'allowed'] : $dsConf[
'foreign_table'];
5490 $prependName = $dsConf[
'type'] ==
'group' ? $dsConf[
'prepend_tname'] :
'';
5491 if ($dsConf[
'MM']) {
5494 $dbAnalysis->start(
'', $allowedTables, $dsConf[
'MM'], $uid, $table, $dsConf);
5495 $this->version_remapMMForVersionSwap_reg[$uid][$field .
'/' . $path] = array($dbAnalysis, $dsConf[
'MM'], $prependName);
5512 if (is_array($this->version_remapMMForVersionSwap_reg[$id])) {
5513 foreach ($this->version_remapMMForVersionSwap_reg[$id] as $field => $str) {
5514 $str[0]->remapMM($str[1], $id, -$id, $str[2]);
5517 if (is_array($this->version_remapMMForVersionSwap_reg[$swapWith])) {
5518 foreach ($this->version_remapMMForVersionSwap_reg[$swapWith] as $field => $str) {
5519 $str[0]->remapMM($str[1], $swapWith, $id, $str[2]);
5522 if (is_array($this->version_remapMMForVersionSwap_reg[$id])) {
5523 foreach ($this->version_remapMMForVersionSwap_reg[$id] as $field => $str) {
5524 $str[0]->remapMM($str[1], -$id, $swapWith, $str[2]);
5545 $copyTCE->stripslashes_values = $stripslashesValues;
5561 if (!empty($this->registerDBList)) {
5562 foreach ($this->registerDBList as $table => $records) {
5563 foreach ($records as $uid => $fields) {
5565 $theUidToUpdate = $this->copyMappingArray_merged[$table][$uid];
5567 foreach ($fields as $fieldName => $value) {
5568 $conf = $GLOBALS[
'TCA'][$table][
'columns'][$fieldName][
'config'];
5569 switch ($conf[
'type']) {
5574 if (is_array($vArray)) {
5575 $newData[$fieldName] = implode(
',', $vArray);
5579 if ($value ==
'FlexForm_reference') {
5581 $origRecordRow = $this->
recordInfo($table, $theUidToUpdate,
'*');
5582 if (is_array($origRecordRow)) {
5588 $currentValueArray[
'data'] = $this->
checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table, $theUidToUpdate, $fieldName),
'remapListedDBRecords_flexFormCallBack');
5590 if (is_array($currentValueArray[
'data'])) {
5591 $newData[$fieldName] = $this->checkValue_flexArray2Xml($currentValueArray,
true);
5597 $this->remapListedDBRecords_procInline($conf, $value, $uid, $table);
5600 debug(
'Field type should not appear here: ' . $conf[
'type']);
5604 if (!empty($newData)) {
5605 $this->
updateDB($table, $theUidToUpdate_saveTo, $newData);
5626 list($table, $uid, $field) = $pParams;
5630 if (is_array($vArray)) {
5631 $dataValue = implode(
',', $vArray);
5635 return array(
'value' => $dataValue);
5654 $allowedTables = $conf[
'type'] ==
'group' ? $conf[
'allowed'] : $conf[
'foreign_table'];
5656 $prependName = $conf[
'type'] ==
'group' ? $conf[
'prepend_tname'] :
'';
5661 $dbAnalysis->registerNonTableValues = $conf[
'type'] ==
'select' && $conf[
'allowNonIdValues'];
5662 $dbAnalysis->start($value, $allowedTables, $conf[
'MM'], $MM_localUid, $table, $conf);
5664 foreach ($dbAnalysis->itemArray as $k => $v) {
5665 $mapID = $this->copyMappingArray_merged[$v[
'table']][$v[
'id']];
5666 if ($mapID && !in_array($v[
'table'], $dontRemapTables,
true)) {
5667 $dbAnalysis->itemArray[$k][
'id'] = $mapID;
5671 if (!empty($conf[
'MM'])) {
5673 $dbAnalysis->purgeItemArray();
5674 if ($dbAnalysis->isPurged()) {
5680 if (!empty($this->copyMappingArray_merged[$table])) {
5681 $originalId = array_search($MM_localUid, $this->copyMappingArray_merged[$table]);
5683 if (!empty($liveId) && !empty($originalId) && (
int)$liveId === (
int)$originalId) {
5685 $liveRelations->setWorkspaceId(0);
5686 $liveRelations->start(
'', $allowedTables, $conf[
'MM'], $liveId, $table, $conf);
5688 $liveRelations->purgeItemArray(0);
5689 if ($liveRelations->isPurged()) {
5690 $liveRelations->writeMM($conf[
'MM'], $liveId, $prependName);
5697 $dbAnalysis->writeMM($conf[
'MM'], $MM_localUid, $prependName);
5699 return $dbAnalysis->getValueArray($prependName);
5714 public function remapListedDBRecords_procInline($conf, $value, $uid, $table)
5716 $theUidToUpdate = $this->copyMappingArray_merged[$table][$uid];
5717 if ($conf[
'foreign_table']) {
5719 if ($inlineType ==
'mm') {
5721 }
elseif ($inlineType !==
false) {
5724 $dbAnalysis->start($value, $conf[
'foreign_table'],
'', 0, $table, $conf);
5727 $originalItemArray = $dbAnalysis->itemArray;
5728 foreach ($dbAnalysis->itemArray as &$item) {
5730 if (!empty($versionedId)) {
5731 $item[
'id'] = $versionedId;
5736 if ($inlineType ==
'field') {
5737 $dbAnalysis->writeForeignField($conf, $uid, $theUidToUpdate);
5739 $thePidToUpdate = null;
5741 if ($table ==
'pages') {
5742 $thePidToUpdate = $theUidToUpdate;
5743 }
elseif (isset($this->registerDBPids[$table][$uid])) {
5744 $thePidToUpdate = $this->registerDBPids[$table][$uid];
5745 $thePidToUpdate = $this->copyMappingArray_merged[
'pages'][$thePidToUpdate];
5748 if ($thePidToUpdate) {
5749 $updateValues = array(
'pid' => $thePidToUpdate);
5750 foreach ($originalItemArray as $v) {
5752 $this->databaseConnection->exec_UPDATEquery($v[
'table'],
'uid=' . (
int)$v[
'id'], $updateValues);
5769 if (is_array($this->remapStack)) {
5770 $remapFlexForms = array();
5772 foreach ($this->remapStack as $remapAction) {
5774 if (!is_array($remapAction[
'pos'])) {
5778 $field = $remapAction[
'field'];
5779 $id = $remapAction[
'args'][$remapAction[
'pos'][
'id']];
5781 $table = $remapAction[
'args'][$remapAction[
'pos'][
'table']];
5782 $valueArray = $remapAction[
'args'][$remapAction[
'pos'][
'valueArray']];
5783 $tcaFieldConf = $remapAction[
'args'][$remapAction[
'pos'][
'tcaFieldConf']];
5784 $additionalData = $remapAction[
'additionalData'];
5786 if (strpos($id,
'NEW') !==
false) {
5788 $id = $this->substNEWwithIDs[$id];
5790 if (isset($this->autoVersionIdMap[$table][$id])) {
5791 $id = $this->autoVersionIdMap[$table][$id];
5793 $remapAction[
'args'][$remapAction[
'pos'][
'id']] = $id;
5796 if (is_array($valueArray)) {
5797 $foreign_table = $tcaFieldConf[
'foreign_table'];
5798 foreach ($valueArray as $key => $value) {
5799 if (strpos($value,
'NEW') !==
false) {
5800 $value = $this->substNEWwithIDs[$value];
5802 if (isset($this->autoVersionIdMap[$foreign_table][$value])) {
5803 $value = $this->autoVersionIdMap[$foreign_table][$value];
5806 $this->newRelatedIDs[$foreign_table][] = $value;
5807 $valueArray[$key] = $value;
5810 $remapAction[
'args'][$remapAction[
'pos'][
'valueArray']] = $valueArray;
5813 $newValue = call_user_func_array(array($this, $remapAction[
'func']), $remapAction[
'args']);
5815 if (is_array($newValue)) {
5822 if (!empty($field)) {
5823 $this->
updateDB($table, $id, array($field => $newValue));
5825 }
elseif (!empty($additionalData[
'flexFormId']) && !empty($additionalData[
'flexFormPath'])) {
5826 $flexFormId = $additionalData[
'flexFormId'];
5827 $flexFormPath = $additionalData[
'flexFormPath'];
5829 if (!isset($remapFlexForms[$flexFormId])) {
5830 $remapFlexForms[$flexFormId] = array();
5833 $remapFlexForms[$flexFormId][$flexFormPath] = $newValue;
5836 if (isset($this->remapStackRecords[$table][$rawId][
'processDatamap_afterDatabaseOperations'])) {
5837 $hookArgs = $this->remapStackRecords[$table][$rawId][
'processDatamap_afterDatabaseOperations'];
5839 $hookArgs[
'fieldArray'][$field] = $newValue;
5841 $hookObjectsArr = $hookArgs[
'hookObjectsArr'];
5842 foreach ($hookObjectsArr as $hookObj) {
5843 if (method_exists($hookObj,
'processDatamap_afterDatabaseOperations')) {
5844 $hookObj->processDatamap_afterDatabaseOperations($hookArgs[
'status'], $table, $rawId, $hookArgs[
'fieldArray'], $this);
5850 if ($remapFlexForms) {
5851 foreach ($remapFlexForms as $flexFormId => $modifications) {
5857 if ($this->remapStackActions) {
5858 foreach ($this->remapStackActions as $action) {
5859 if (isset($action[
'callback']) && isset($action[
'arguments'])) {
5860 call_user_func_array($action[
'callback'], $action[
'arguments']);
5865 foreach ($this->remapStackRefIndex as $table => $idArray) {
5866 foreach ($idArray as $id) {
5867 $this->updateRefIndex($table, $id);
5868 unset($this->remapStackRefIndex[$table][$id]);
5872 $this->remapStack = array();
5873 $this->remapStackRecords = array();
5874 $this->remapStackActions = array();
5875 $this->remapStackRefIndex = array();
5887 list($table, $uid, $field) = explode(
':', $flexFormId, 3);
5890 $uid = $this->substNEWwithIDs[$uid];
5893 $record = $this->
recordInfo($table, $uid,
'*');
5895 if (!$table || !$uid || !$field || !is_array($record)) {
5905 foreach ($modifications as $path => $value) {
5907 $valueStructure[
'data'], $path, $value
5911 if (is_array($valueStructure[
'data'])) {
5914 $field => $this->checkValue_flexArray2Xml($valueStructure,
true),
5917 $this->
updateDB($table, $uid, $values);
5936 protected function triggerRemapAction($table, $id, array $callback, array $arguments, $forceRemapStackActions =
false)
5939 if (!$forceRemapStackActions && !isset($this->remapStackRecords[$table][$id]) && !isset($this->remapStackChildIds[$id])) {
5940 call_user_func_array($callback, $arguments);
5957 $this->remapStackActions[] = array(
5962 'callback' => $callback,
5963 'arguments' => $arguments
5976 $this->remapStackRefIndex[$table][$id] = $id;
5994 foreach ($incomingFieldArray as $field => $value) {
5995 $fieldConf = $GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
5996 if (
$registerDBList[$table][$id][$field] && ($foreignTable = $fieldConf[
'foreign_table'])) {
5997 $newValueArray = array();
5998 $origValueArray = explode(
',', $value);
6000 foreach ($origValueArray as $childId) {
6001 $newValueArray[] = $this->autoVersionIdMap[$foreignTable][$childId] ? $this->autoVersionIdMap[$foreignTable][$childId] : $childId;
6004 $incomingFieldArray[$field] = implode(
',', $newValueArray);
6026 public function checkModifyAccessList($table)
6032 $hookObject->checkModifyAccessList($res, $table, $this);
6046 if (!isset($this->isRecordInWebMount_Cache[($table .
':' . $id)])) {
6048 $this->isRecordInWebMount_Cache[$table .
':' . $id] = $this->
isInWebMount($recP[
'event_pid']);
6050 return $this->isRecordInWebMount_Cache[$table .
':' . $id];
6061 if (!isset($this->isInWebMount_Cache[$pid])) {
6062 $this->isInWebMount_Cache[$pid] = $this->BE_USER->isInWebMount($pid);
6064 return $this->isInWebMount_Cache[$pid];
6079 if (is_array($hookObjectsArr)) {
6080 foreach ($hookObjectsArr as $hookObj) {
6081 if (method_exists($hookObj,
'checkRecordUpdateAccess')) {
6082 $res = $hookObj->checkRecordUpdateAccess($table, $id, $data, $res, $this);
6086 if ($res === 1 || $res === 0) {
6091 if ($GLOBALS[
'TCA'][$table] && (
int)$id > 0) {
6093 if (isset($this->recUpdateAccessCache[$table][$id])) {
6094 return $this->recUpdateAccessCache[$table][$id];
6099 $this->recUpdateAccessCache[$table][$id] = $res;
6120 if (isset($this->recInsertAccessCache[$insertTable][$pid])) {
6121 return $this->recInsertAccessCache[$insertTable][$pid];
6125 if ($insertTable ===
'pages') {
6126 $perms = $this->pMap[
'new'];
6128 }
elseif (($insertTable ===
'sys_file_reference') && array_key_exists(
'pages', $this->datamap)) {
6129 $perms = $this->pMap[
'edit'];
6131 $perms = $this->pMap[
'editcontent'];
6140 $this->recInsertAccessCache[$insertTable][$pid] = $res;
6141 }
elseif ($this->enableLogging) {
6143 $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']);
6145 }
elseif ($this->enableLogging) {
6147 $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']);
6161 $page_uid = (int)$page_uid;
6162 $rootLevelSetting = (int)$GLOBALS[
'TCA'][$checkTable][
'ctrl'][
'rootLevel'];
6164 if ($checkTable !==
'pages' && $rootLevelSetting !== -1 && ($rootLevelSetting xor !$page_uid)) {
6175 $doktype = $this->
pageInfo($page_uid,
'doktype');
6176 $allowedTableList = isset($GLOBALS[
'PAGES_TYPES'][$doktype][
'allowedTables'])
6177 ? $GLOBALS[
'PAGES_TYPES'][$doktype][
'allowedTables']
6178 : $GLOBALS[
'PAGES_TYPES'][
'default'][
'allowedTables'];
6181 if (strpos($allowedTableList,
'*') !==
false || in_array($checkTable, $allowedArray,
true)) {
6201 if ($this->bypassAccessCheckForRecords) {
6206 if ($table !=
'pages') {
6214 if ($table ===
'sys_file_reference' && array_key_exists(
'pages', $this->datamap)) {
6217 $perms =
'editcontent';
6222 $perms = (int)$this->pMap[$perms];
6224 $perms = (int)$perms;
6227 throw new \RuntimeException(
'Internal ERROR: no permissions to check for non-admin user', 1270853920);
6231 if (is_array($GLOBALS[
'TCA'][$table]) && $id > 0 && ($isWebMountRestrictionIgnored || $this->
isRecordInWebMount($table, $id) || $this->admin)) {
6232 if ($table !=
'pages') {
6234 $mres = $this->databaseConnection->exec_SELECTquery(
'uid,pid', $table,
'uid=' . (
int)$id . $this->
deleteClause($table));
6236 $output = $this->databaseConnection->sql_fetch_assoc($mres);
6239 if (is_array($output)) {
6242 $pageRec = $this->databaseConnection->sql_fetch_assoc($mres);
6245 if (is_array($pageRec) || !$output[
'pid'] && ($isRootLevelRestrictionIgnored || $this->admin)) {
6252 return $this->databaseConnection->sql_num_rows($mres);
6269 return $this->databaseConnection->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 &
Permission::PAGE_EDIT +
Permission::PAGE_DELETE +
Permission::CONTENT_EDIT ?
' AND ' . $GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'editlock'] .
'=0' :
''));
6288 $perms = (int)$perms;
6290 $mres = $this->databaseConnection->exec_SELECTquery(
'uid, perms_userid, perms_groupid, perms_user, perms_group, perms_everybody',
'pages',
'pid=' . (
int)$pid . $this->
deleteClause(
'pages'),
'',
'sorting');
6291 while ($row = $this->databaseConnection->sql_fetch_assoc($mres)) {
6293 if ($this->admin || $this->BE_USER->doesUserHaveAccess($row, $perms)) {
6294 $inList .= $row[
'uid'] .
',';
6297 $inList = $this->
doesBranchExist($inList, $row[
'uid'], $perms, $recurse);
6298 if ($inList == -1) {
6307 $this->databaseConnection->sql_free_result($mres);
6321 return (
bool)$GLOBALS[
'TCA'][$table][
'ctrl'][
'readOnly'];
6333 return (
bool)$GLOBALS[
'TCA'][$table][
'ctrl'][
'adminOnly'];
6347 $destinationId = (int)$destinationId;
6349 if ($destinationId === $id) {
6352 while ($destinationId !== 0 && $loopCheck > 0) {
6354 $res = $this->databaseConnection->exec_SELECTquery(
'pid, uid, t3ver_oid,t3ver_wsid',
'pages',
'uid=' . $destinationId . $this->
deleteClause(
'pages'));
6355 if ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
6357 if ($row[
'pid'] == $id) {
6360 $destinationId = (int)$row[
'pid'];
6365 $this->databaseConnection->sql_free_result($res);
6380 foreach ($GLOBALS[
'TCA'] as $table => $_) {
6381 if (isset($GLOBALS[
'TCA'][$table][
'columns'])) {
6382 foreach ($GLOBALS[
'TCA'][$table][
'columns'] as $field => $config) {
6383 if ($config[
'exclude'] && !isset($nonExcludeFieldsArray[$table .
':' . $field])) {
6384 $list[] = $table .
'-' . $field;
6401 $page_uid = (int)$page_uid;
6406 $allowedTableList = isset($GLOBALS[
'PAGES_TYPES'][$doktype][
'allowedTables']) ? $GLOBALS[
'PAGES_TYPES'][$doktype][
'allowedTables'] : $GLOBALS[
'PAGES_TYPES'][
'default'][
'allowedTables'];
6409 if (strstr($allowedTableList,
'*')) {
6413 $tableList = array();
6414 foreach ($GLOBALS[
'TCA'] as $table => $_) {
6416 if (!in_array($table, $allowedArray,
true)) {
6417 $count = $this->databaseConnection->exec_SELECTcountRows(
'uid', $table,
'pid=' . (
int)$page_uid);
6419 $tableList[] = $table;
6423 return implode(
',', $tableList);
6441 if (!isset($this->pageCache[$id])) {
6442 $res = $this->databaseConnection->exec_SELECTquery(
'*',
'pages',
'uid=' . (
int)$id);
6443 if ($this->databaseConnection->sql_num_rows($res)) {
6444 $this->pageCache[$id] = $this->databaseConnection->sql_fetch_assoc($res);
6446 $this->databaseConnection->sql_free_result($res);
6448 return $this->pageCache[$id][$field];
6463 if ((
int)$id === 0 || !isset($GLOBALS[
'TCA'][$table])) {
6466 $result = $this->databaseConnection->exec_SELECTgetSingleRow($fieldList, $table,
'uid=' . (
int)$id);
6467 return $result ?: null;
6483 $row = $table ==
'pages' && !$id ? array(
'title' =>
'[root-level]',
'uid' => 0,
'pid' => 0) : $this->
recordInfo($table, $id,
'*');
6499 if ($GLOBALS[
'TCA'][$table]) {
6503 'pid' => $row[
'pid'],
6504 'event_pid' => $this->
eventPid($table, isset($row[
'_ORIG_pid']) ? $row[
't3ver_oid'] : $row[
'uid'], $row[
'pid']),
6505 't3ver_state' => $GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] ? $row[
't3ver_state'] :
'',
6506 '_ORIG_pid' => $row[
'_ORIG_pid']
6521 return $table ==
'pages' ? $uid : $pid;
6540 if (is_array($fieldArray) && is_array($GLOBALS[
'TCA'][$table]) && (
int)$id) {
6542 unset($fieldArray[
'uid']);
6543 if (!empty($fieldArray)) {
6546 $this->databaseConnection->exec_UPDATEquery($table,
'uid=' . (
int)$id, $fieldArray);
6548 if (!$this->databaseConnection->sql_error()) {
6550 $this->updateRefIndex($table, $id);
6551 if ($this->enableLogging) {
6553 if ($this->checkStoredRecords) {
6558 $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']);
6565 if ($table ==
'pages') {
6566 unset($this->pageCache[$id]);
6568 }
elseif ($this->enableLogging) {
6569 $this->
log($table, $id, 2, 0, 2,
'SQL error: \'%s\' (%s)', 12, array($this->databaseConnection->sql_error(), $table .
':' . $id));
6587 public function insertDB($table, $id, $fieldArray, $newVersion =
false, $suggestedUid = 0, $dontSetNewIdIndex =
false)
6589 if (is_array($fieldArray) && is_array($GLOBALS[
'TCA'][$table]) && isset($fieldArray[
'pid'])) {
6591 unset($fieldArray[
'uid']);
6592 if (!empty($fieldArray)) {
6597 $suggestedUid = (int)$suggestedUid;
6598 if ($this->BE_USER->isAdmin() && $suggestedUid && $this->suggestedInsertUids[$table .
':' . $suggestedUid]) {
6600 if ($this->suggestedInsertUids[$table .
':' . $suggestedUid] ===
'DELETE') {
6602 $this->databaseConnection->exec_DELETEquery($table,
'uid=' . (
int)$suggestedUid);
6604 $fieldArray[
'uid'] = $suggestedUid;
6608 $this->databaseConnection->exec_INSERTquery($table, $fieldArray);
6610 if (!$this->databaseConnection->sql_error()) {
6614 $id = $this->databaseConnection->sql_insert_id();
6615 if (!$dontSetNewIdIndex) {
6616 $this->substNEWwithIDs[$NEW_id] = $id;
6617 $this->substNEWwithIDs_table[$NEW_id] = $table;
6621 if ($this->enableLogging && $this->checkStoredRecords) {
6625 $this->updateRefIndex($table, $id);
6627 if ($this->enableLogging) {
6629 $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);
6632 if ($this->enableLogging) {
6635 $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);
6641 }
elseif ($this->enableLogging) {
6642 $this->
log($table, $id, 1, 0, 2,
'SQL error: \'%s\' (%s)', 12, array($this->databaseConnection->sql_error(), $table .
':' . $id));
6662 if (is_array($GLOBALS[
'TCA'][$table]) && $id) {
6663 $res = $this->databaseConnection->exec_SELECTquery(
'*', $table,
'uid=' . (
int)$id);
6664 if ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
6667 foreach ($fieldArray as $key => $value) {
6668 if ($this->checkStoredRecords_loose && !$value && !$row[$key]) {
6669 }
elseif ((
string)$value !== (
string)$row[$key]) {
6674 if ($this->enableLogging && !empty($errors)) {
6676 'These fields of record %d in table "%s" have not been saved correctly: %s! The values might have changed due to type casting of the database.',
6679 implode(
', ', $errors)
6681 $this->
log($table, $id, $action, 0, 1, $message);
6686 $this->databaseConnection->sql_free_result($res);
6701 if (isset($this->historyRecords[$table .
':' . $id]) && (
int)$logId > 0) {
6702 $fields_values = array();
6703 $fields_values[
'history_data'] = serialize($this->historyRecords[$table .
':' . $id]);
6704 $fields_values[
'fieldlist'] = implode(
',', array_keys($this->historyRecords[$table .
':' . $id][
'newRecord']));
6705 $fields_values[
'tstamp'] = $GLOBALS[
'EXEC_TIME'];
6706 $fields_values[
'tablename'] = $table;
6707 $fields_values[
'recuid'] = $id;
6708 $fields_values[
'sys_log_uid'] = $logId;
6709 $this->databaseConnection->exec_INSERTquery(
'sys_history', $fields_values);
6721 public function updateRefIndex($table, $id)
6726 $refIndexObj->setWorkspaceId($this->BE_USER->workspace);
6728 $refIndexObj->updateRefIndexTable($table, $id);
6747 if ($GLOBALS[
'TCA'][$table] && $GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']) {
6748 $sortRow = $GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
6752 $res = $this->databaseConnection->exec_SELECTquery($sortRow .
',pid,uid', $table,
'pid=' . (
int)$pid . $this->
deleteClause($table),
'', $sortRow .
' ASC',
'1');
6754 if ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
6756 if ($row[
'uid'] == $uid) {
6757 return $row[$sortRow];
6760 if ($row[$sortRow] < 1) {
6761 $this->
resorting($table, $pid, $sortRow, 0);
6766 return floor($row[$sortRow] / 2);
6776 $res = $this->databaseConnection->exec_SELECTquery($sortRow .
',pid,uid', $table,
'uid=' . abs($pid) . $this->
deleteClause($table));
6778 if ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
6781 $row = $lookForLiveVersion;
6785 $row = $movePlaceholder;
6788 if ($row[
'uid'] == $uid) {
6789 $sortNumber = $row[$sortRow];
6791 $subres = $this->databaseConnection->exec_SELECTquery($sortRow .
',pid,uid', $table,
'pid=' . (
int)$row[
'pid'] .
' AND ' . $sortRow .
'>=' . (
int)$row[$sortRow] . $this->
deleteClause($table),
'', $sortRow .
' ASC',
'2');
6794 if ($this->databaseConnection->sql_num_rows($subres) == 2) {
6796 $this->databaseConnection->sql_fetch_assoc($subres);
6798 $subrow = $this->databaseConnection->sql_fetch_assoc($subres);
6800 $sortNumber = $row[$sortRow] + floor(($subrow[$sortRow] - $row[$sortRow]) / 2);
6802 if ($sortNumber <= $row[$sortRow] || $sortNumber >= $subrow[$sortRow]) {
6804 $sortNumber = $this->
resorting($table, $row[
'pid'], $sortRow, $row[
'uid']);
6810 $this->databaseConnection->sql_free_result($subres);
6812 return array(
'pid' => $row[
'pid'],
'sortNumber' => $sortNumber);
6814 if ($this->enableLogging) {
6817 $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']);
6839 public function resorting($table, $pid, $sortRow, $return_SortNumber_After_This_Uid)
6841 if ($GLOBALS[
'TCA'][$table] && $sortRow && $GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'] == $sortRow) {
6844 $i = $intervals * 2;
6845 $res = $this->databaseConnection->exec_SELECTquery(
'uid', $table,
'pid=' . (
int)$pid . $this->
deleteClause($table),
'', $sortRow .
' ASC');
6846 while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
6847 $uid = (int)$row[
'uid'];
6849 $this->databaseConnection->exec_UPDATEquery($table,
'uid=' . (
int)$uid, array($sortRow => $i));
6851 if ($uid == $return_SortNumber_After_This_Uid) {
6852 $i = $i + $intervals;
6856 die(
'Fatal ERROR!! No Uid at resorting.');
6858 $i = $i + $intervals;
6860 $this->databaseConnection->sql_free_result($res);
6878 $previousLocalizedRecordUid = $uid;
6879 if ($GLOBALS[
'TCA'][$table] && $GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']) {
6880 $sortRow = $GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
6881 $select = $sortRow .
',pid,uid';
6883 if ($table ===
'tt_content') {
6884 $select .=
',colPos';
6888 if (is_array($row)) {
6890 $where =
'pid=' . (int)$pid .
' AND ' .
'sys_language_uid=0' .
' AND ' . $sortRow .
'<' . (
int)$row[$sortRow];
6892 if ($table ===
'tt_content') {
6893 $where .=
' AND colPos=' . (int)$row[
'colPos'];
6895 $res = $this->databaseConnection->exec_SELECTquery($select, $table, $where . $this->
deleteClause($table),
'', $sortRow .
' DESC',
'1');
6897 if ($previousRow = $this->databaseConnection->sql_fetch_assoc($res)) {
6899 if (is_array($previousLocalizedRecord[0])) {
6900 $previousLocalizedRecordUid = $previousLocalizedRecord[0][
'uid'];
6903 $this->databaseConnection->sql_free_result($res);
6906 return $previousLocalizedRecordUid;
6919 if ((
string)$TSConfig_p[
'userid'] !==
'') {
6920 $fieldArray[
'perms_userid'] = (int)$TSConfig_p[
'userid'];
6922 if ((
string)$TSConfig_p[
'groupid'] !==
'') {
6923 $fieldArray[
'perms_groupid'] = (int)$TSConfig_p[
'groupid'];
6925 if ((
string)$TSConfig_p[
'user'] !==
'') {
6928 if ((
string)$TSConfig_p[
'group'] !==
'') {
6931 if ((
string)$TSConfig_p[
'everybody'] !==
'') {
6946 $fieldArray = array();
6947 if (is_array($GLOBALS[
'TCA'][$table][
'columns'])) {
6948 foreach ($GLOBALS[
'TCA'][$table][
'columns'] as $field => $content) {
6949 if (isset($this->defaultValues[$table][$field])) {
6950 $fieldArray[$field] = $this->defaultValues[$table][$field];
6951 }
elseif (isset($content[
'config'][
'default'])) {
6952 $fieldArray[$field] = $content[
'config'][
'default'];
6957 if ($table ===
'pages') {
6959 $fieldArray[
'perms_groupid'] = (int)$this->BE_USER->firstMainGroup;
6960 $fieldArray[
'perms_user'] = $this->assemblePermissions($this->defaultPermissions[
'user']);
6961 $fieldArray[
'perms_group'] = $this->
assemblePermissions($this->defaultPermissions[
'group']);
6962 $fieldArray[
'perms_everybody'] = $this->
assemblePermissions($this->defaultPermissions[
'everybody']);
6977 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']) {
6978 if (!isset($incomingFieldArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']])) {
6980 $rows = array_merge(array(array(
'uid' => 0)), $this->databaseConnection->exec_SELECTgetRows(
'uid',
'sys_language',
'pid=0' .
BackendUtility::deleteClause(
'sys_language')), array(array(
'uid' => -1)));
6981 foreach ($rows as $r) {
6982 if ($this->BE_USER->checkLanguageAccess($r[
'uid'])) {
6983 $incomingFieldArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']] = $r[
'uid'];
7000 if (is_array($this->overrideValues[$table])) {
7001 $data = array_merge($data, $this->overrideValues[$table]);
7018 $res = $this->databaseConnection->exec_SELECTquery(
'*', $table,
'uid=' . (
int)$id);
7019 $currentRecord = $this->databaseConnection->sql_fetch_assoc($res);
7021 if (is_array($currentRecord)) {
7024 $cRecTypes = array();
7025 foreach ($currentRecord as $col => $val) {
7026 $cRecTypes[$col] = $this->databaseConnection->sql_field_type($res, $c);
7030 $this->databaseConnection->sql_free_result($res);
7032 foreach ($fieldArray as $col => $val) {
7033 $fieldConfiguration = $GLOBALS[
'TCA'][$table][
'columns'][$col][
'config'];
7034 $isNullField = (!empty($fieldConfiguration[
'eval']) &&
GeneralUtility::inList($fieldConfiguration[
'eval'],
'null'));
7039 unset($fieldArray[$col]);
7041 if (!isset($this->mmHistoryRecords[($table .
':' . $id)][
'oldRecord'][$col])) {
7042 $this->historyRecords[$table .
':' . $id][
'oldRecord'][$col] = $currentRecord[$col];
7043 }
elseif ($this->mmHistoryRecords[$table .
':' . $id][
'oldRecord'][$col] != $this->mmHistoryRecords[$table .
':' . $id][
'newRecord'][$col]) {
7044 $this->historyRecords[$table .
':' . $id][
'oldRecord'][$col] = $this->mmHistoryRecords[$table .
':' . $id][
'oldRecord'][$col];
7046 if (!isset($this->mmHistoryRecords[($table .
':' . $id)][
'newRecord'][$col])) {
7047 $this->historyRecords[$table .
':' . $id][
'newRecord'][$col] = $fieldArray[$col];
7048 }
elseif ($this->mmHistoryRecords[$table .
':' . $id][
'newRecord'][$col] != $this->mmHistoryRecords[$table .
':' . $id][
'oldRecord'][$col]) {
7049 $this->historyRecords[$table .
':' . $id][
'newRecord'][$col] = $this->mmHistoryRecords[$table .
':' . $id][
'newRecord'][$col];
7055 $fieldArray = array();
7077 $result = (string)$submittedValue === (
string)$storedValue || $storedType ===
'int' && (int)$storedValue === (
int)$submittedValue;
7080 }
elseif ($storedValue !== null) {
7082 $submittedValue !== null
7088 $result = ($submittedValue === null);
7105 foreach ($keyArr as $key) {
7106 if ($key && isset($this->pMap[$key])) {
7107 $value |= $this->pMap[$key];
7121 return rtrim($input,
',');
7132 $token = md5(microtime());
7133 $parts = explode($token, preg_replace(
'/(&#([0-9]+);)/', $token .
'\\2' . $token, $input));
7134 foreach ($parts as $k => $v) {
7139 $parts[$k] = chr((
int)$v);
7143 return implode(
'', $parts);
7154 return PATH_site . $folder;
7179 return ' AND ' . $table .
'.' . $GLOBALS[
'TCA'][$table][
'ctrl'][
'delete'] .
'=0';
7193 if (!isset($this->cachedTSconfig[$tscPID])) {
7196 return $this->cachedTSconfig[$tscPID][
'properties'];
7209 $tA = is_array($TSconfig[
'table.'][$table .
'.']) ? $TSconfig[
'table.'][$table .
'.'] : array();
7210 $dA = is_array($TSconfig[
'default.']) ? $TSconfig[
'default.'] : array();
7224 $res_tmp = $this->databaseConnection->exec_SELECTquery(
'pid', $table,
'uid=' . (
int)$uid);
7225 if ($row = $this->databaseConnection->sql_fetch_assoc($res_tmp)) {
7239 foreach ($this->dbAnalysisStore as $action) {
7242 $action[0]->writeMM($action[1], $id, $action[3]);
7254 foreach ($this->removeFilesStore as $file) {
7255 if (@is_file($file)) {
7275 $addW = !$this->admin ?
' AND ' . $this->BE_USER->getPagePermsClause($this->pMap[
'show']) :
'';
7276 $mres = $this->databaseConnection->exec_SELECTquery(
'uid',
'pages',
'pid=' . (
int)$pid . $this->
deleteClause(
'pages') . $addW,
'',
'sorting DESC');
7277 while ($row = $this->databaseConnection->sql_fetch_assoc($mres)) {
7278 if ($row[
'uid'] != $rootID) {
7279 $CPtable[$row[
'uid']] = $pid;
7282 $CPtable = $this->
int_pageTreeInfo($CPtable, $row[
'uid'], $counter - 1, $rootID);
7286 $this->databaseConnection->sql_free_result($mres);
7298 return array_keys($GLOBALS[
'TCA']);
7310 if (empty($GLOBALS[
'TCA'][$table])) {
7314 $curData = $this->
recordInfo($table, $uid,
'*');
7316 foreach ($GLOBALS[
'TCA'][$table][
'columns'] as $field => $conf) {
7317 if ($conf[
'config'][
'type'] ===
'input' && (
string)$curData[$field] !==
'') {
7319 if (in_array(
'uniqueInPid', $evalCodesArray,
true)) {
7320 $newV = $this->
getUnique($table, $field, $curData[$field], $uid, $curData[
'pid']);
7321 if ((
string)$newV !== (
string)$curData[$field]) {
7322 $newData[$field] = $newV;
7328 if (!empty($newData)) {
7329 $this->
updateDB($table, $uid, $newData);
7346 if ($GLOBALS[
'TCA'][$table] && $GLOBALS[
'TCA'][$table][
'ctrl'][
'copyAfterDuplFields']) {
7347 $prevData = $this->
recordInfo($table, $prevUid,
'*');
7349 foreach ($theFields as $field) {
7350 if ($GLOBALS[
'TCA'][$table][
'columns'][$field] && ($update || !isset($newData[$field]))) {
7351 $newData[$field] = $prevData[$field];
7354 if ($update && !empty($newData)) {
7355 $this->
updateDB($table, $uid, $newData);
7370 if (isset($GLOBALS[
'TCA'][$table][
'columns'])) {
7371 foreach ($GLOBALS[
'TCA'][$table][
'columns'] as $field => $configArr) {
7372 if ($configArr[
'config'][
'type'] ==
'group' && ($configArr[
'config'][
'internal_type'] ==
'file' || $configArr[
'config'][
'internal_type'] ==
'file_reference')) {
7373 $listArr[] = $field;
7394 if ((
string)$value !==
'') {
7398 if (!empty($configuration[
'MM']) || !empty($configuration[
'foreign_field'])) {
7402 if (array_key_exists(
'default', $configuration)) {
7403 return $configuration[
'default'];
7417 return $conf[
'type'] ==
'group' && $conf[
'internal_type'] ==
'db' || $conf[
'type'] ==
'select' && $conf[
'foreign_table'];
7429 if ($conf[
'type'] !==
'inline' || !$conf[
'foreign_table']) {
7432 if ($conf[
'foreign_field']) {
7455 public function getCopyHeader($table, $pid, $field, $value, $count, $prevTitle =
'')
7459 $checkTitle = $value . rtrim(
' ' . sprintf($this->
prependLabel($table), $count));
7461 $checkTitle = $value;
7464 if ($prevTitle != $checkTitle || $count < 100) {
7465 $rowCount = $this->databaseConnection->exec_SELECTcountRows(
'uid', $table,
'pid=' . (
int)$pid .
' AND ' . $field .
'=' . $this->databaseConnection->fullQuoteStr($checkTitle, $table) . $this->
deleteClause($table));
7467 return $this->
getCopyHeader($table, $pid, $field, $value, $count + 1, $checkTitle);
7483 if (is_object($GLOBALS[
'LANG'])) {
7484 $label = $GLOBALS[
'LANG']->sL($GLOBALS[
'TCA'][$table][
'ctrl'][
'prependAtCopy']);
7486 list($label) = explode(
'|', $GLOBALS[
'TCA'][$table][
'ctrl'][
'prependAtCopy']);
7502 $res = $this->databaseConnection->exec_SELECTquery(
'pid', $table,
'uid=' . abs($pid));
7503 $row = $this->databaseConnection->sql_fetch_assoc($res);
7504 $this->databaseConnection->sql_free_result($res);
7510 $row = $lookForLiveVersion;
7512 $pid = (int)$row[
'pid'];
7526 $regex =
'/' . sprintf(quotemeta($this->
prependLabel($table)),
'[0-9]*') .
'$/';
7527 return @preg_replace($regex,
'', $value);
7541 $uploadFolder = $GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'uploadfolder'];
7542 if ($uploadFolder && trim($filelist) && $GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'internal_type'] ==
'file') {
7544 $fileArray = explode(
',', $filelist);
7545 foreach ($fileArray as $theFile) {
7546 $theFile = trim($theFile);
7550 $theFileFullPath = $uploadPath .
'/' . $theFile;
7551 if (@is_file($theFileFullPath)) {
7554 }
elseif ($this->enableLogging) {
7555 $this->
log($table, 0, 3, 0, 100,
'Delete: Referenced file that was supposed to be deleted together with it\'s record didn\'t exist');
7572 $inList = trim($this->
rmComma(trim($inList)));
7573 if ($inList && !$this->admin) {
7574 foreach ($GLOBALS[
'TCA'] as $table => $_) {
7575 $count = $this->databaseConnection->exec_SELECTcountRows(
'uid', $table,
'pid IN (' . $inList .
')' .
BackendUtility::deleteClause($table));
7576 if ($count && ($this->
tableReadOnly($table) || !$this->checkModifyAccessList($table))) {
7594 if (isset($this->copyMappingArray[$table][$uid])) {
7596 }
elseif (isset($this->copyMappingArray[$table]) && in_array($uid, array_values($this->copyMappingArray[$table]))) {
7620 if (!is_array(static::$recordsToClearCacheFor[$table])) {
7621 static::$recordsToClearCacheFor[$table] = array();
7623 static::$recordsToClearCacheFor[$table][] = (int)$uid;
7630 protected function processClearCacheQueue()
7632 $tagsToClear = array();
7633 $clearCacheCommands = array();
7634 foreach (static::$recordsToClearCacheFor as $table => $uids) {
7635 foreach (array_unique($uids) as $uid) {
7637 if (!isset($GLOBALS[
'TCA'][$table]) || $uid <= 0) {
7643 if (empty($TSConfig[
'clearCache_disable'])) {
7645 $pageIdsThatNeedCacheFlush = array();
7646 if ($table ===
'pages' || $table ===
'pages_language_overlay') {
7647 if ($table ===
'pages_language_overlay') {
7648 $pageUid = $this->
getPID($table, $uid);
7653 $res_tmp = $this->databaseConnection->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');
7655 while ($row_tmp = $this->databaseConnection->sql_fetch_assoc($res_tmp)) {
7656 $pageIdsThatNeedCacheFlush[] = (int)$row_tmp[
'uid'];
7657 $pid_tmp = $row_tmp[
'pid'];
7659 if ($TSConfig[
'clearCache_pageSiblingChildren']) {
7660 $res_tmp2 = $this->databaseConnection->exec_SELECTquery(
'uid',
'pages',
'pid=' . (
int)$row_tmp[
'uid'] .
' AND deleted=0');
7661 while ($row_tmp2 = $this->databaseConnection->sql_fetch_assoc($res_tmp2)) {
7662 $pageIdsThatNeedCacheFlush[] = (int)$row_tmp2[
'uid'];
7664 $this->databaseConnection->sql_free_result($res_tmp2);
7667 $this->databaseConnection->sql_free_result($res_tmp);
7669 $pageIdsThatNeedCacheFlush[] = (int)$pid_tmp;
7671 if ($TSConfig[
'clearCache_pageGrandParent']) {
7672 $res_tmp = $this->databaseConnection->exec_SELECTquery(
'pid',
'pages',
'uid=' . (
int)$pid_tmp);
7673 if ($row_tmp = $this->databaseConnection->sql_fetch_assoc($res_tmp)) {
7674 $pageIdsThatNeedCacheFlush[] = (int)$row_tmp[
'pid'];
7676 $this->databaseConnection->sql_free_result($res_tmp);
7680 $pageIdsThatNeedCacheFlush[] = $pageUid = (int)$this->
getPID($table, $uid);
7683 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearPageCacheEval'])) {
7684 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearPageCacheEval'] as $funcName) {
7685 $_params = array(
'pageIdArray' => &$pageIdsThatNeedCacheFlush,
'table' => $table,
'uid' => $uid,
'functionID' =>
'clear_cache()');
7691 foreach ($pageIdsThatNeedCacheFlush as $pageId) {
7696 $tagsToClear[
'pageId_' . $pageId] =
true;
7700 $tagsToClear[$table] =
true;
7701 $tagsToClear[$table .
'_' . $uid] =
true;
7704 if (!empty($TSConfig[
'clearCacheCmd'])) {
7706 $clearCacheCommands = array_unique($commands);
7710 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearCachePostProc'])) {
7711 $_params = array(
'table' => $table,
'uid' => $uid,
'uid_page' => $pageUid,
'TSConfig' => $TSConfig);
7712 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearCachePostProc'] as $_funcRef) {
7721 foreach ($tagsToClear as $tag => $_) {
7722 $cacheManager->flushCachesInGroupByTag(
'pages', $tag);
7726 foreach ($clearCacheCommands as $command) {
7731 static::$recordsToClearCacheFor = array();
7775 if (is_object($this->BE_USER)) {
7776 $this->BE_USER->writelog(3, 1, 0, 0,
'User %s has cleared the cache (cacheCmd=%s)', array($this->BE_USER->user[
'username'], $cacheCmd));
7779 switch (strtolower($cacheCmd)) {
7781 if ($this->admin || $this->BE_USER->getTSConfigVal(
'options.clearCache.pages')) {
7786 if ($this->admin || $this->BE_USER->getTSConfigVal(
'options.clearCache.all')) {
7789 $this->databaseConnection->exec_TRUNCATEquery(
'cache_treelist');
7795 if ($this->admin || $this->BE_USER->getTSConfigVal(
'options.clearCache.system')
7796 || ((bool)$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'clearCacheSystem'] ===
true && $this->admin)) {
7802 $tagsToFlush = array();
7805 $list_cache = array($cacheCmd);
7807 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearPageCacheEval'])) {
7808 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearPageCacheEval'] as $funcName) {
7809 $_params = array(
'pageIdArray' => &$list_cache,
'cacheCmd' => $cacheCmd,
'functionID' =>
'clear_cacheCmd()');
7815 if (is_array($list_cache)) {
7816 foreach ($list_cache as $pageId) {
7817 $tagsToFlush[] =
'pageId_' . (int)$pageId;
7823 $cacheTag = substr($cacheCmd, 9);
7824 $tagsToFlush[] = $cacheTag;
7827 if (!empty($tagsToFlush)) {
7828 foreach (array_unique($tagsToFlush) as $tag) {
7834 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearCachePostProc'])) {
7835 $_params = array(
'cacheCmd' => strtolower($cacheCmd));
7836 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tcemain.php'][
'clearCachePostProc'] as $_funcRef) {
7862 public function log($table, $recuid, $action, $recpid, $error, $details, $details_nr = -1, $data = array(), $event_pid = -1, $NEWid =
'')
7864 if (!$this->enableLogging) {
7869 if (!$this->storeLogMessages) {
7873 $detailMessage = $details;
7874 if (is_array($data)) {
7875 $detailMessage = vsprintf($details, $data);
7877 $this->errorLog[] =
'[' . $type .
'.' . $action .
'.' . $details_nr .
']: ' . $detailMessage;
7879 return $this->BE_USER->writelog($type, $action, $error, $details_nr, $details, $data, $table, $recuid, $recpid, $event_pid, $NEWid);
7892 return $this->
log(
'', 0, 0, 0, $error,
'[newlog()] ' . $message, -1);
7906 public function newlog2($message, $table, $uid, $pid = null, $error = 0)
7908 if ($pid ===
false) {
7909 GeneralUtility::deprecationLog(
'Setting the $pid parameter of DataHandler::newlog2 to FALSE is deprecated since TYPO3 CMS 7. Either provide an integer or NULL. FALSE will not be supported any more in TYPO3 CMS 8');
7912 if (is_null($pid)) {
7914 $pid = $propArr[
'pid'];
7916 return $this->
log($table, $uid, 0, 0, $error, $message, -1, array(), $this->
eventPid($table, $uid, $pid));
7925 public function printLogErrorMessages($redirect)
7927 $res_log = $this->databaseConnection->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');
7928 while ($row = $this->databaseConnection->sql_fetch_assoc($res_log)) {
7929 $log_data = unserialize($row[
'log_data']);
7930 $msg = $row[
'error'] .
': ' . sprintf($row[
'details'], $log_data[0], $log_data[1], $log_data[2], $log_data[3], $log_data[4]);
7935 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
7936 $defaultFlashMessageQueue->enqueue($flashMessage);
7938 $this->databaseConnection->sql_free_result($res_log);
7958 $result = $fieldArray;
7959 foreach ($fieldArray as $field => $value) {
7960 switch ($GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'type']) {
7962 if ($GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'][
'foreign_field']) {
7983 if (isset($this->autoVersionIdMap[$table][$id])) {
7984 $result = $this->autoVersionIdMap[$table][$id];
7999 if (is_null($autoVersionId) ===
false) {
8000 $id = $autoVersionId;
8013 foreach ($idValues as $idValue) {
8014 if (strpos($idValue,
'NEW') === 0) {
8015 $this->remapStackChildIds[$idValue] =
true;
8029 if (!isset($this->outerMostInstance)) {
8030 $stack = array_reverse(debug_backtrace());
8031 foreach ($stack as $stackItem) {
8032 if (isset($stackItem[
'object']) && $stackItem[
'object'] instanceof
DataHandler) {
8033 $this->outerMostInstance = $stackItem[
'object'];
8073 $nestedElementCalls = (array)$this->runtimeCache->get($this->cachePrefixNestedElementCalls);
8074 return isset($nestedElementCalls[$identifier][$table][$id]);
8088 $nestedElementCalls = (array)$this->runtimeCache->get($this->cachePrefixNestedElementCalls);
8089 $nestedElementCalls[$identifier][$table][$id] =
true;
8090 $this->runtimeCache->set($this->cachePrefixNestedElementCalls, $nestedElementCalls);
8100 $this->runtimeCache->remove($this->cachePrefixNestedElementCalls);
8116 $elementsToBeDeleted = (array)$this->runtimeCache->get(
'core-datahandler-elementsToBeDeleted');
8117 return isset($elementsToBeDeleted[$table][$id]);
8128 $elementsToBeDeleted = (array)$this->runtimeCache->get(
'core-datahandler-elementsToBeDeleted');
8129 $this->runtimeCache->set(
'core-datahandler-elementsToBeDeleted', array_merge($elementsToBeDeleted, $this->
getCommandMapElements(
'delete')));
8140 $this->runtimeCache->remove(
'core-datahandler-elementsToBeDeleted');
8153 foreach ($elements as $key => $value) {
8154 if (empty($value)) {
8155 unset($elements[$key]);
8169 $elements = array();
8170 foreach ($this->cmdmap as $tableName => $idArray) {
8171 foreach ($idArray as $id => $commandArray) {
8172 foreach ($commandArray as $command => $value) {
8173 if ($value && $command == $needle) {
8174 $elements[$tableName][$id] =
true;
8190 if (!empty($this->control[
'active'])) {
8192 $this->control[
'active'],
8209 foreach ($active as $key => $value) {
8211 if (is_array($value)) {
8219 $haystack[$key] = null;
8232 return 'core-datahandler-eval-' . md5($additionalIdentifier);