Skip to content

Commit

Permalink
feat(newsletter): Remove obsolete welcome email option
Browse files Browse the repository at this point in the history
  • Loading branch information
torotil committed Oct 15, 2024
1 parent d11de54 commit 2f01a5f
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 29 deletions.
17 changes: 0 additions & 17 deletions campaignion_newsletters/campaignion_newsletters.module
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ function campaignion_webform_component_defaults_alter(&$component, $type) {
$component['extra'] += [
'lists' => [],
'opt_in_implied' => 1,
'send_welcome' => 0,
'optout_all_lists' => TRUE,
];
}
Expand Down Expand Up @@ -155,22 +154,6 @@ function campaignion_newsletters_form_webform_component_edit_form_alter(&$elemen
'#parents' => ['extra', 'opt_in_implied'],
];

$element['list_management']['welcome'] = [
'#type' => 'container',
'#attributes' => ['class' => ['form-item']],
];
$element['list_management']['welcome']['label'] = [
'#theme' => 'form_element_label',
'#title' => t('Welcome email'),
'#title_display' => 'before',
];
$element['list_management']['welcome']['enabled'] = [
'#type' => 'checkbox',
'#title' => t('Send a welcome email (for new subscribers).'),
'#default_value' => !empty($component['extra']['send_welcome']),
'#parents' => ['extra', 'send_welcome'],
];

$element['behavior']['optout_all_lists'] = [
'#type' => 'checkbox',
'#title' => t('If the email address is unsubscribed it will be unsubscribed from all email lists.'),
Expand Down
7 changes: 0 additions & 7 deletions campaignion_newsletters/src/QueueItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,6 @@ public function optIn() {
return !empty($this->args['send_optin']);
}

/**
* Check whether a welcome email should besent.
*/
public function welcome() {
return !empty($this->args['send_welcome']);
}

/**
* Trigger the queued action on the list’s provider.
*
Expand Down
2 changes: 0 additions & 2 deletions campaignion_newsletters/src/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,8 @@ public function delete($from_provider = FALSE) {
* Calculate the arguments for a queue item.
*/
public function queueItemArgs() {
$args['send_welcome'] = FALSE;
$args['send_optin'] = FALSE;
foreach ($this->components as $component) {
$args['send_welcome'] = $args['send_welcome'] || !empty($component['extra']['send_welcome']);
$args['send_optin'] = $args['send_optin'] || empty($component['extra']['opt_in_implied']);
}
return $args;
Expand Down
5 changes: 2 additions & 3 deletions campaignion_newsletters/tests/SubscriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public function testOptInThenUpdate() {
* Test merging subscriptions.
*/
public function testMerge() {
$c1 = ['cid' => 1, 'extra' => ['opt_in_implied' => 1, 'send_welcome' => 1]];
$c2 = ['cid' => 2, 'extra' => ['opt_in_implied' => 0, 'send_welcome' => 0]];
$c1 = ['cid' => 1, 'extra' => ['opt_in_implied' => 1]];
$c2 = ['cid' => 2, 'extra' => ['opt_in_implied' => 0]];
$email = '[email protected]';
$s1 = Subscription::byData(1, $email, [
'fingerprint' => 'fingerprint1',
Expand All @@ -129,7 +129,6 @@ public function testMerge() {
$this->assertEqual($s1->fingerprint, '');
// TRUE wins.
$args = $s1->queueItemArgs();
$this->assertTrue($args['send_welcome']);
$this->assertTrue($args['send_optin']);
}
}

0 comments on commit 2f01a5f

Please sign in to comment.