- Displays notice on step 3 of import when subscribers are added to a

segment with welcome notification enabled
This commit is contained in:
Vlad
2016-05-25 19:22:24 -04:00
parent f17c78fda2
commit 8b9d76db8a
3 changed files with 37 additions and 5 deletions

View File

@@ -1050,6 +1050,7 @@ define(
importResults.created = response.data.created; importResults.created = response.data.created;
importResults.updated = response.data.updated; importResults.updated = response.data.updated;
importResults.segments = response.data.segments; importResults.segments = response.data.segments;
importResults.segments_with_welcome_notification = response.data.segments_with_welcome_notification;
} }
queue.run(); queue.run();
}) })
@@ -1118,9 +1119,10 @@ define(
.replace('%1$s', '<strong>' + importData.step2.updated.toLocaleString() + '</strong>') .replace('%1$s', '<strong>' + importData.step2.updated.toLocaleString() + '</strong>')
.replace('%2$s', '"' + importData.step2.segments.join('", "') + '"') .replace('%2$s', '"' + importData.step2.segments.join('", "') + '"')
: false, : false,
noaction: (!importData.step2.updated && !importData.step2.created) no_action: (!importData.step2.created && !importData.step2.updated)
? true ? true
: false : false,
segments_with_welcome_notification: importData.step2.segments_with_welcome_notification
}; };
jQuery('#subscribers_data_import_results') jQuery('#subscribers_data_import_results')

View File

@@ -1,6 +1,7 @@
<?php <?php
namespace MailPoet\Subscribers\ImportExport\Import; namespace MailPoet\Subscribers\ImportExport\Import;
use MailPoet\Models\NewsletterOption;
use MailPoet\Models\Subscriber; use MailPoet\Models\Subscriber;
use MailPoet\Models\SubscriberCustomField; use MailPoet\Models\SubscriberCustomField;
use MailPoet\Models\SubscriberSegment; use MailPoet\Models\SubscriberSegment;
@@ -79,12 +80,19 @@ class Import {
); );
} }
$segments = new BootStrapMenu('import'); $segments = new BootStrapMenu('import');
$segments = $segments->getSegments();
$segments_with_welcome_notification =
($created_subscribers || $updated_subscribers) ?
$this->getSegmentsWithWelcomeNotification($this->segments) :
false;
return array( return array(
'result' => true, 'result' => true,
'data' => array( 'data' => array(
'created' => count($created_subscribers), 'created' => count($created_subscribers),
'updated' => count($updated_subscribers), 'updated' => count($updated_subscribers),
'segments' => $segments->getSegments() 'segments' => $segments,
'segments_with_welcome_notification' =>
($segments_with_welcome_notification) ? true : false
), ),
'profiler' => $this->timeExecution() 'profiler' => $this->timeExecution()
); );
@@ -363,4 +371,23 @@ class Import {
$profiler_end = microtime(true); $profiler_end = microtime(true);
return ($profiler_end - $this->profiler_start) / 60; 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();
}
} }

View File

@@ -25,9 +25,12 @@
{{#if updated}} {{#if updated}}
<li>{{{updated}}}</li> <li>{{{updated}}}</li>
{{/if}} {{/if}}
{{#if noaction}} {{#if no_action}}
<li><%= __('No new subscribers were found/added.') %></li> <li><%= __('No new subscribers were found/added.') %></li>
{{/if}} {{/if}}
{{#if segments_with_welcome_notification}}
<li><%= __('Important note: imported subscribers will not receive any welcome emails.') %></li>
{{/if}}
</ul> </ul>
</script> </script>
</div> </div>