Commit 64b0b1eb authored by Thomas Löffler's avatar Thomas Löffler

Fixes review form

parent e015be42
Pipeline #1970 passed with stages
in 1 minute and 26 seconds
......@@ -35,7 +35,8 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = [
[
'GETvar' => 'tx_terfe2_pi1[controller]',
'valueMap' => [
'Extension' => ''
'Extension' => '',
'Review' => 'security-review'
],
'noMatch' => 'bypass'
],
......@@ -43,7 +44,8 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = [
'GETvar' => 'tx_terfe2_pi1[action]',
'valueMap' => [
'detail' => '',
'download' => 'download'
'download' => 'download',
'update' => 'update'
],
'noMatch' => 'bypass'
],
......
......@@ -31,41 +31,22 @@ namespace T3o\TerFe2\Controller;
class ReviewController extends \T3o\TerFe2\Controller\AbstractTerBasedController
{
/**
* @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
*/
protected $persistenceManager;
/**
* Initializes the controller
*
* @return void
*/
protected function initializeController()
{
$this->persistenceManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class);
}
/**
* Set unsecure flag of all given versions
*
* @param \T3o\TerFe2\Domain\Model\Extension $extension The extension to update
* @param mixed $insecureVersions Version UIDs or empty string of no version was selected
* @param array $insecureVersions Version UIDs or empty string of no version was selected
* @return void
*/
public function updateAction(\T3o\TerFe2\Domain\Model\Extension $extension, $insecureVersions)
public function updateAction(\T3o\TerFe2\Domain\Model\Extension $extension, array $insecureVersions)
{
$insecureVersions = (is_array($insecureVersions) ? $insecureVersions : array());
$extensionKey = $extension->getExtKey();
$actionParameters = ['extension' => $extension];
$versions = $extension->getVersions();
$persist = FALSE;
$versionChanged = false;
$versionRepository = $this->objectManager->get(\T3o\TerFe2\Domain\Repository\VersionRepository::class);
foreach ($versions as $version) {
$versionString = $version->getVersionString();
$actionParameters = array('extension' => $extension);
/** @var \T3o\TerFe2\Domain\Model\Version $version */
$reviewState = 0;
if (in_array($version->getUid(), $insecureVersions)) {
$reviewState = -1;
......@@ -76,17 +57,17 @@ class ReviewController extends \T3o\TerFe2\Controller\AbstractTerBasedController
}
$error = '';
if ($this->terConnection->setReviewState($extensionKey, $versionString, $reviewState, $error)) {
if ($this->terConnection->setReviewState($extension->getExtKey(), $version->getVersionString(), $reviewState, $error)) {
$version->setReviewState($reviewState);
$persist = TRUE;
$versionChanged = true;
$versionRepository->update($version);
} else {
$message = $this->translate('msg.reviewstate_not_enabled', array($versionString, $error));
$message = $this->translate('msg.reviewstate_not_enabled', [$version->getVersionString(), $error]);
$this->redirectWithMessage($message, 'show', '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, 'Extension', NULL, $actionParameters);
}
}
if ($persist) {
$this->persistenceManager->persistAll();
if ($versionChanged) {
$this->redirectWithMessage($this->translate('msg.reviewstate_enabled'), 'show', '', \TYPO3\CMS\Core\Messaging\FlashMessage::OK, 'Extension', NULL, $actionParameters);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment