diff --git a/lib/Alchemy/Phrasea/Controller/Prod/DoDownloadController.php b/lib/Alchemy/Phrasea/Controller/Prod/DoDownloadController.php index 659b522a31..aded69e19b 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/DoDownloadController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/DoDownloadController.php @@ -9,14 +9,12 @@ */ namespace Alchemy\Phrasea\Controller\Prod; -use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application\Helper\DelivererAware; use Alchemy\Phrasea\Application\Helper\DispatcherAware; use Alchemy\Phrasea\Application\Helper\FilesystemAware; use Alchemy\Phrasea\Controller\Controller; use Alchemy\Phrasea\Http\DeliverDataInterface; use Alchemy\Phrasea\Model\Entities\Token; -use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Session; @@ -107,17 +105,17 @@ class DoDownloadController extends Controller $exportName = $list['export_name']; - if ($list['count'] === 1 && !$list['cgu']) { - $file = end($list['files']); - $subdef = end($file['subdefs']); - $exportName = sprintf('%s%s.%s', $file['export_name'], $subdef['ajout'], $subdef['exportExt']); - $exportFile = \p4string::addEndSlash($subdef['path']) . $subdef['file']; - $mime = $subdef['mime']; - $list['complete'] = true; - } else { +// if ($list['count'] === 1 && !$list['cgu']) { +// $file = end($list['files']); +// $subdef = end($file['subdefs']); +// $exportName = sprintf('%s%s.%s', $file['export_name'], $subdef['ajout'], $subdef['exportExt']); +// $exportFile = \p4string::addEndSlash($subdef['path']) . $subdef['file']; +// $mime = $subdef['mime']; +// $list['complete'] = true; +// } else { $exportFile = $this->app['tmp.download.path'].'/'.$token->getValue() . '.zip'; $mime = 'application/zip'; - } +// } if (!$this->getFilesystem()->exists($exportFile)) { $this->app->abort(404, 'Download file not found'); @@ -159,21 +157,21 @@ class DoDownloadController extends Controller $session->save(); ignore_user_abort(true); - if ($list['count'] > 1) { +// if ($list['count'] > 1 || $list['cgu']) { \set_export::build_zip( $this->app, $token, $list, sprintf('%s/%s.zip', $this->app['tmp.download.path'], $token->getValue()) // Dest file ); - } else { - $list['complete'] = true; - $token->setData(serialize($list)); - /** @var EntityManagerInterface $manager */ - $manager = $this->app['orm.em']; - $manager->persist($token); - $manager->flush(); - } +// } else { +// $list['complete'] = true; +// $token->setData(serialize($list)); +// /** @var EntityManagerInterface $manager */ +// $manager = $this->app['orm.em']; +// $manager->persist($token); +// $manager->flush(); +// } return $this->app->json([ 'success' => true, diff --git a/lib/Alchemy/Phrasea/Controller/Prod/DownloadController.php b/lib/Alchemy/Phrasea/Controller/Prod/DownloadController.php index 1e11a60580..07b18ab0d6 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/DownloadController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/DownloadController.php @@ -17,6 +17,7 @@ use Alchemy\Phrasea\Core\Event\ExportEvent; use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Filesystem\PhraseanetFilesystem; use Alchemy\Phrasea\Model\Manipulator\TokenManipulator; +use Exception; use set_export; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -81,6 +82,7 @@ class DownloadController extends Controller * * @param Request $request * @return Response + * @throws Exception */ public function listDownloadAsync(Request $request) { @@ -98,12 +100,6 @@ class DownloadController extends Controller $this->app->abort(403); } - // "stamp_choice" is a ckbox with value "NO_STAMP" to "remove stamp" on download - $stamp_method = set_export::STAMP_ASYNC; // will not stamp, but flag files to be stamped - if($request->request->get('stamp_choice') === set_export::NO_STAMP) { - $stamp_method = set_export::NO_STAMP; - } - $list = $download->prepare_export( $this->getAuthenticatedUser(), $this->getFilesystem(), @@ -128,7 +124,7 @@ class DownloadController extends Controller try { $record = new \record_adapter($this->app, $sbasId, $file['record_id']); - } catch (\Exception $e) { + } catch (Exception $e) { continue; } @@ -183,10 +179,10 @@ class DownloadController extends Controller ]); } else { - throw new \Exception("invalid or expired token"); + throw new Exception("invalid or expired token"); } } - catch(\Exception $e) { + catch(Exception $e) { // no-op $this->app->abort(403, $e->getMessage()); } diff --git a/templates/web/common/dialog_export.html.twig b/templates/web/common/dialog_export.html.twig index 046a8ed0c7..21643d13e1 100644 --- a/templates/web/common/dialog_export.html.twig +++ b/templates/web/common/dialog_export.html.twig @@ -173,7 +173,7 @@ {% if removeable_stamp and download.has_stamp_option() == true %}
diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php index 18e7609ce5..0ff1874435 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php @@ -79,6 +79,9 @@ class DoDownloadTest extends \PhraseanetAuthenticatedWebTestCase */ public function testOneDocumentsDownload() { + $this->markTestSkipped("direct download removed by PHRAS-3958"); + + /* $nbRowLogsBefore = $this->getNbRowLogs(self::$DI['record_1']->get_databox()); $thumbnail = self::$DI['record_1']->get_thumbnail(); @@ -119,6 +122,7 @@ class DoDownloadTest extends \PhraseanetAuthenticatedWebTestCase $nbRowLogsAfter = $this->getNbRowLogs(self::$DI['record_1']->get_databox()); $this->assertGreaterThan($nbRowLogsBefore, $nbRowLogsAfter); unset($response); + */ } /** * @covers Alchemy\Phrasea\Controller\Prod\DoDownload::downloadDocuments