diff --git a/CHANGELOG.md b/CHANGELOG.md index 959855bb..e81469d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Release Notes for Campaign +## 2.9.2 - Unreleased + +### Fixed + +- Fixed a bug in which selecting a user group to import was throwing an exception ([#425](https://github.com/putyourlightson/craft-campaign/issues/425)). + ## 2.9.1 - 2023-10-17 ### Changed diff --git a/composer.json b/composer.json index e8707335..982d34b9 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "putyourlightson/craft-campaign", "description": "Send and manage email campaigns, contacts and mailing lists.", - "version": "2.9.1", + "version": "2.9.2", "type": "craft-plugin", "homepage": "https://putyourlightson.com/plugins/campaign", "license": "proprietary", diff --git a/src/controllers/ImportsController.php b/src/controllers/ImportsController.php index ce96fce4..4569491f 100644 --- a/src/controllers/ImportsController.php +++ b/src/controllers/ImportsController.php @@ -113,6 +113,9 @@ public function actionImportFile(): ?Response $this->requirePostRequest(); $import = $this->_getImportModelFromParams(); + $import->assetId = $this->request->getRequiredBodyParam('assetId'); + $import->fileName = $this->request->getRequiredBodyParam('fileName'); + $mailingListIds = $this->request->getBodyParam('mailingListIds'); $import->mailingListId = $mailingListIds[0] ?? null; @@ -186,7 +189,9 @@ public function actionImportUserGroup(): ?Response $import = $this->_getImportModelFromParams('field_'); $import->userGroupId = $this->request->getRequiredBodyParam('userGroupId'); + $mailingListIds = $this->request->getBodyParam('mailingListIds'); + $import->mailingListId = $mailingListIds[0] ?? null; if (!$import->validate()) { $errors = implode('. ', $import->getErrorSummary(true)); @@ -297,8 +302,7 @@ private function _returnFieldsTemplate(ImportModel $import, array|string|null $m private function _getImportModelFromParams(string $fieldIndexPrefix = null): ImportModel { $import = new ImportModel(); - $import->assetId = $this->request->getRequiredBodyParam('assetId'); - $import->fileName = $this->request->getRequiredBodyParam('fileName'); + $import->unsubscribe = (bool)$this->request->getBodyParam('unsubscribe'); $import->forceSubscribe = (bool)$this->request->getBodyParam('forceSubscribe'); $import->emailFieldIndex = $this->request->getBodyParam('emailFieldIndex');