Skip to content

Commit

Permalink
Merge branch 'develop' into v3
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	src/elements/MailingListElement.php
#	tests/README.md
  • Loading branch information
bencroker committed Mar 26, 2024
2 parents 46440e3 + 382062c commit f79ccd0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release Notes for Campaign

## 3.0.0-beta.2 - Unreleased
## 3.0.0-beta.2 - 2024-03-26

### Added

Expand All @@ -11,6 +11,8 @@

- Fixed a bug in which the expected recipients count could fail in sendouts with very large numbers of contacts.
- Fixed a bug in which sendout actions were unavailable on the sendout index page.
- Fixed a bug in which newly created contacts were not being indexed for searching if only an email address was the only field added ([#463](https://github.com/putyourlightson/craft-campaign/issues/463)).


### Removed

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": "3.0.0-beta.1",
"version": "3.0.0-beta.2",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/campaign",
"license": "proprietary",
Expand Down
30 changes: 30 additions & 0 deletions src/elements/ContactElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ protected static function defineDefaultTableAttributes(string $source): array
*/
public ?string $subscriptionStatus = null;

/**
* @var string|null The initial email value, if there was one.
* @see getDirtyAttributes()
*/
private ?string $savedEmail = null;

/**
* @var null|FieldLayout Field layout
* @see getFieldLayout()
Expand All @@ -414,6 +420,16 @@ public function __toString(): string
return $this->email ?? '';
}

/**
* @inheritdoc
*/
public function init(): void
{
parent::init();

$this->savedEmail = $this->email;
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -896,6 +912,20 @@ public function hasRoundedThumb(): bool
return true;
}

/**
* @inheritdoc
*/
public function getDirtyAttributes(): array
{
$dirtyAttributes = parent::getDirtyAttributes();

if ($this->email !== $this->savedEmail && !in_array('email', $dirtyAttributes)) {
$dirtyAttributes[] = 'email';
}

return $dirtyAttributes;
}

/**
* @inheritdoc
* @since 2.0.0
Expand Down
1 change: 1 addition & 0 deletions src/elements/MailingListElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ protected static function defineDefaultTableAttributes(string $source): array

/**
* @var FieldLayout|null Field layout
* @see self::getFieldLayout()
*/
private ?FieldLayout $fieldLayout = null;

Expand Down
7 changes: 7 additions & 0 deletions src/elements/SendoutElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,36 +474,43 @@ protected static function defineSearchableAttributes(): array

/**
* @var CampaignElement|null
* @see self::getCampaign()
*/
private ?CampaignElement $campaign = null;

/**
* @var User|null
* @see self::getSender()
*/
private ?User $sender = null;

/**
* @var ContactElement[]|null
* @see self::getContacts()
*/
private ?array $contacts = null;

/**
* @var ContactElement[]|null
* @see self::getFailedContacts()
*/
private ?array $failedContacts = null;

/**
* @var MailingListElement[]|null
* @see self::getMailingLists()
*/
private ?array $mailingLists = null;

/**
* @var MailingListElement[]|null
* @see self::getExcludedMailingLists()
*/
private ?array $excludedMailingLists = null;

/**
* @var SegmentElement[]|null
* @see self::getSegments()
*/
private ?array $segments = null;

Expand Down
2 changes: 0 additions & 2 deletions src/services/SyncService.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,10 @@ public function syncUserMailingList(User $user, MailingListElement $mailingList)
$contactMailingListRecord = new ContactMailingListRecord();
$contactMailingListRecord->contactId = $contact->id;
$contactMailingListRecord->mailingListId = $mailingList->id;

$contactMailingListRecord->subscriptionStatus = 'subscribed';
$contactMailingListRecord->subscribed = new DateTime();
$contactMailingListRecord->sourceType = 'user';
$contactMailingListRecord->source = $user->id;

$contactMailingListRecord->save();
} // If user is not active and contact mailing list record exists then delete it
elseif ($user->status != User::STATUS_ACTIVE && $contactMailingListRecord !== null) {
Expand Down

0 comments on commit f79ccd0

Please sign in to comment.