Skip to content

Commit

Permalink
[BUGFIX] Fix paste handling in CmdMap part
Browse files Browse the repository at this point in the history
We now support negative uids on the target while handling paste
commands.

Resolves: IchHabRecht#76
  • Loading branch information
Alexander Opitz committed Dec 10, 2020
1 parent 97a5662 commit c8924b2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Classes/Hooks/CmdmapDataHandlerHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ public function processCmdmap_beforeStart(DataHandler $dataHandler)
}
}

$checkId = $id;

if (is_array($value)
&& !empty($value['action'])
&& 'paste' === $value['action']
&& isset($value['update']['colPos'])
) {
$command = 'paste';
$pageId = (int)$value['target'];

if ($pageId < 0) {
$previousRecord = BackendUtility::getRecord('tt_content', abs($pageId), 'pid');
$pageId = (int)$previousRecord['pid'];
$checkId = 'NEW_';
}
$colPos = (int)$value['update']['colPos'];
} elseif ($value > 0) {
$pageId = (int)$value;
Expand All @@ -78,11 +86,10 @@ public function processCmdmap_beforeStart(DataHandler $dataHandler)
$currentRecord['colPos'] = $colPos;

$backendLayoutConfiguration = BackendLayoutConfiguration::createFromPageId($pageId);
$columnConfiguration = $backendLayoutConfiguration->getConfigurationByColPos($colPos, $id);
$columnConfiguration = $backendLayoutConfiguration->getConfigurationByColPos($colPos, $checkId);

// Failing one of the conditions prevents a new record from being added to the database for the
// current command

if (!$this->isRecordAllowedByRestriction($columnConfiguration, $currentRecord)) {
unset($dataHandler->cmdmap['tt_content'][$id]);
$dataHandler->log(
Expand Down

0 comments on commit c8924b2

Please sign in to comment.