partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit d138c8de73714d188d06c4ccc5aef86c2e95fce4
parent e1acb12444a9e77200f5183b2a57ff32005fa400
Author: Felicia Hummel <felicitus@felicitus.org>
Date:   Fri, 19 Aug 2016 14:03:52 +0200

Merge pull request #723 from partkeepr/PartKeepr-722

Part keepr 722
Diffstat:
Mapp/config/parameters.php.dist | 5+++++
Msrc/PartKeepr/CoreBundle/Services/VersionService.php | 1-
Msrc/PartKeepr/DoctrineReflectionBundle/Filter/AdvancedSearchFilter.php | 3---
Msrc/PartKeepr/FrontendBundle/Controller/IndexController.php | 5+++++
Msrc/PartKeepr/UploadedFileBundle/Controller/TemporaryFileController.php | 15++++++++++++++-
Msrc/PartKeepr/UploadedFileBundle/Tests/TemporaryFileControllerTest.php | 2--
6 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/app/config/parameters.php.dist b/app/config/parameters.php.dist @@ -230,6 +230,11 @@ $container->setParameter('partkeepr.parts.limit', false); $container->setParameter('partkeepr.parts.internalPartNumberUnique', false); /** + * Defines a limit for the maximum amount of parts allowed. Valid values are false (no limit) or an integer number + */ +$container->setParameter('partkeepr.upload.limit', false); + +/** * Specifies the PartKeepr data directory */ $container->setParameter('partkeepr.filesystem.data_directory', '%kernel.root_dir%/../data/'); diff --git a/src/PartKeepr/CoreBundle/Services/VersionService.php b/src/PartKeepr/CoreBundle/Services/VersionService.php @@ -112,7 +112,6 @@ class VersionService return; } - echo $this->getVersion(); if (version_compare($this->getVersion(), $latestVersion['version'], '<')) { $this->systemNoticeService->createUniqueSystemNotice( 'PARTKEEPR_VERSION_'.$latestVersion['version'], diff --git a/src/PartKeepr/DoctrineReflectionBundle/Filter/AdvancedSearchFilter.php b/src/PartKeepr/DoctrineReflectionBundle/Filter/AdvancedSearchFilter.php @@ -109,9 +109,6 @@ class AdvancedSearchFilter extends AbstractFilter $this->applyOrderByExpression($queryBuilder, $sorter); } - - //echo $queryBuilder->getDQL(); - } /** diff --git a/src/PartKeepr/FrontendBundle/Controller/IndexController.php b/src/PartKeepr/FrontendBundle/Controller/IndexController.php @@ -36,6 +36,11 @@ class IndexController extends Controller $aParameters['maxUploadSize'] = min($maxPostSize, $maxFileSize); + if ($this->getParameterWithDefault('partkeepr.upload.limit', false) !== false) { + $aParameters['maxUploadSize'] = $this->getParameterWithDefault('partkeepr.upload.limit', false); + } + + // @todo Hardcoded for now due to GD, see #445 $aParameters['availableImageFormats'] = ['JPG', 'GIF', 'PNG']; diff --git a/src/PartKeepr/UploadedFileBundle/Controller/TemporaryFileController.php b/src/PartKeepr/UploadedFileBundle/Controller/TemporaryFileController.php @@ -38,6 +38,9 @@ class TemporaryFileController extends FileController $fileService = $this->get('partkeepr_uploadedfile_service'); if ($request->files->has('userfile') && $request->files->get('userfile') != null) { + /** + * @var $file UploadedFile + */ $file = $request->files->get('userfile'); if (!$file->isValid()) { switch ($file->getError()) { @@ -52,7 +55,17 @@ class TemporaryFileController extends FileController throw new \Exception($error); } - /* + + + if ($this->container->hasParameter("partkeepr.upload.limit") && + $this->container->getParameter("partkeepr.upload.limit") !== false && + $file->getSize() > $this->container->getParameter("partkeepr.upload.limit")) { + + throw new \Exception($this->get('translator')->trans('The uploaded file is too large.')); + + } + + /* * @var $file UploadedFile */ $fileService->replace($uploadedFile, new File($file->getPathname())); diff --git a/src/PartKeepr/UploadedFileBundle/Tests/TemporaryFileControllerTest.php b/src/PartKeepr/UploadedFileBundle/Tests/TemporaryFileControllerTest.php @@ -113,8 +113,6 @@ class TemporaryFileControllerTest extends WebTestCase $response = json_decode($client->getResponse()->getContent()); - //var_dump($response); - $attribute = '@type'; $this->assertObjectHasAttribute($attribute, $response);