From b850d730687cf353ebb438c2abc35dfd07955598 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Tue, 15 Jan 2019 22:32:18 +0100 Subject: [PATCH] Return files, newFiles and removedFiles in getValue() See #2825 --- .../builder/field/UploadFormField.class.php | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php index 30911da0ff..690cdded14 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php @@ -65,10 +65,22 @@ class UploadFormField extends AbstractFormField { /** * @inheritDoc - * @return UploadFile[] + * @return UploadFile[][] */ public function getValue() { - return UploadHandler::getInstance()->getFilesForFieldId($this->getId()); + $returnValues = [ + 'files' => UploadHandler::getInstance()->getFilesForFieldId($this->getId()), + 'newFiles' => [], + 'removedFiles' => UploadHandler::getInstance()->getRemovedFiledForFieldId($this->getId(), false) + ]; + + foreach (UploadHandler::getInstance()->getFilesForFieldId($this->getId()) as $file) { + if (!$file->isProcessed()) { + $returnValues['newFiles'][] = $file; + } + } + + return $returnValues; } /** @@ -92,14 +104,14 @@ class UploadFormField extends AbstractFormField { } } - if ($this->getMinimum() !== null && count($this->getValue()) < $this->getMinimum()) { + if ($this->getMinimum() !== null && count($this->getValue()['files']) < $this->getMinimum()) { $this->addValidationError(new FormFieldValidationError( 'minimum', 'wcf.form.field.upload.error.minimum', ['minimum' => $this->getMinimum()] )); } - else if ($this->getMaximum() !== null && count($this->getValue()) > $this->getMaximum()) { + else if ($this->getMaximum() !== null && count($this->getValue()['files']) > $this->getMaximum()) { $this->addValidationError(new FormFieldValidationError( 'maximum', 'wcf.form.field.upload.error.maximum', -- 2.20.1