2 namespace TYPO3\CMS\Version\Hook;
59 $this->notificationEmailInfo = array();
61 $tcemainObj->cmdmap = $this->
getCommandMap($tcemainObj)->process()->get();
78 if ($command ==
'version') {
79 $commandIsProcessed =
true;
80 $action = (string)$value[
'action'];
81 $comment = !empty($value[
'comment']) ? $value[
'comment'] :
'';
82 $notificationAlternativeRecipients = (isset($value[
'notificationAlternativeRecipients'])) && is_array($value[
'notificationAlternativeRecipients']) ? $value[
'notificationAlternativeRecipients'] : array();
88 if (isset($value[
'treeLevels'])) {
89 $versionizeTree = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($value[
'treeLevels'], -1, 100);
91 if ($table ==
'pages' && $versionizeTree >= 0) {
92 $this->
versionizePages($id, $value[
'label'], $versionizeTree, $tcemainObj);
98 $this->version_swap($table, $id, $value[
'swapWith'], $value[
'swapIntoWS'],
102 $notificationAlternativeRecipients
113 foreach ($elementIds as $elementId) {
118 $notificationAlternativeRecipients
138 foreach ($this->notificationEmailInfo as $notifItem) {
139 $this->notifyStageChange($notifItem[
'shared'][0], $notifItem[
'shared'][1], implode(
', ', $notifItem[
'elements']), 0, $notifItem[
'shared'][2], $tcemainObj, $notifItem[
'alternativeRecipients']);
142 $this->notificationEmailInfo = array();
144 $this->remappedIds = array();
161 if ($recordWasDeleted) {
164 $recordWasDeleted =
true;
167 if ($record[
'pid'] != -1) {
169 $record = $wsVersion;
170 $id = $record[
'uid'];
175 if ($record[
'pid'] == -1) {
176 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
178 if ($tcemainObj->BE_USER->workspace == 0 || (
int)$record[
't3ver_wsid'] == $tcemainObj->BE_USER->workspace) {
184 && !empty($tcemainObj->cmdmap[$table][$liveRec[
'uid']][
'version'][
'action'])
185 && !empty($tcemainObj->cmdmap[$table][$liveRec[
'uid']][
'version'][
'swapWith'])
186 && $tcemainObj->cmdmap[$table][$liveRec[
'uid']][
'version'][
'action'] ===
'swap'
187 && $tcemainObj->cmdmap[$table][$liveRec[
'uid']][
'version'][
'swapWith'] == $id
195 $updateFields = array(
196 't3ver_label' =>
'DELETED!',
199 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . $id, $updateFields);
202 }
elseif ($record[
't3ver_wsid'] == 0 || !$liveRecordVersionState->indicatesPlaceholder()) {
208 $tcemainObj->
deleteEl($table, $movePlaceholder[
'uid']);
216 $tcemainObj->
newlog(
'Tried to delete record from another workspace', 1);
219 $tcemainObj->
newlog(
'Versioning not enabled for record with PID = -1!', 2);
221 }
elseif ($res = $tcemainObj->BE_USER->workspaceAllowLiveRecordsInPID($record[
'pid'], $table)) {
226 $tcemainObj->
newlog(
'Stage of root point did not allow for deletion', 1);
234 $updateFields = array(
237 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$wsRec[
'uid'], $updateFields);
242 $copyMappingArray = $tcemainObj->copyMappingArray;
248 foreach ($versionizedElements as $versionizedTableName => $versionizedOriginalIds) {
249 foreach ($versionizedOriginalIds as $versionizedOriginalId => $_) {
270 public function moveRecord($table, $uid, $destPid, array $propArr, array $moveRec, $resolvedPid, &$recordWasMoved,
DataHandler $tcemainObj)
273 if ($tcemainObj->BE_USER->workspace === 0) {
279 if ($movePlaceHolder !==
false) {
280 $resolvedPid = $movePlaceHolder[
'pid'];
283 $recordWasMoved =
true;
293 if (empty($WSversion[
'uid'])) {
298 }
elseif ($tcemainObj->
isRecordCopied($table, $uid) && (int)$tcemainObj->copyMappingArray[$table][$uid] === (
int)$WSversion[
'uid']) {
303 $workspaceAccessBlocked = array();
305 $recIsNewVersion = $moveRecVersionState->indicatesPlaceholder();
306 $destRes = $tcemainObj->BE_USER->workspaceAllowLiveRecordsInPID($resolvedPid, $table);
309 if (!$recIsNewVersion) {
310 $errorCode = $tcemainObj->BE_USER->workspaceCannotEditRecord($table, $WSversion[
'uid'] ? $WSversion[
'uid'] : $uid);
312 $workspaceAccessBlocked[
'src1'] =
'Record could not be edited in workspace: ' . $errorCode .
' ';
313 }
elseif (!$canMoveRecord && $tcemainObj->BE_USER->workspaceAllowLiveRecordsInPID($moveRec[
'pid'], $table) <= 0) {
314 $workspaceAccessBlocked[
'src2'] =
'Could not remove record from table "' . $table .
'" from its page "' . $moveRec[
'pid'] .
'" ';
323 if (!($destRes > 0 || $canMoveRecord && !$destRes)) {
324 $workspaceAccessBlocked[
'dest1'] =
'Could not insert record from table "' . $table .
'" in destination PID "' . $resolvedPid .
'" ';
325 }
elseif ($destRes == 1 && $WSversion[
'uid']) {
326 $workspaceAccessBlocked[
'dest2'] =
'Could not insert other versions in destination PID ';
328 if (empty($workspaceAccessBlocked)) {
336 $recordWasMoved =
false;
339 $tcemainObj->
newlog(
'Move attempt failed due to workspace restrictions: ' . implode(
' // ', $workspaceAccessBlocked), 1);
355 if (empty($versionedRecord)) {
358 foreach ($versionedRecord as $field => $value) {
359 if (empty(
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'])) {
363 $dataHandler, $resolvedPageId,
364 $table, $uid, $field, $value,
365 $GLOBALS[
'TCA'][$table][
'columns'][$field][
'config']
385 $inlineProcessing = (
386 ($inlineFieldType ===
'list' || $inlineFieldType ===
'field')
388 && (!isset($configuration[
'behaviour'][
'disableMovingChildrenWithParent']) || !$configuration[
'behaviour'][
'disableMovingChildrenWithParent'])
391 if ($inlineProcessing) {
392 if ($table ===
'pages') {
395 $resolvedPageId = $uid;
399 $dbAnalysis->start($value, $configuration[
'foreign_table'],
'', $uid, $table, $configuration);
403 foreach ($dbAnalysis->itemArray as $item) {
405 if (empty($versionedRecord) ||
VersionState::cast($versionedRecord[
't3ver_state'])->indicatesPlaceholder()) {
408 $dataHandler->
moveRecord($item[
'table'], $item[
'id'], $resolvedPageId);
428 protected function notifyStageChange(array $stat, $stageId, $table, $id, $comment,
DataHandler $tcemainObj, array $notificationAlternativeRecipients = array())
432 $elementName = $id ? $table .
':' . $id : $table;
433 if (!is_array($workspaceRec)) {
438 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'workspaces')) {
440 $newStage = $stageService->getStageTitle((
int)$stageId);
445 switch ((
int)$stageId) {
447 $newStage =
'Ready for review';
450 $newStage =
'Ready for publishing';
453 $newStage =
'Element was rejected!';
456 $newStage =
'Rejected element was noticed and edited';
459 $newStage =
'Unknown state change!?';
462 if (empty($notificationAlternativeRecipients)) {
465 switch ((
int)$stat[
'stagechg_notification']) {
467 switch ((
int)$stageId) {
476 $allElements = explode(
',', $elementName);
478 foreach ($allElements as $elRef) {
479 list($eTable, $eUid) = explode(
':', $elRef);
480 $rows =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'log_data,tstamp,userid',
'sys_log',
'action=6 and details_nr=30
481 AND tablename=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($eTable,
'sys_log') .
'
482 AND recuid=' . (
int)$eUid,
'',
'uid DESC');
484 foreach ($rows as $dat) {
485 $data = unserialize($dat[
'log_data']);
487 if ($data[
'stage'] == 1) {
509 $emails = $notificationAlternativeRecipients;
512 if (!empty($emails)) {
514 list($elementTable, $elementUid) = explode(
':', $elementName);
515 $elementUid = (int)$elementUid;
518 if ($elementTable ==
'pages') {
519 $pageUid = $elementUid;
522 $pageUid = ($elementUid = $elementRecord[
'pid']);
531 $emailConfig = $pageTsConfig[
'tx_version.'][
'workspaces.'][
'stageNotificationEmail.'];
533 '###RECORD_TITLE###' => $recordTitle,
535 '###SITE_NAME###' =>
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'],
537 '###WORKSPACE_TITLE###' => $workspaceRec[
'title'],
538 '###WORKSPACE_UID###' => $workspaceRec[
'uid'],
539 '###ELEMENT_NAME###' => $elementName,
540 '###NEXT_STAGE###' => $newStage,
541 '###COMMENT###' => $comment,
543 '###USER_REALNAME###' => $tcemainObj->BE_USER->user[
'realName'],
544 '###USER_FULLNAME###' => $tcemainObj->BE_USER->user[
'realName'],
545 '###USER_USERNAME###' => $tcemainObj->BE_USER->user[
'username']
548 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'workspaces')) {
552 $tempEmailMessage =
$GLOBALS[
'LANG']->sL($emailConfig[
'message']);
554 $tempEmailMessage = $emailConfig[
'message'];
556 if (strpos($tempEmailMessage,
'###PREVIEW_LINK###') !==
false) {
557 $markers[
'###PREVIEW_LINK###'] = $this->workspaceService->generateWorkspacePreviewLink($elementUid);
559 unset($tempEmailMessage);
560 $markers[
'###SPLITTED_PREVIEW_LINK###'] = $this->workspaceService->generateWorkspaceSplittedPreviewLink($elementUid,
true);
563 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/version/class.tx_version_tcemain.php'][
'notifyStageChange-postModifyMarkers'])) {
564 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/version/class.tx_version_tcemain.php'][
'notifyStageChange-postModifyMarkers'] as $_classRef) {
566 $markers = $_procObj->postModifyMarkers($markers, $this);
571 $emailRecipients = array();
574 $languageObjects = array(
578 foreach ($emails as $recipientData) {
580 if (isset($emailRecipients[$recipientData[
'email']])) {
583 $emailSubject = $emailConfig[
'subject'];
584 $emailMessage = $emailConfig[
'message'];
585 $emailRecipients[$recipientData[
'email']] = $recipientData[
'email'];
589 $recipientLanguage = $recipientData[
'lang'] ? $recipientData[
'lang'] :
'default';
590 if (!isset($languageObjects[$recipientLanguage])) {
595 $languageObject->init($recipientLanguage);
596 $languageObjects[$recipientLanguage] = $languageObject;
598 $languageObject = $languageObjects[$recipientLanguage];
601 $emailSubject = $languageObject->sL($emailSubject);
604 $emailMessage = $languageObject->sL($emailMessage);
608 $emailSubject = $templateService->substituteMarkerArray($emailSubject, $markers,
'',
true,
true);
609 $emailMessage = $templateService->substituteMarkerArray($emailMessage, $markers,
'',
true,
true);
613 if (!empty($recipientData[
'realName'])) {
614 $recipient = array($recipientData[
'email'] => $recipientData[
'realName']);
616 $recipient = $recipientData[
'email'];
618 $mail->setTo($recipient)
619 ->setSubject($emailSubject)
620 ->setFrom(\TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom())
621 ->setBody($emailMessage);
624 $emailRecipients = implode(
',', $emailRecipients);
625 $tcemainObj->
newlog2(
'Notification email for stage change was sent to "' . $emailRecipients .
'"', $table, $id);
641 foreach ($users as $userIdent) {
642 if ($noTablePrefix) {
643 $id = (int)$userIdent;
647 if ($table ===
'be_users' || $noTablePrefix) {
649 if (trim($userRecord[
'email']) !==
'') {
650 $emails[$id] = $userRecord;
675 if ($errorCode = $tcemainObj->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) {
676 $tcemainObj->
newlog(
'Attempt to set stage for record failed: ' . $errorCode, 1);
679 $stat = $tcemainObj->BE_USER->checkWorkspace($record[
't3ver_wsid']);
681 if (
$GLOBALS[
'BE_USER']->workspaceCheckStageForCurrent($record[
't3ver_stage'])) {
684 't3ver_stage' => $stageId
686 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$id, $updateData);
687 $tcemainObj->
newlog2(
'Stage for record was changed to ' . $stageId .
'. Comment was: "' . substr($comment, 0, 100) .
'"', $table, $id);
689 $tcemainObj->
log($table, $id, 6, 0, 0,
'Stage raised...', 30, array(
'comment' => $comment,
'stage' => $stageId));
690 if ((
int)$stat[
'stagechg_notification'] > 0) {
692 $this->notificationEmailInfo[$stat[
'uid'] .
':' . $stageId .
':' . $comment][
'shared'] = array($stat, $stageId, $comment);
693 $this->notificationEmailInfo[$stat[
'uid'] .
':' . $stageId .
':' . $comment][
'elements'][] = $table .
':' . $id;
694 $this->notificationEmailInfo[$stat[
'uid'] .
':' . $stageId .
':' . $comment][
'alternativeRecipients'] = $notificationAlternativeRecipients;
696 $this->notifyStageChange($stat, $stageId, $table, $id, $comment, $tcemainObj, $notificationAlternativeRecipients);
700 $tcemainObj->
newlog(
'The member user tried to set a stage value "' . $stageId .
'" that was not allowed', 1);
703 $tcemainObj->
newlog(
'Attempt to set stage for record failed because you do not have edit access', 1);
724 $brExist = $tcemainObj->
doesBranchExist(
'', $uid, $tcemainObj->pMap[
'show'], 1);
726 if ((
int)$brExist === -1) {
727 $tcemainObj->
newlog(
'Could not read all subpages to versionize.', 1);
731 $verTablesArray = array();
732 $allTables = array_keys(
$GLOBALS[
'TCA']);
733 foreach ($allTables as $tableName) {
734 if ($tableName !=
'pages' && ($versionizeTree > 0 ||
$GLOBALS[
'TCA'][$tableName][
'ctrl'][
'versioning_followPages'])) {
735 $verTablesArray[] = $tableName;
741 if ($versionizeTree !== -1) {
742 $tcemainObj->
newlog(
'Versioning type "' . $versionizeTree .
'" was not allowed in workspace', 1);
746 $theNewRootID = $tcemainObj->
versionizeRecord(
'pages', $uid, $label,
false, $versionizeTree);
747 if (!$theNewRootID) {
748 $tcemainObj->
newlog(
'The root version could not be created!', 1);
753 if ($versionizeTree > 0) {
755 $CPtable = $tcemainObj->
int_pageTreeInfo(array(), $uid, (
int)$versionizeTree, $theNewRootID);
757 foreach ($CPtable as $thePageUid => $thePagePid) {
758 $newPid = $tcemainObj->copyMappingArray[
'pages'][$thePagePid];
759 if (isset($newPid)) {
760 $theNewRootID = $tcemainObj->
copyRecord_raw(
'pages', $thePageUid, $newPid);
763 $tcemainObj->
newlog(
'Something went wrong during copying branch (for versioning)', 1);
784 protected function version_swap($table, $id, $swapWith, $swapIntoWS = 0,
DataHandler $tcemainObj, $comment =
'',
$notificationEmailInfo =
false, $notificationAlternativeRecipients = array())
791 $tcemainObj->
newlog(
'Error: You cannot swap versions for a record you do not have access to edit!', 1);
799 if (!(is_array($curVersion) && is_array($swapVersion))) {
800 $tcemainObj->
newlog(
'Error: Either online or swap version could not be selected!', 2);
803 if (!$tcemainObj->BE_USER->workspacePublishAccess($swapVersion[
't3ver_wsid'])) {
804 $tcemainObj->
newlog(
'User could not publish records from workspace #' . $swapVersion[
't3ver_wsid'], 1);
807 $wsAccess = $tcemainObj->BE_USER->checkWorkspace($swapVersion[
't3ver_wsid']);
808 if (!($swapVersion[
't3ver_wsid'] <= 0 || !($wsAccess[
'publish_access'] & 1) || (
int)$swapVersion[
't3ver_stage'] === -10)) {
809 $tcemainObj->
newlog(
'Records in workspace #' . $swapVersion[
't3ver_wsid'] .
' can only be published when in "Publish" stage.', 1);
813 $tcemainObj->
newlog(
'You cannot publish a record you do not have edit and show permissions for', 1);
816 if ($swapIntoWS && !$tcemainObj->BE_USER->workspaceSwapAccess()) {
817 $tcemainObj->
newlog(
'Workspace #' . $swapVersion[
't3ver_wsid'] .
' does not support swapping.', 1);
821 if (!(((
int)$swapVersion[
'pid'] == -1 && (
int)$curVersion[
'pid'] >= 0) && (
int)$swapVersion[
't3ver_oid'] === (
int)$id)) {
822 $tcemainObj->
newlog(
'In swap version, either pid was not -1 or the t3ver_oid didn\'t match the id of the online version as it must!', 2);
826 $lockFileName = PATH_site .
'typo3temp/swap_locking/' . $table .
':' . $id .
'.ser';
827 if (@is_file($lockFileName)) {
828 $tcemainObj->
newlog(
'A swapping lock file was present. Either another swap process is already running or a previous swap process failed. Ask your administrator to handle the situation.', 2);
837 'user' => $tcemainObj->BE_USER->user[
'username'],
838 'curVersion' => $curVersion,
839 'swapVersion' => $swapVersion
843 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']) {
844 $keepFields[] =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
848 if (!isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable']) &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']) {
849 $keepFields[] =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'];
852 foreach ($keepFields as $fN) {
853 $tmp = $swapVersion[$fN];
854 $swapVersion[$fN] = $curVersion[$fN];
855 $curVersion[$fN] = $tmp;
858 $t3ver_state = array();
859 $t3ver_state[
'swapVersion'] = $swapVersion[
't3ver_state'];
860 $t3ver_state[
'curVersion'] = $curVersion[
't3ver_state'];
862 $tmp_wsid = $swapVersion[
't3ver_wsid'];
864 $swapVersion[
'pid'] = (int)$curVersion[
'pid'];
868 $swapVersion[
't3ver_oid'] = 0;
873 $swapVersion[
't3ver_wsid'] = 0;
875 if ($t3ver_state[
'swapVersion'] > 0) {
876 $swapVersion[
't3ver_wsid'] = $tcemainObj->BE_USER->workspace;
878 $swapVersion[
't3ver_wsid'] = (int)$curVersion[
't3ver_wsid'];
881 $swapVersion[
't3ver_tstamp'] =
$GLOBALS[
'EXEC_TIME'];
882 $swapVersion[
't3ver_stage'] = 0;
890 $movePlhID = $plhRec[
'uid'];
891 $movePlh[
'pid'] = $swapVersion[
'pid'];
892 $swapVersion[
'pid'] = (int)$plhRec[
'pid'];
893 $curVersion[
't3ver_state'] = (int)$swapVersion[
't3ver_state'];
895 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']) {
897 $movePlh[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']] = $swapVersion[$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']];
898 $swapVersion[$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']] = $plhRec[$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby']];
903 if (is_array(
$GLOBALS[
'TCA'][$table][
'columns'])) {
904 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $fieldConf) {
908 unset($swapVersion[
'uid']);
910 unset($curVersion[
'uid']);
912 $curVersion[
'pid'] = -1;
913 $curVersion[
't3ver_oid'] = (int)$id;
914 $curVersion[
't3ver_wsid'] = $swapIntoWS ? (int)$tmp_wsid : 0;
915 $curVersion[
't3ver_tstamp'] =
$GLOBALS[
'EXEC_TIME'];
916 $curVersion[
't3ver_count'] = $curVersion[
't3ver_count'] + 1;
918 $curVersion[
't3ver_stage'] = 0;
923 $tcemainObj->version_remapMMForVersionSwap($table, $id, $swapWith);
928 $sqlErrors = array();
929 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$id, $swapVersion);
930 if (
$GLOBALS[
'TYPO3_DB']->sql_error()) {
931 $sqlErrors[] =
$GLOBALS[
'TYPO3_DB']->sql_error();
933 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$swapWith, $curVersion);
934 if (
$GLOBALS[
'TYPO3_DB']->sql_error()) {
935 $sqlErrors[] =
$GLOBALS[
'TYPO3_DB']->sql_error();
937 unlink($lockFileName);
940 if (!empty($sqlErrors)) {
941 $tcemainObj->
newlog(
'During Swapping: SQL errors happened: ' . implode(
'; ', $sqlErrors), 2);
944 $this->remappedIds[$table][$id] = $swapWith;
945 $this->remappedIds[$table][$swapWith] = $id;
951 $tcemainObj->
deleteEl($table, $movePlhID,
true,
true);
954 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$movePlhID, $movePlh);
960 if (!$swapIntoWS && ((
int)$t3ver_state[
'swapVersion'] === 1 || (
int)$t3ver_state[
'swapVersion'] === 2)) {
962 $tcemainObj->
deleteEl($table, $id,
true);
964 $tcemainObj->
newlog2(($swapIntoWS ?
'Swapping' :
'Publishing') .
' successful for table "' . $table .
'" uid ' . $id .
'=>' . $swapWith, $table, $id, $swapVersion[
'pid']);
969 if ($propArr[
'_ORIG_pid'] == -1) {
970 $label =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_tcemain.xlf:version_swap.offline_record_updated');
972 $label =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_tcemain.xlf:version_swap.online_record_updated');
974 $theLogId = $tcemainObj->
log($table, $id, 2, $propArr[
'pid'], 0, $label, 10, array($propArr[
'header'], $table .
':' . $id), $propArr[
'event_pid']);
975 $tcemainObj->
setHistory($table, $id, $theLogId);
980 if ($propArr[
'_ORIG_pid'] == -1) {
981 $label =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_tcemain.xlf:version_swap.offline_record_updated');
983 $label =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_tcemain.xlf:version_swap.online_record_updated');
985 $theLogId = $tcemainObj->
log($table, $swapWith, 2, $propArr[
'pid'], 0, $label, 10, array($propArr[
'header'], $table .
':' . $swapWith), $propArr[
'event_pid']);
986 $tcemainObj->
setHistory($table, $swapWith, $theLogId);
990 $notificationEmailInfoKey = $wsAccess[
'uid'] .
':' . $stageId .
':' . $comment;
991 $this->notificationEmailInfo[$notificationEmailInfoKey][
'shared'] = array($wsAccess, $stageId, $comment);
992 $this->notificationEmailInfo[$notificationEmailInfoKey][
'elements'][] = $table .
':' . $id;
993 $this->notificationEmailInfo[$notificationEmailInfoKey][
'alternativeRecipients'] = $notificationAlternativeRecipients;
995 $this->notifyStageChange($wsAccess, $stageId, $table, $id, $comment, $tcemainObj, $notificationAlternativeRecipients);
998 $tcemainObj->
newlog2(
'Stage for record was changed to ' . $stageId .
'. Comment was: "' . substr($comment, 0, 100) .
'"', $table, $id);
999 $tcemainObj->
log($table, $id, 6, 0, 0,
'Published', 30, array(
'comment' => $comment,
'stage' => $stageId));
1004 if (!$swapIntoWS && $t3ver_state[
'curVersion'] > 0) {
1006 $tcemainObj->
deleteEl($table, $swapWith,
true,
true);
1012 $refIndexObj->setWorkspaceId(0);
1013 $refIndexObj->updateRefIndexTable($table, $id);
1014 $refIndexObj->updateRefIndexTable($table, $swapWith);
1028 foreach ($dbAnalysis->itemArray as &$item) {
1029 if (isset($this->remappedIds[$item[
'table']][$item[
'id']])) {
1030 $item[
'id'] = $this->remappedIds[$item[
'table']][$item[
'id']];
1033 $dbAnalysis->writeForeignField($configuration, $parentId);
1051 if ($inlineType !==
'field') {
1054 $foreignTable = $configuration[
'foreign_table'];
1057 $liveRelations->setWorkspaceId(0);
1058 $liveRelations->start(
'', $foreignTable,
'', $liveData[
'uid'], $tableName, $configuration);
1061 $versionRelations->setUseLiveReferenceIds(
false);
1062 $versionRelations->start(
'', $foreignTable,
'', $versionData[
'uid'], $tableName, $configuration);
1064 if (count($liveRelations->itemArray)) {
1066 $tableName, $liveData[
'uid'],
1067 array($this,
'updateInlineForeignFieldSorting'),
1068 array($tableName, $liveData[
'uid'], $foreignTable, $liveRelations->tableArray[$foreignTable], $configuration, $dataHandler->BE_USER->workspace)
1071 if (count($versionRelations->itemArray)) {
1073 $tableName, $liveData[
'uid'],
1074 array($this,
'updateInlineForeignFieldSorting'),
1075 array($tableName, $liveData[
'uid'], $foreignTable, $versionRelations->tableArray[$foreignTable], $configuration, 0)
1102 foreach ($foreignIds as $foreignId) {
1103 if (!empty($this->remappedIds[$foreignTableName][$foreignId])) {
1104 $remappedIds[] = $this->remappedIds[$foreignTableName][$foreignId];
1111 $relationHandler->setWorkspaceId($targetWorkspaceId);
1112 $relationHandler->setUseLiveReferenceIds(
false);
1113 $relationHandler->start(implode(
',',
$remappedIds), $foreignTableName);
1114 $relationHandler->processDeletePlaceholder();
1115 $relationHandler->writeForeignField($configuration, $parentId);
1129 if ($errorCode = $tcemainObj->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) {
1130 $tcemainObj->
newlog(
'Attempt to reset workspace for record failed: ' . $errorCode, 1);
1134 $tcemainObj->
newlog(
'Attempt to reset workspace for record failed because you do not have edit access', 1);
1142 $updateData = array(
1144 't3ver_tstamp' =>
$GLOBALS[
'EXEC_TIME']
1146 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$id, $updateData);
1152 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$liveRec[
'uid'], $updateData);
1154 $tcemainObj->
deleteEl($table, $liveRec[
'uid'],
true);
1166 $tcemainObj->
deleteEl($table, $id,
true,
true);
1171 $tcemainObj->
deleteEl($table, $plhRec[
'uid'],
true,
true);
1195 foreach ($copyTablesArray as $table) {
1197 if ($table && is_array(
$GLOBALS[
'TCA'][$table]) && $table !==
'pages') {
1198 $mres =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid', $table,
'pid=' . (
int)$oldPageId . $tcemainObj->
deleteClause($table));
1199 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($mres)) {
1201 if (!$tcemainObj->copyMappingArray[$table][$row[
'uid']]) {
1206 $GLOBALS[
'TYPO3_DB']->sql_free_result($mres);
1222 $workspaceId = (int)$rec[
't3ver_wsid'];
1223 $elementData = array();
1224 if ($workspaceId === 0) {
1225 return $elementData;
1228 if ($table !=
'pages') {
1230 $pageId = $rec[
'pid'];
1233 $offlinePageId = $rec[
'_ORIG_uid'];
1236 $offlinePageId = $offlineId;
1239 foreach (
$GLOBALS[
'TCA'] as $table => $cfg) {
1240 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] && $table !==
'pages') {
1242 while (
false != ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_row($res))) {
1243 $elementData[$table][] = array($row[1], $row[0]);
1245 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
1248 if ($offlinePageId && $offlinePageId != $pageId) {
1249 $elementData[
'pages'][] = array($pageId, $offlinePageId);
1251 return $elementData;
1264 if ($workspaceId == 0) {
1268 foreach (
$GLOBALS[
'TCA'] as $table => $cfg) {
1269 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] && $table !==
'pages') {
1271 while (
false !== ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_row($res))) {
1272 $elementList[$table][] = $row[0];
1274 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
1275 if (is_array($elementList[$table])) {
1278 $elementList[$table] = array_unique($elementList[$table]);
1296 if ($workspaceId == 0) {
1300 while (
false !== ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_row($res))) {
1301 $pageIdList[] = $row[0];
1307 if ($rec[
'_ORIG_uid']) {
1308 $elementList[
'pages'][$row[0]] = $rec[
'_ORIG_uid'];
1311 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
1314 $pageIdList = array_unique($pageIdList);
1325 foreach ($idList as $key => $id) {
1327 if ($rec[
't3ver_oid'] > 0) {
1328 $idList[$key] = $rec[
't3ver_oid'];
1351 $originalRecordDestinationPid = $destPid;
1354 if ($movePlaceHolder !==
false) {
1355 $destPid = -$movePlaceHolder[
'uid'];
1364 $newVersion_placeholderFieldArray = array();
1367 if (isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'shadowColumnsForMovePlaceholders'])) {
1368 $shadowColumnsForMovePlaceholder =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'shadowColumnsForMovePlaceholders'];
1370 }
elseif (isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'shadowColumnsForNewPlaceholders'])) {
1371 $shadowColumnsForMovePlaceholder =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'shadowColumnsForNewPlaceholders'];
1375 if (!empty($shadowColumnsForMovePlaceholder)) {
1378 foreach ($shadowColumns as $shadowColumn) {
1379 if (isset($versionedRecord[$shadowColumn])) {
1380 $newVersion_placeholderFieldArray[$shadowColumn] = $versionedRecord[$shadowColumn];
1385 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'crdate']) {
1386 $newVersion_placeholderFieldArray[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'crdate']] = $GLOBALS[
'EXEC_TIME'];
1388 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'cruser_id']) {
1389 $newVersion_placeholderFieldArray[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'cruser_id']] = $tcemainObj->userid;
1391 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']) {
1392 $newVersion_placeholderFieldArray[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp']] = $GLOBALS[
'EXEC_TIME'];
1394 if ($table ==
'pages') {
1396 $perms_clause = $tcemainObj->BE_USER->getPagePermsClause(1);
1398 $newVersion_placeholderFieldArray[
'perms_userid'] = $access[
'perms_userid'];
1399 $newVersion_placeholderFieldArray[
'perms_groupid'] = $access[
'perms_groupid'];
1400 $newVersion_placeholderFieldArray[
'perms_user'] = $access[
'perms_user'];
1401 $newVersion_placeholderFieldArray[
'perms_group'] = $access[
'perms_group'];
1402 $newVersion_placeholderFieldArray[
'perms_everybody'] = $access[
'perms_everybody'];
1404 $newVersion_placeholderFieldArray[
't3ver_label'] =
'MovePlaceholder #' . $uid;
1405 $newVersion_placeholderFieldArray[
't3ver_move_id'] = $uid;
1409 $newVersion_placeholderFieldArray[
't3ver_wsid'] = $tcemainObj->BE_USER->workspace;
1412 if (isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']) && isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'])) {
1414 $newVersion_placeholderFieldArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']] = $l10nParentRec[$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']];
1415 $newVersion_placeholderFieldArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']] = $l10nParentRec[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']];
1416 if (isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField'])) {
1417 $newVersion_placeholderFieldArray[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField']] = $l10nParentRec[$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigDiffSourceField']];
1419 unset($l10nParentRec);
1422 $newVersion_placeholderFieldArray[
'pid'] = 0;
1423 $id =
'NEW_MOVE_PLH';
1425 $tcemainObj->
insertDB($table, $id, $newVersion_placeholderFieldArray,
false);
1427 $tcemainObj->
moveRecord_raw($table, $tcemainObj->substNEWwithIDs[$id], $destPid);
1430 $updateFields = array(
1433 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$wsUid, $updateFields);
1448 foreach (
$GLOBALS[
'TCA'][$parentTable][
'columns'] as $parentField => $parentFieldDefinition) {
1449 if (isset($parentFieldDefinition[
'config'][
'type'])) {
1450 $parentFieldConfiguration = $parentFieldDefinition[
'config'];
1451 if ($parentFieldConfiguration[
'type'] ==
'inline' && isset($parentFieldConfiguration[
'foreign_table'])) {
1452 if (!in_array($parentFieldConfiguration[
'foreign_table'], $possibleInlineChildren)) {
1453 $possibleInlineChildren = $this->
getPossibleInlineChildTablesOfParentTable($parentFieldConfiguration[
'foreign_table'], array_merge($possibleInlineChildren, $parentFieldConfiguration[
'foreign_table']));
1458 return $possibleInlineChildren;
1474 $tceMain->BE_USER->workspace
1487 if (empty(
$GLOBALS[
'TCA'][$table][
'columns'])) {
1490 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $configArr) {
1491 if ($configArr[
'config'][
'type'] ===
'input') {
1493 if (in_array(
'uniqueInPid', $evalCodesArray) || in_array(
'unique', $evalCodesArray)) {
1494 $listArr[] = $field;