diff --git a/typo3/sysext/recycler/Classes/Controller/DeletedRecordsController.php b/typo3/sysext/recycler/Classes/Controller/DeletedRecordsController.php index d6554d39b738e00ab090da3c05e46f85b99e76ae..aacbcf3e9ecdef799afc87ff8dd5c0c377b09492 100644 --- a/typo3/sysext/recycler/Classes/Controller/DeletedRecordsController.php +++ b/typo3/sysext/recycler/Classes/Controller/DeletedRecordsController.php @@ -50,12 +50,10 @@ class DeletedRecordsController * Transforms the rows for the deleted records * * @param array $deletedRowsArray Array with table as key and array with all deleted rows - * @param int $totalDeleted Number of deleted records in total * @return array JSON array */ - public function transform($deletedRowsArray, $totalDeleted) + public function transform($deletedRowsArray) { - $total = 0; $jsonArray = [ 'rows' => [] ]; @@ -65,11 +63,9 @@ class DeletedRecordsController $iconFactory = GeneralUtility::makeInstance(IconFactory::class); foreach ($deletedRowsArray as $table => $rows) { - $total += count($deletedRowsArray[$table]); foreach ($rows as $row) { $pageTitle = $this->getPageTitle((int)$row['pid']); $backendUserName = $this->getBackendUser((int)$row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']]); - $userIdWhoDeleted = $this->getUserWhoDeleted($table, (int)$row['uid']); $jsonArray['rows'][] = [ @@ -92,7 +88,6 @@ class DeletedRecordsController } } } - $jsonArray['total'] = $totalDeleted; return $jsonArray; } diff --git a/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php b/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php index 57eb2de11c2122b937e6a885c442292de78c040f..690e873337231910e666995b71e7d35afee7f17d 100644 --- a/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php +++ b/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php @@ -97,7 +97,7 @@ class RecyclerAjaxController /* @var $controller DeletedRecordsController */ $controller = GeneralUtility::makeInstance(DeletedRecordsController::class); - $recordsArray = $controller->transform($deletedRowsArray, $totalDeleted); + $recordsArray = $controller->transform($deletedRowsArray); $allowDelete = $this->getBackendUser()->isAdmin() ?: (bool)($this->getBackendUser()->getTSConfig()['mod.']['recycler.']['allowDelete'] ?? false); @@ -105,10 +105,9 @@ class RecyclerAjaxController $view->setTemplatePathAndFilename($extPath . 'Resources/Private/Templates/Ajax/RecordsTable.html'); $view->assign('records', $recordsArray['rows']); $view->assign('allowDelete', $allowDelete); - $view->assign('total', $recordsArray['total']); $content = [ 'rows' => $view->render(), - 'totalItems' => $recordsArray['total'] + 'totalItems' => $totalDeleted ]; break; case 'undoRecords': diff --git a/typo3/sysext/recycler/Classes/Domain/Model/DeletedRecords.php b/typo3/sysext/recycler/Classes/Domain/Model/DeletedRecords.php index d543913c998a6659bf84852e937b68d121abea76..dac6e7c21a46335834af38de58d0ab29e41996ec 100644 --- a/typo3/sysext/recycler/Classes/Domain/Model/DeletedRecords.php +++ b/typo3/sysext/recycler/Classes/Domain/Model/DeletedRecords.php @@ -243,8 +243,6 @@ class DeletedRecords if ($recordsToCheck !== false) { $this->checkRecordAccess($table, $recordsToCheck); - $pidList = $this->getTreeList($id, $depth); - $this->sortDeletedRowsByPidList($pidList); } } $this->label[$table] = $tcaCtrl['label']; @@ -341,27 +339,6 @@ class DeletedRecords } } - /** - * @param array $pidList - */ - protected function sortDeletedRowsByPidList(array $pidList) - { - foreach ($this->deletedRows as $table => $rows) { - // Reset array of deleted rows for current table - $this->deletedRows[$table] = []; - - // Get rows for current pid - foreach ($pidList as $pid) { - $rowsForCurrentPid = array_filter($rows, function ($row) use ($pid) { - return (int)$row['pid'] === (int)$pid; - }); - - // Append sorted records to the array again - $this->deletedRows[$table] = array_merge($this->deletedRows[$table], $rowsForCurrentPid); - } - } - } - /************************************************************ * DELETE FUNCTIONS ************************************************************/ diff --git a/typo3/sysext/recycler/Classes/Domain/Model/Tables.php b/typo3/sysext/recycler/Classes/Domain/Model/Tables.php index e4a59f40d386b92630852b41aa01d2cb61af7ba2..3c1cfffde65e57c8ed8150648690f34a71cac93a 100644 --- a/typo3/sysext/recycler/Classes/Domain/Model/Tables.php +++ b/typo3/sysext/recycler/Classes/Domain/Model/Tables.php @@ -36,6 +36,7 @@ class Tables $lang = $this->getLanguageService(); $tables = []; $connection = GeneralUtility::makeInstance(ConnectionPool::class); + foreach (RecyclerUtility::getModifyableTables() as $tableName) { $deletedField = RecyclerUtility::getDeletedField($tableName); if ($deletedField) { diff --git a/typo3/sysext/recycler/Classes/Utility/RecyclerUtility.php b/typo3/sysext/recycler/Classes/Utility/RecyclerUtility.php index c5753056b687f57fe33f87bcc2c91b873872726f..1fe5231767f810a2581d5766d0bba24c8e2d5c71 100644 --- a/typo3/sysext/recycler/Classes/Utility/RecyclerUtility.php +++ b/typo3/sysext/recycler/Classes/Utility/RecyclerUtility.php @@ -34,13 +34,21 @@ class RecyclerUtility * as well as the table access rights of the user. * * @param string $table The table to check access for - * @param string $row Record array + * @param array $row Record array * @return bool Returns TRUE is the user has access, or FALSE if not */ public static function checkAccess($table, $row) { $backendUser = static::getBackendUser(); + if ($backendUser->isAdmin()) { + return true; + } + + if (!$backendUser->check('tables_modify', $table)) { + return false; + } + // Checking if the user has permissions? (Only working as a precaution, because the final permission check is always down in TCE. But it's good to notify the user on beforehand...) // First, resetting flags. $hasAccess = false; @@ -60,9 +68,6 @@ class RecyclerUtility $hasAccess = $backendUser->recordEditAccessInternals($table, $calcPRec); } } - if (!$backendUser->check('tables_modify', $table)) { - $hasAccess = false; - } return $hasAccess; } diff --git a/typo3/sysext/recycler/Resources/Private/Partials/RecordsTable/DeletedRecord.html b/typo3/sysext/recycler/Resources/Private/Partials/RecordsTable/DeletedRecord.html index 2f84bfafa79fa8dd3087eb27fec723112cf56e5d..7dc56e05b14716338a21cfd68ea5aadbf83c3e37 100644 --- a/typo3/sysext/recycler/Resources/Private/Partials/RecordsTable/DeletedRecord.html +++ b/typo3/sysext/recycler/Resources/Private/Partials/RecordsTable/DeletedRecord.html @@ -30,7 +30,7 @@ </td> </tr> <tr class="collapse" id="{record.table}_{record.uid}"> - <td colspan="6"> + <td colspan="7"> <table class="table"> <thead> <tr> diff --git a/typo3/sysext/recycler/Tests/Functional/Recycle/Pages/DataSet/Assertion/deletedPage-3_4_5_7.xml b/typo3/sysext/recycler/Tests/Functional/Recycle/Pages/DataSet/Assertion/deletedPage-3_4_5_7.xml index 4de2198a5761670d78735cd34b89fd0b64e0ddbd..4b20657bbbfa6736c6fa52ce82123f8dfe807b06 100644 --- a/typo3/sysext/recycler/Tests/Functional/Recycle/Pages/DataSet/Assertion/deletedPage-3_4_5_7.xml +++ b/typo3/sysext/recycler/Tests/Functional/Recycle/Pages/DataSet/Assertion/deletedPage-3_4_5_7.xml @@ -16,14 +16,6 @@ <deleted>1</deleted> <perms_everybody>15</perms_everybody> </pages> - <pages> - <uid>7</uid> - <pid>1</pid> - <title>Dummy 1-7 (deleted)</title> - <doktype>1</doktype> - <deleted>1</deleted> - <perms_everybody>0</perms_everybody> - </pages> <pages> <uid>5</uid> <pid>4</pid> @@ -32,5 +24,14 @@ <deleted>1</deleted> <perms_everybody>15</perms_everybody> </pages> + + <pages> + <uid>7</uid> + <pid>1</pid> + <title>Dummy 1-7 (deleted)</title> + <doktype>1</doktype> + <deleted>1</deleted> + <perms_everybody>0</perms_everybody> + </pages> </dataset> diff --git a/typo3/sysext/recycler/Tests/Unit/Domain/Model/DeletedRecordsTest.php b/typo3/sysext/recycler/Tests/Unit/Domain/Model/DeletedRecordsTest.php deleted file mode 100644 index d5ce5fd5ce22f1b5316b752bb8946d788499ebc2..0000000000000000000000000000000000000000 --- a/typo3/sysext/recycler/Tests/Unit/Domain/Model/DeletedRecordsTest.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -declare(strict_types = 1); -namespace TYPO3\CMS\Recycler\Tests\Unit\Domain\Model; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use TYPO3\CMS\Recycler\Domain\Model\DeletedRecords; -use TYPO3\TestingFramework\Core\Unit\UnitTestCase; - -/** - * Test case - */ -class DeletedRecordsTest extends UnitTestCase -{ - /** - * @test - */ - public function recordsOfMultipleTablesAreSortedByPid() - { - $deletedRowsData = [ - 'pages' => [ - ['uid' => 1, 'pid' => 1], - ['uid' => 2, 'pid' => 2], - ['uid' => 3, 'pid' => 4], - ['uid' => 4, 'pid' => 7], - ], - 'sys_template' => [ - ['uid' => 1, 'pid' => 9], - ['uid' => 2, 'pid' => 10], - ['uid' => 3, 'pid' => 1], - ], - 'tt_content' => [ - ['uid' => 1, 'pid' => 7], - ['uid' => 2, 'pid' => 1], - ] - ]; - - $expectedRows = [ - 'pages' => [ - ['uid' => 1, 'pid' => 1], - ['uid' => 2, 'pid' => 2], - ['uid' => 4, 'pid' => 7], - ['uid' => 3, 'pid' => 4], - ], - 'sys_template' => [ - ['uid' => 3, 'pid' => 1], - ['uid' => 2, 'pid' => 10], - ['uid' => 1, 'pid' => 9], - ], - 'tt_content' => [ - ['uid' => 2, 'pid' => 1], - ['uid' => 1, 'pid' => 7], - ] - ]; - - /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|DeletedRecords $subject */ - $subject = $this->getAccessibleMock(DeletedRecords::class, ['dummy']); - $subject->_set('deletedRows', $deletedRowsData); - $subject->_call('sortDeletedRowsByPidList', [1, 2, 7, 4, 10, 9]); - static::assertEquals($expectedRows, $subject->getDeletedRows()); - } -}