- Displays notice on step 3 of import when subscribers are added to a
segment with welcome notification enabled
This commit is contained in:
@@ -1050,6 +1050,7 @@ define(
|
||||
importResults.created = response.data.created;
|
||||
importResults.updated = response.data.updated;
|
||||
importResults.segments = response.data.segments;
|
||||
importResults.segments_with_welcome_notification = response.data.segments_with_welcome_notification;
|
||||
}
|
||||
queue.run();
|
||||
})
|
||||
@@ -1118,9 +1119,10 @@ define(
|
||||
.replace('%1$s', '<strong>' + importData.step2.updated.toLocaleString() + '</strong>')
|
||||
.replace('%2$s', '"' + importData.step2.segments.join('", "') + '"')
|
||||
: false,
|
||||
noaction: (!importData.step2.updated && !importData.step2.created)
|
||||
no_action: (!importData.step2.created && !importData.step2.updated)
|
||||
? true
|
||||
: false
|
||||
: false,
|
||||
segments_with_welcome_notification: importData.step2.segments_with_welcome_notification
|
||||
};
|
||||
|
||||
jQuery('#subscribers_data_import_results')
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace MailPoet\Subscribers\ImportExport\Import;
|
||||
|
||||
use MailPoet\Models\NewsletterOption;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Models\SubscriberCustomField;
|
||||
use MailPoet\Models\SubscriberSegment;
|
||||
@@ -68,7 +69,7 @@ class Import {
|
||||
$subscriber_fields,
|
||||
$subscriber_custom_fields
|
||||
);
|
||||
if ($wp_users) {
|
||||
if($wp_users) {
|
||||
$this->synchronizeWPUsers($wp_users);
|
||||
}
|
||||
}
|
||||
@@ -79,12 +80,19 @@ class Import {
|
||||
);
|
||||
}
|
||||
$segments = new BootStrapMenu('import');
|
||||
$segments = $segments->getSegments();
|
||||
$segments_with_welcome_notification =
|
||||
($created_subscribers || $updated_subscribers) ?
|
||||
$this->getSegmentsWithWelcomeNotification($this->segments) :
|
||||
false;
|
||||
return array(
|
||||
'result' => true,
|
||||
'data' => array(
|
||||
'created' => count($created_subscribers),
|
||||
'updated' => count($updated_subscribers),
|
||||
'segments' => $segments->getSegments()
|
||||
'segments' => $segments,
|
||||
'segments_with_welcome_notification' =>
|
||||
($segments_with_welcome_notification) ? true : false
|
||||
),
|
||||
'profiler' => $this->timeExecution()
|
||||
);
|
||||
@@ -363,4 +371,23 @@ class Import {
|
||||
$profiler_end = microtime(true);
|
||||
return ($profiler_end - $this->profiler_start) / 60;
|
||||
}
|
||||
|
||||
function getSegmentsWithWelcomeNotification($segments_ids) {
|
||||
return NewsletterOption::table_alias('options')
|
||||
->join(
|
||||
MP_NEWSLETTERS_TABLE,
|
||||
'newsletters.id = options.newsletter_id',
|
||||
'newsletters'
|
||||
)
|
||||
->join(
|
||||
MP_NEWSLETTER_OPTION_FIELDS_TABLE,
|
||||
'option_fields.id = options.option_field_id',
|
||||
'option_fields'
|
||||
)
|
||||
->whereNull('newsletters.deleted_at')
|
||||
->where('newsletters.type', 'welcome')
|
||||
->where('option_fields.name', 'segment')
|
||||
->whereIn('options.value', $segments_ids)
|
||||
->findMany();
|
||||
}
|
||||
}
|
@@ -25,9 +25,12 @@
|
||||
{{#if updated}}
|
||||
<li>{{{updated}}}</li>
|
||||
{{/if}}
|
||||
{{#if noaction}}
|
||||
{{#if no_action}}
|
||||
<li><%= __('No new subscribers were found/added.') %></li>
|
||||
{{/if}}
|
||||
{{#if segments_with_welcome_notification}}
|
||||
<li><%= __('Important note: imported subscribers will not receive any welcome emails.') %></li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</script>
|
||||
</div>
|
Reference in New Issue
Block a user