From 65d564723c8eb0eaa025df1e8ef1bc677b315d03 Mon Sep 17 00:00:00 2001 From: seto Date: Tue, 19 Dec 2023 16:45:12 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=A0=E3=81=AE?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=83=95=E3=82=A3=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=83=89=E3=81=AE=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/src/Utility/BcFileUploader.php | 5 +++++ .../baser-core/src/View/Helper/BcUploadHelper.php | 4 ++++ plugins/bc-mail/src/Service/MailMessagesService.php | 13 ++++++------- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/plugins/baser-core/src/Utility/BcFileUploader.php b/plugins/baser-core/src/Utility/BcFileUploader.php index 3250a7646f..9bf7cd653e 100644 --- a/plugins/baser-core/src/Utility/BcFileUploader.php +++ b/plugins/baser-core/src/Utility/BcFileUploader.php @@ -493,6 +493,11 @@ public function moveFileSessionToTmp($data, $fieldName) $uploadInfo['uploadable'] = true; $uploadInfo['ext'] = BcUtil::decodeContent($fileType, $fileName); $uploadedFile[$fieldName] = $uploadInfo; + + // 一時ファイルを一度に複数扱う場合に1ファイルしかアップロードされない問題への対応 + // 例: メールフォームのファイルフィールドなど + $uploadedFile = array_merge($this->getUploadingFiles($data['_bc_upload_id']), $uploadedFile); + $this->setUploadingFiles($uploadedFile, $data['_bc_upload_id']); return true; } diff --git a/plugins/baser-core/src/View/Helper/BcUploadHelper.php b/plugins/baser-core/src/View/Helper/BcUploadHelper.php index 46532238bb..64e6e89b94 100755 --- a/plugins/baser-core/src/View/Helper/BcUploadHelper.php +++ b/plugins/baser-core/src/View/Helper/BcUploadHelper.php @@ -157,6 +157,10 @@ public function fileLink($fieldName, $entity, $options = []) $basePath = '/baser-core/uploads/tmp/'; } + if (is_array($value)) { + return false; + } + /* ファイルのパスを取得 */ /* 画像の場合はサイズを指定する */ if (isset($settings['saveDir'])) { diff --git a/plugins/bc-mail/src/Service/MailMessagesService.php b/plugins/bc-mail/src/Service/MailMessagesService.php index 9d5bd3e069..ac0c6f5ee8 100644 --- a/plugins/bc-mail/src/Service/MailMessagesService.php +++ b/plugins/bc-mail/src/Service/MailMessagesService.php @@ -120,14 +120,13 @@ public function getIndex(array $queryParams = []) */ public function create(EntityInterface $mailContent, $postData) { - if (!$postData instanceof EntityInterface) { - // newEntity() だと配列が消えてしまうため、エンティティクラスで直接変換 - $entity = new MailMessage($postData, ['source' => 'BcMail.MailMessages']); - } else { - $entity = $postData; + $entity = $this->MailMessages->newEntity($postData); + foreach ($postData as $postKey => $postValue) { + if (is_array($postValue)) { + $entity->$postKey = $postValue; + } } - $validateEntity = $this->MailMessages->patchEntity($this->MailMessages->newEmptyEntity(), $entity->toArray()); - if (!$validateEntity->getErrors()) { + if (!$entity->getErrors()) { $mailFieldsTable = TableRegistry::getTableLocator()->get('BcMail.MailFields'); $mailFields = $mailFieldsTable->find()->where(['MailFields.mail_content_id' => $mailContent->id, 'MailFields.use_field' => true])->all(); $this->MailMessages->convertToDb($mailFields, $entity);