Skip to content

Commit

Permalink
Fixed user group import bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Oct 24, 2023
1 parent 2e14f17 commit 321478b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 6 additions & 2 deletions src/controllers/ImportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 321478b

Please sign in to comment.