Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Classes/Hooks/AbstractDataHandlerHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessShowitem;
use TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsRemoveUnused;
use TYPO3\CMS\Backend\Form\FormDataProvider\UserTsConfig;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

abstract class AbstractDataHandlerHook
Expand Down Expand Up @@ -80,6 +81,11 @@ protected function isRecordAllowedByRestriction(array $columnConfiguration, arra
$allowedConfiguration = array_intersect_key($columnConfiguration['allowed.'] ?? [], $result['processedTca']['columns']);
foreach ($allowedConfiguration as $field => $value) {
$allowedValues = GeneralUtility::trimExplode(',', $value);

if (($record['CType'] == 'shortcut') && (!$this->checkShortcut($record, $field, $allowedValues))) {
return false;
}

if (!$this->isAllowedValue($record, $field, $allowedValues)) {
return false;
}
Expand All @@ -88,6 +94,11 @@ protected function isRecordAllowedByRestriction(array $columnConfiguration, arra
$disallowedConfiguration = array_intersect_key($columnConfiguration['disallowed.'] ?? [], $result['processedTca']['columns']);
foreach ($disallowedConfiguration as $field => $value) {
$disallowedValues = GeneralUtility::trimExplode(',', $value);

if (($record['CType'] == 'shortcut') && (!$this->checkShortcut($record, $field, $disallowedValues, false))) {
return false;
}

if (!$this->isAllowedValue($record, $field, $disallowedValues, false)) {
return false;
}
Expand Down Expand Up @@ -123,4 +134,33 @@ protected function isRecordAllowedByItemsCount(array $columnConfiguration, array

return (int)$columnConfiguration['maxitems'] >= $this->contentRepository->addRecordToColPos($record);
}

/**
* @param array $shortcut
* @param string $field
* @param array $values
* @param bool $allowed
* @return bool
*/
protected function checkShortcut(array $shortcut, $field, array $values, $allowed = true)
{
$references = GeneralUtility::trimExplode(',', $shortcut['records']);
foreach ($references as $reference) {
$referenceParts = GeneralUtility::revExplode('_', $reference, 2);
$uid = $referenceParts[count($referenceParts) - 1];
$table = 'tt_content';
if (count($referenceParts) == 2) {
$table = $referenceParts[0];
}
$referencedRecord = BackendUtility::getRecord($table, $uid);
if ($referencedRecord['CType'] == 'shortcut') {
return $this->checkShortcut($referencedRecord, $field, $values, $allowed);
}
if (!$this->isAllowedValue($referencedRecord, $field, $values, $allowed)) {
return false;
}
}

return true;
}
}