diff --git a/Classes/Updates/PluginPermissionUpdater.php b/Classes/Updates/PluginPermissionUpdater.php new file mode 100644 index 0000000..76d91dd --- /dev/null +++ b/Classes/Updates/PluginPermissionUpdater.php @@ -0,0 +1,107 @@ +checkIfWizardIsRequired(); + } + + public function executeUpdate(): bool + { + return $this->performMigration(); + } + + public function checkIfWizardIsRequired(): bool + { + return count($this->getMigrationRecords()) > 0; + } + + public function performMigration(): bool + { + $records = $this->getMigrationRecords(); + + foreach ($records as $record) { + $this->updateExplicitAllowdeny( + $record['uid'], + str_replace('list_type:fechangepwd_pi1', 'CType:fechangepwd_pi1', $record['explicit_allowdeny']) + ); + } + + return true; + } + + /** + * Updates the explicit_allowdeny for the given be_groups record uid with the given value + */ + protected function updateExplicitAllowdeny(int $uid, string $explicitAllowdeny): void + { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_groups'); + $queryBuilder->update('be_groups') + ->set('explicit_allowdeny', $explicitAllowdeny) + ->where( + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter($uid, Connection::PARAM_INT) + ) + ) + ->executeStatement(); + } + + /** + * Returns all record for the migration + */ + protected function getMigrationRecords(): array + { + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); + $queryBuilder = $connectionPool->getQueryBuilderForTable('be_groups'); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); + + return $queryBuilder + ->select('uid', 'explicit_allowdeny') + ->from('be_groups') + ->where( + $queryBuilder->expr()->like( + 'explicit_allowdeny', + $queryBuilder->createNamedParameter('%list_type:fechangepwd_pi1%') + ) + ) + ->executeQuery() + ->fetchAllAssociative(); + } +} diff --git a/Classes/Updates/PluginToContentTypeUpdater.php b/Classes/Updates/PluginToContentTypeUpdater.php new file mode 100644 index 0000000..babbc6c --- /dev/null +++ b/Classes/Updates/PluginToContentTypeUpdater.php @@ -0,0 +1,109 @@ +checkIfWizardIsRequired(); + } + + public function executeUpdate(): bool + { + return $this->performMigration(); + } + + public function checkIfWizardIsRequired(): bool + { + return count($this->getMigrationRecords()) > 0; + } + + public function performMigration(): bool + { + $records = $this->getMigrationRecords(); + + foreach ($records as $record) { + $this->updateContentElement($record['uid'], $record['list_type']); + } + + return true; + } + + /** + * Updates the CType and sets `list_type` to an empty string for the given tt_content record + */ + protected function updateContentElement(int $uid, string $newCtype): void + { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); + $queryBuilder->update('tt_content') + ->set('CType', $newCtype) + ->set('list_type', '') + ->where( + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter($uid, Connection::PARAM_INT) + ) + ) + ->executeStatement(); + } + + /** + * Returns all record for the migration + */ + protected function getMigrationRecords(): array + { + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); + $queryBuilder = $connectionPool->getQueryBuilderForTable('tt_content'); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); + + return $queryBuilder + ->select('uid', 'pid', 'CType', 'list_type', 'pi_flexform') + ->from('tt_content') + ->where( + $queryBuilder->expr()->eq( + 'CType', + $queryBuilder->createNamedParameter('list') + ), + $queryBuilder->expr()->eq( + 'list_type', + $queryBuilder->createNamedParameter('fechangepwd_pi1') + ) + ) + ->executeQuery() + ->fetchAllAssociative(); + } +} diff --git a/ext_emconf.php b/ext_emconf.php index 23206ed..d233017 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,7 +8,7 @@ 'author' => 'Torben Hansen', 'author_email' => 'torben@derhansen.com', 'state' => 'stable', - 'version' => '5.0.0', + 'version' => '5.1.0', 'constraints' => [ 'depends' => [ 'typo3' => '13.2.0-13.4.99' diff --git a/ext_localconf.php b/ext_localconf.php index 2f3ce21..3c6976a 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -15,7 +15,8 @@ // non-cacheable actions [ PasswordController::class => 'edit,update,sendChangePasswordCode', - ] + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); // Define template override for Fluid email